From 65f0435bfe0c21741db6c9f52a65e27f9103c5a8 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 11:05:56 -0600 Subject: [PATCH 1/9] Changed command structure to fix windows glide bug --- src/deployables.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/deployables.ts b/src/deployables.ts index a4b72b5..8fcf895 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -176,20 +176,23 @@ export const getAllDeployableFilesWindows = ({ .map((f) => (f.includes('.') ? f : `*.${f}`)) .join(' ') : '*'; - const excludePattern = excludeDirs.length > 0 ? excludeDirs.join('|') : ''; + const excludePattern = excludeDirs.length > 0 + ? excludeDirs + .map((f) => `\\${f}`) + .join(' ') : ''; const pattern = typeNames.length > 0 - ? typeNames.map((name) => `polyConfig: ${name}`).join('|') + ? typeNames.map((name) => `\\`).join(' ') : 'polyConfig'; const excludeCommand = excludePattern - ? ` | findstr /V /I "${excludePattern}"` + ? ` | findstr /V /I "${excludePattern}”` : ''; - const searchCommand = ` | findstr /M /I /F:/ /C:"${pattern}"`; + const searchCommand = ` | findstr /M /I /F:/ ${pattern}`; let result: string[] = []; for (const dir of includeDirs) { - const dirCommand = `dir /S /P /B ${includePattern} ${dir}`; + const dirCommand = `dir ${includePattern} /S /P /B`; const fullCommand = `${dirCommand}${excludeCommand}${searchCommand}`; try { const output = shell.exec(fullCommand).toString('utf8'); From 9217f4b3c4c633d2186be574dbb69f29aa4f2ed8 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 11:41:07 -0600 Subject: [PATCH 2/9] Added comment to explain strange syntax --- src/deployables.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/deployables.ts b/src/deployables.ts index 8fcf895..38e76b6 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -185,6 +185,8 @@ export const getAllDeployableFilesWindows = ({ ? typeNames.map((name) => `\\`).join(' ') : 'polyConfig'; + // Using two regular quotes or two smart quotes throws "The syntax of the command is incorrect". + // For some reason this configuration works. const excludeCommand = excludePattern ? ` | findstr /V /I "${excludePattern}”` : ''; From c7c1c521a7c5a7ccfd23cdb844bd3aca1c1de1de Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 12:17:20 -0600 Subject: [PATCH 3/9] Allowed directories to be specified in the command --- src/deployables.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/deployables.ts b/src/deployables.ts index 38e76b6..ad16a32 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -170,12 +170,6 @@ export const getAllDeployableFilesWindows = ({ excludeDirs, }: PolyDeployConfig): string[] => { // To get the equivalent of grep in Windows we use a combination of `dir` and `findstr` - const includePattern = - includeFilesOrExtensions.length > 0 - ? includeFilesOrExtensions - .map((f) => (f.includes('.') ? f : `*.${f}`)) - .join(' ') - : '*'; const excludePattern = excludeDirs.length > 0 ? excludeDirs .map((f) => `\\${f}`) @@ -194,6 +188,14 @@ export const getAllDeployableFilesWindows = ({ let result: string[] = []; for (const dir of includeDirs) { + const includePattern = + dir === '.' + ? includeFilesOrExtensions + .map((f) => (f.includes('.') ? f : `*.${f}`)) + .join(' ') + : includeFilesOrExtensions + .map((f) => (f.includes('.') ? f : `${dir}*.${f}`)) + .join(' '); const dirCommand = `dir ${includePattern} /S /P /B`; const fullCommand = `${dirCommand}${excludeCommand}${searchCommand}`; try { @@ -235,13 +237,13 @@ export const getAllDeployableFilesLinux = ({ export const getAllDeployableFiles = ( config: Partial = {}, ): string[] => { - config.typeNames = config.typeNames = DeployableTypeEntries.map((p) => p[0]); - config.includeDirs = config.includeDirs = ['.']; - config.includeFilesOrExtensions = config.includeFilesOrExtensions = [ + config.typeNames = config.typeNames || DeployableTypeEntries.map((p) => p[0]); + config.includeDirs = config.includeDirs || ['.']; + config.includeFilesOrExtensions = config.includeFilesOrExtensions || [ 'ts', 'js', ]; - config.excludeDirs = config.excludeDirs = [ + config.excludeDirs = config.excludeDirs || [ 'node_modules', 'dist', 'build', From 2b42d6aea0448c91bebe82c5c3c3d7563f8f869d Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 12:41:36 -0600 Subject: [PATCH 4/9] Updated excludeCommand quotations and comment --- src/deployables.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deployables.ts b/src/deployables.ts index ad16a32..419cfa1 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -180,9 +180,9 @@ export const getAllDeployableFilesWindows = ({ : 'polyConfig'; // Using two regular quotes or two smart quotes throws "The syntax of the command is incorrect". - // For some reason this configuration works. + // For some reason, starting with a regular quote and leaving the end without a quote works. const excludeCommand = excludePattern - ? ` | findstr /V /I "${excludePattern}”` + ? ` | findstr /V /I "${excludePattern}` : ''; const searchCommand = ` | findstr /M /I /F:/ ${pattern}`; From 2562716750f32852d928c4a26fab80802e1063c6 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 12:49:41 -0600 Subject: [PATCH 5/9] Updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed47453..537f65d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.23.24", + "version": "0.23.26", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { From 351c826091750f6c9fcdc63401462ae0b601d170 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Mon, 16 Jun 2025 12:54:04 -0600 Subject: [PATCH 6/9] Added package-lock.json --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d1a76da..e48cb08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.23.24", + "version": "0.23.26", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.23.24", + "version": "0.23.26", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", From 7b3208666c48679e0366a5d179d301d355be55e8 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 26 Jun 2025 09:17:30 -0600 Subject: [PATCH 7/9] Fixed config name TypeError --- package-lock.json | 4 ++-- package.json | 2 +- src/commands/prepare.ts | 7 +++++-- src/transpiler.ts | 7 +++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee29292..169f182 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.24.0", + "version": "0.24.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.24.0", + "version": "0.24.4", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", diff --git a/package.json b/package.json index 6981f9b..3cc327b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.3", + "version": "0.24.4", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { diff --git a/src/commands/prepare.ts b/src/commands/prepare.ts index f71e840..882ce0c 100644 --- a/src/commands/prepare.ts +++ b/src/commands/prepare.ts @@ -93,6 +93,9 @@ const getAllDeployables = async ( baseUrl, gitRevision, ); + if (deployable === null) { + continue; + } const fullName = `${deployable.context}.${deployable.name}`; if (found.has(fullName)) { console.error( @@ -160,7 +163,7 @@ export const prepareDeployables = async ( writeUpdatedDeployable(deployable, disableDocs), ), ); - const staged = shell.exec('git diff --name-only --cached') + const staged = shell.exec('git diff --name-only --cached', {silent:true}) .toString().split('\n').filter(Boolean); const rootPath: string = shell.exec('git rev-parse --show-toplevel', {silent:true}) .toString('utf8').replace('\n', ''); @@ -168,7 +171,7 @@ export const prepareDeployables = async ( try{ const deployableName = deployable.file.replace(`${rootPath}/`, ''); if (staged.includes(deployableName)) { - shell.echo(`Staging ${deployableName}`); + console.log(`Staging ${deployableName}`); shell.exec(`git add ${deployableName}`); } } diff --git a/src/transpiler.ts b/src/transpiler.ts index 20c7299..8192cda 100644 --- a/src/transpiler.ts +++ b/src/transpiler.ts @@ -259,6 +259,10 @@ const getPolyConfig = (types: string[], sourceFile: ts.SourceFile): any => { }; visit(sourceFile); + + if (config === null) { + return null; + } const { name, context, type, description, ...other } = config; if (!name) throw new Error("polyConfig is missing 'name'."); if (!context) throw new Error("polyConfig is missing 'context'."); @@ -471,6 +475,9 @@ export const parseDeployable = async ( DeployableTypeEntries.map((e) => e[0]), sourceFile, ); + if (polyConfig === null) { + return [null, null]; + } polyConfig.type = DeployableTsTypeToName[polyConfig.type]; const fileContents = sourceFile.getFullText(); const fileRevision = getDeployableFileRevision(fileContents); From 3c11313475b08b8ed4c24a1e2a09cab3b97372cd Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 26 Jun 2025 10:33:48 -0600 Subject: [PATCH 8/9] Revert "Fixed config name TypeError" This reverts commit 7b3208666c48679e0366a5d179d301d355be55e8. --- package-lock.json | 4 ++-- package.json | 2 +- src/commands/prepare.ts | 7 ++----- src/transpiler.ts | 7 ------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 169f182..ee29292 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.24.4", + "version": "0.24.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.24.4", + "version": "0.24.0", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", diff --git a/package.json b/package.json index 3cc327b..6981f9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.4", + "version": "0.24.3", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { diff --git a/src/commands/prepare.ts b/src/commands/prepare.ts index 882ce0c..f71e840 100644 --- a/src/commands/prepare.ts +++ b/src/commands/prepare.ts @@ -93,9 +93,6 @@ const getAllDeployables = async ( baseUrl, gitRevision, ); - if (deployable === null) { - continue; - } const fullName = `${deployable.context}.${deployable.name}`; if (found.has(fullName)) { console.error( @@ -163,7 +160,7 @@ export const prepareDeployables = async ( writeUpdatedDeployable(deployable, disableDocs), ), ); - const staged = shell.exec('git diff --name-only --cached', {silent:true}) + const staged = shell.exec('git diff --name-only --cached') .toString().split('\n').filter(Boolean); const rootPath: string = shell.exec('git rev-parse --show-toplevel', {silent:true}) .toString('utf8').replace('\n', ''); @@ -171,7 +168,7 @@ export const prepareDeployables = async ( try{ const deployableName = deployable.file.replace(`${rootPath}/`, ''); if (staged.includes(deployableName)) { - console.log(`Staging ${deployableName}`); + shell.echo(`Staging ${deployableName}`); shell.exec(`git add ${deployableName}`); } } diff --git a/src/transpiler.ts b/src/transpiler.ts index 8192cda..20c7299 100644 --- a/src/transpiler.ts +++ b/src/transpiler.ts @@ -259,10 +259,6 @@ const getPolyConfig = (types: string[], sourceFile: ts.SourceFile): any => { }; visit(sourceFile); - - if (config === null) { - return null; - } const { name, context, type, description, ...other } = config; if (!name) throw new Error("polyConfig is missing 'name'."); if (!context) throw new Error("polyConfig is missing 'context'."); @@ -475,9 +471,6 @@ export const parseDeployable = async ( DeployableTypeEntries.map((e) => e[0]), sourceFile, ); - if (polyConfig === null) { - return [null, null]; - } polyConfig.type = DeployableTsTypeToName[polyConfig.type]; const fileContents = sourceFile.getFullText(); const fileRevision = getDeployableFileRevision(fileContents); From 4c90af1b1058437e0c93ad32b54d1e98c5474c75 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Thu, 26 Jun 2025 11:08:17 -0600 Subject: [PATCH 9/9] Fixed windows find deployables command to ignore files without polyConfig --- package-lock.json | 4 ++-- package.json | 2 +- src/commands/prepare.ts | 11 ++++------- src/deployables.ts | 14 ++++++-------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee29292..169f182 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.24.0", + "version": "0.24.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.24.0", + "version": "0.24.4", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", diff --git a/package.json b/package.json index 6981f9b..3cc327b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.24.3", + "version": "0.24.4", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { diff --git a/src/commands/prepare.ts b/src/commands/prepare.ts index f71e840..0b5db55 100644 --- a/src/commands/prepare.ts +++ b/src/commands/prepare.ts @@ -160,16 +160,13 @@ export const prepareDeployables = async ( writeUpdatedDeployable(deployable, disableDocs), ), ); - const staged = shell.exec('git diff --name-only --cached') + const staged = shell.exec('git diff --name-only --cached', {silent:true}) .toString().split('\n').filter(Boolean); - const rootPath: string = shell.exec('git rev-parse --show-toplevel', {silent:true}) - .toString('utf8').replace('\n', ''); for (const deployable of dirtyDeployables) { try{ - const deployableName = deployable.file.replace(`${rootPath}/`, ''); - if (staged.includes(deployableName)) { - shell.echo(`Staging ${deployableName}`); - shell.exec(`git add ${deployableName}`); + if (staged.includes(deployable.file)) { + shell.echo(`Staging ${deployable.file}`); + shell.exec(`git add ${deployable.file}`); } } catch (error) { diff --git a/src/deployables.ts b/src/deployables.ts index b6ffed5..bbb3698 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -177,15 +177,13 @@ export const getAllDeployableFilesWindows = ({ .join(' ') : ''; const pattern = typeNames.length > 0 - ? typeNames.map((name) => `\\`).join(' ') - : 'polyConfig'; + ? typeNames.map((name) => `/C:"polyConfig: ${name}"`).join(' ') + : 'C/:"polyConfig"'; - // Using two regular quotes or two smart quotes throws "The syntax of the command is incorrect". - // For some reason, starting with a regular quote and leaving the end without a quote works. const excludeCommand = excludePattern - ? ` | findstr /V /I "${excludePattern}` + ? ` | findstr /V /I "${excludePattern}"` : ''; - const searchCommand = ` | findstr /M /I /F:/ ${pattern}`; + const searchCommand = ` | findstr /M /I /S /F:/ ${pattern} *.*`; let result: string[] = []; for (const dir of includeDirs) { @@ -197,10 +195,10 @@ export const getAllDeployableFilesWindows = ({ : includeFilesOrExtensions .map((f) => (f.includes('.') ? f : `${dir}*.${f}`)) .join(' '); - const dirCommand = `dir ${includePattern} /S /P /B`; + const dirCommand = `dir ${includePattern} /S /P /B > NUL`; const fullCommand = `${dirCommand}${excludeCommand}${searchCommand}`; try { - const output = shell.exec(fullCommand).toString('utf8'); + const output = shell.exec(fullCommand, {silent:true}).toString('utf8'); result = result.concat(output.split(/\r?\n/).filter(Boolean)); } catch {} }