Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apack.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"cmd": "$(zap-cli) generate --noUi --noServer -o ${generationOutput} --packageMatch fuzzy [ --zcl ${zcl.zigbeeZclJsonFile} | --zcl ${sdkRoot}/app/zcl/zcl-zap.json ] [ --zcl ${zcl.matterZclJsonFile} | --zcl ${sdkRoot}/extension/matter_extension/src/app/zap-templates/zcl/zcl.json ] [ --generationTemplate ${zcl.zigbeeTemplateJsonFile} | --generationTemplate ${sdkRoot}/protocol/zigbee/app/framework/gen-template/gen-templates.json ] [ --generationTemplate ${zcl.matterTemplateJsonFile} | --generationTemplate ${sdkRoot}/extension/matter_extension/src/app/zap-templates/app-templates.json ] --in ${contentFolder} --noLoadingFailure --appendGenerationSubdirectory --upgradeZapFile --no-emoji"
},
"uc_upgrade": {
"cmd": "$(zap-cli) upgrade --results ${results} -d ${tempContentFolder} [ --zcl ${zcl.zigbeeZclJsonFile} | --zcl ${sdkRoot}/app/zcl/zcl-zap.json ] [ --zcl ${zcl.matterZclJsonFile} | --zcl ${sdkRoot}/extension/matter_extension/src/app/zap-templates/zcl/zcl.json ] [ --generationTemplate ${zcl.zigbeeTemplateJsonFile} | --generationTemplate ${sdkRoot}/protocol/zigbee/app/framework/gen-template/gen-templates.json ] [ --generationTemplate ${zcl.matterTemplateJsonFile} | --generationTemplate ${sdkRoot}/extension/matter_extension/src/app/zap-templates/app-templates.json ] --noLoadingFailure --no-emoji"
"cmd": "$(zap-cli) upgrade --results ${results} -d ${tempContentFolder} --upgradeOutputSubdirectory zcl [ --zcl ${zcl.zigbeeZclJsonFile} | --zcl ${sdkRoot}/app/zcl/zcl-zap.json ] [ --zcl ${zcl.matterZclJsonFile} | --zcl ${sdkRoot}/extension/matter_extension/src/app/zap-templates/zcl/zcl.json ] [ --generationTemplate ${zcl.zigbeeTemplateJsonFile} | --generationTemplate ${sdkRoot}/protocol/zigbee/app/framework/gen-template/gen-templates.json ] [ --generationTemplate ${zcl.matterTemplateJsonFile} | --generationTemplate ${sdkRoot}/extension/matter_extension/src/app/zap-templates/app-templates.json ] --noLoadingFailure --no-emoji"
},
"zapHelp": {
"cmd": "$(zap) --help"
Expand Down
31 changes: 20 additions & 11 deletions src-electron/main-process/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,30 @@ async function noopConvert(resultsFile, logger) {
}

/**
* Find all zap files in a given directory
* @param {*} dir
* @returns all .zap files in the given directory
* Find all zap files in a given directory, optionally skipping a named
* subdirectory (e.g. the output subdirectory used by upgradeZapFile so that
* re-runs don't pick up previously upgraded files).
*
* @param {string} dir - Directory to search.
* @param {string|null} skipSubdirectory - Name of a directory to exclude at
* every level of the recursive search (e.g. the upgrade output directory so
* that re-runs don't pick up already-upgraded files).
* @returns {string[]} Paths of all .zap files found.
*/
function findZapFiles(dir) {
function findZapFiles(dir, skipSubdirectory = null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we investigated why this was not an issue before and is an issue now? We should not be hardcoding things like this. What is the underlying issue?

@paulr34 paulr34 Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. We should meet with all teams involved and discuss the best path forward.

At the moment, I see two options:

1.) Merge this PR now to unblock progress, then follow up with a separate PR once we've aligned on the long-term solution.
2.) Hold off on merging, meet with the team to determine where the path should be defined, understand why this behavior started occurring, and then implement a fully agreed-upon solution.

Either way, this PR is available if timing becomes a factor and we need to unblock work quickly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compromise: put the path in apack.json for now.

That avoids hardcoding it in ZAP and doesn't require SDK changes immediately. ZAP can consume the path from apack.json, and we can revisit the long-term ownership of the path later if needed.

let zapFiles = []

// Read all items in the directory
const items = fs.readdirSync(dir)

// Loop through each item
items.forEach((item) => {
const itemPath = path.join(dir, item)
const stats = fs.statSync(itemPath)

// If it's a directory, search recursively
if (stats.isDirectory()) {
zapFiles = zapFiles.concat(findZapFiles(itemPath))
if (skipSubdirectory && item === skipSubdirectory) return
zapFiles = zapFiles.concat(findZapFiles(itemPath, skipSubdirectory))
}

// If it's a file and has .zap extension, add to the list
if (stats.isFile() && path.extname(item) === '.zap') {
zapFiles.push(itemPath)
}
Expand All @@ -233,7 +236,7 @@ function findZapFiles(dir) {
* @param {*} options
*/
async function upgradeZapFile(argv, options) {
let zapFiles = findZapFiles(argv.d)
let zapFiles = findZapFiles(argv.d, argv.upgradeOutputSubdirectory)
let upgrade_results = argv.results
for (let i = 0; i < zapFiles.length; i++) {
let zapFile = zapFiles[i]
Expand Down Expand Up @@ -309,7 +312,13 @@ async function upgradeZapFile(argv, options) {
upgradeTemplatePackages: upgradeTemplatePackages
})
options.logger(env.formatEmojiMessage('👈', `read in: ${zapFile}`))
let of = outputFile(zapFile, zapFile)
let of = argv.upgradeOutputSubdirectory
? path.join(
path.dirname(zapFile),
argv.upgradeOutputSubdirectory,
path.basename(zapFile)
)
: outputFile(zapFile, zapFile)
let parent = path.dirname(of)
if (!fs.existsSync(parent)) {
fs.mkdirSync(parent, { recursive: true })
Expand Down
5 changes: 5 additions & 0 deletions src-electron/util/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ export function processCommandLineArguments(argv) {
desc: 'Specifying the output YAML file to capture convert results.',
type: 'string'
})
.option('upgradeOutputSubdirectory', {
desc: 'When upgrading .zap files, write each upgraded file into this named subdirectory relative to the original file location.',
type: 'string',
default: null
})
.option('validateOutput', {
desc: 'Optional file path to write the validation report (.json or .yaml). For the validate command, -o/--output is accepted as an alias when this option is omitted.',
type: 'string',
Expand Down
Loading