diff --git a/README.md b/README.md index 782a57e..5227b7d 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,7 @@ FLAG DESCRIPTIONS of your code. ``` -_See code: [src/commands/data-code-extension/function/deploy.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/function/deploy.ts)_ +_See code: [src/commands/data-code-extension/function/deploy.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/function/deploy.ts)_ ## `sf data-code-extension function init` @@ -195,7 +195,7 @@ FLAG DESCRIPTIONS The directory path where the new package will be initialized. The directory will be created if it doesn't exist. ``` -_See code: [src/commands/data-code-extension/function/init.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/function/init.ts)_ +_See code: [src/commands/data-code-extension/function/init.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/function/init.ts)_ ## `sf data-code-extension function run` @@ -224,18 +224,13 @@ DESCRIPTION EXAMPLES Run a function package against the org with alias "myorg": - $ sf data-code-extension function run --entrypoint ./my-package --target-org myorg + $ sf data-code-extension function run --entrypoint ./my-package/entrypoint.py --target-org myorg Run with a custom config file: - $ sf data-code-extension function run --entrypoint ./my-package --target-org myorg --config-file \ + $ sf data-code-extension function run --entrypoint ./my-package/entrypoint.py --target-org myorg --config-file \ ./payload/config.json - Run with dependencies: - - $ sf data-code-extension function run --entrypoint ./my-package --target-org myorg --dependencies \ - "pandas==2.0.0" - FLAG DESCRIPTIONS -e, --entrypoint= Entrypoint file for the package to run. @@ -257,7 +252,7 @@ FLAG DESCRIPTIONS package's requirements.txt. ``` -_See code: [src/commands/data-code-extension/function/run.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/function/run.ts)_ +_See code: [src/commands/data-code-extension/function/run.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/function/run.ts)_ ## `sf data-code-extension function scan` @@ -269,7 +264,7 @@ USAGE FLAGS -d, --dry-run Preview changes without modifying any files. - -e, --entrypoint= Path to the config.json file to update. + -e, --entrypoint= Path to the entrypoint Python file to scan. -n, --no-requirements Skip updating the requirements.txt file. --config-file= Path to an alternate config file. @@ -289,11 +284,7 @@ EXAMPLES Scan with a custom entrypoint file: - $ sf data-code-extension function scan --entrypoint my_script.py - - Scan with an alternate config file: - - $ sf data-code-extension function scan --config-file alternate-config.json + $ sf data-code-extension function scan --entrypoint payload/entrypoint.py Perform a dry run to see what would be changed: @@ -309,10 +300,10 @@ FLAG DESCRIPTIONS When set, performs a scan and shows what would be changed but does not modify any files. Useful for reviewing changes before applying them. - -e, --entrypoint= Path to the config.json file to update. + -e, --entrypoint= Path to the entrypoint Python file to scan. - The path to the config.json file that will be analyzed and updated with discovered permissions. Defaults to - 'payload/config.json' in the current directory. + The path to the entrypoint Python file that will be analyzed. Defaults to 'payload/entrypoint.py' in the current + directory. -n, --no-requirements Skip updating the requirements.txt file. @@ -325,7 +316,7 @@ FLAG DESCRIPTIONS Useful for testing different configurations without modifying the package's primary config.json. ``` -_See code: [src/commands/data-code-extension/function/scan.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/function/scan.ts)_ +_See code: [src/commands/data-code-extension/function/scan.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/function/scan.ts)_ ## `sf data-code-extension function zip` @@ -353,10 +344,6 @@ EXAMPLES $ sf data-code-extension function zip --package-dir ./my-function-package - Create an archive with network configuration for Jupyter notebooks: - - $ sf data-code-extension function zip --package-dir ./my-function-package --network host - FLAG DESCRIPTIONS -n, --network= Network configuration, typically used for Jupyter notebook packages. @@ -369,7 +356,7 @@ FLAG DESCRIPTIONS contain a valid package structure with config.json. ``` -_See code: [src/commands/data-code-extension/function/zip.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/function/zip.ts)_ +_See code: [src/commands/data-code-extension/function/zip.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/function/zip.ts)_ ## `sf data-code-extension script deploy` @@ -411,11 +398,6 @@ EXAMPLES $ sf data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" \ --package-dir ./package --target-org myorg --cpu-size CPU_4XL - Deploy with network configuration for Jupyter notebooks: - - $ sf data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" \ - --package-dir ./package --target-org myorg --network host - FLAG DESCRIPTIONS -d, --description= Description of the package. @@ -453,7 +435,7 @@ FLAG DESCRIPTIONS of your code. ``` -_See code: [src/commands/data-code-extension/script/deploy.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/script/deploy.ts)_ +_See code: [src/commands/data-code-extension/script/deploy.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/script/deploy.ts)_ ## `sf data-code-extension script init` @@ -485,7 +467,7 @@ FLAG DESCRIPTIONS The directory path where the new package will be initialized. The directory will be created if it doesn't exist. ``` -_See code: [src/commands/data-code-extension/script/init.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/script/init.ts)_ +_See code: [src/commands/data-code-extension/script/init.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/script/init.ts)_ ## `sf data-code-extension script run` @@ -514,17 +496,13 @@ DESCRIPTION EXAMPLES Run a script package against the org with alias "myorg": - $ sf data-code-extension script run --entrypoint ./my-package --target-org myorg + $ sf data-code-extension script run --entrypoint ./my-package/entrypoint.py --target-org myorg Run with a custom config file: - $ sf data-code-extension script run --entrypoint ./my-package --target-org myorg --config-file \ + $ sf data-code-extension script run --entrypoint ./my-package/entrypoint.py --target-org myorg --config-file \ ./payload/config.json - Run with dependencies: - - $ sf data-code-extension script run --entrypoint ./my-package --target-org myorg --dependencies "pandas==2.0.0" - FLAG DESCRIPTIONS -e, --entrypoint= Entrypoint file for the package to run. @@ -546,7 +524,7 @@ FLAG DESCRIPTIONS package's requirements.txt. ``` -_See code: [src/commands/data-code-extension/script/run.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/script/run.ts)_ +_See code: [src/commands/data-code-extension/script/run.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/script/run.ts)_ ## `sf data-code-extension script scan` @@ -558,7 +536,7 @@ USAGE FLAGS -d, --dry-run Preview changes without modifying any files. - -e, --entrypoint= Path to the config.json file to update. + -e, --entrypoint= Path to the entrypoint Python file to scan. -n, --no-requirements Skip updating the requirements.txt file. --config-file= Path to an alternate config file. @@ -578,11 +556,7 @@ EXAMPLES Scan with a custom entrypoint file: - $ sf data-code-extension script scan --entrypoint my_script.py - - Scan with an alternate config file: - - $ sf data-code-extension script scan --config-file alternate-config.json + $ sf data-code-extension script scan --entrypoint payload/entrypoint.py Perform a dry run to see what would be changed: @@ -598,10 +572,10 @@ FLAG DESCRIPTIONS When set, performs a scan and shows what would be changed but does not modify any files. Useful for reviewing changes before applying them. - -e, --entrypoint= Path to the config.json file to update. + -e, --entrypoint= Path to the entrypoint Python file to scan. - The path to the config.json file that will be analyzed and updated with discovered permissions. Defaults to - 'payload/config.json' in the current directory. + The path to the entrypoint Python file that will be analyzed. Defaults to 'payload/entrypoint.py' in the current + directory. -n, --no-requirements Skip updating the requirements.txt file. @@ -614,7 +588,7 @@ FLAG DESCRIPTIONS Useful for testing different configurations without modifying the package's primary config.json. ``` -_See code: [src/commands/data-code-extension/script/scan.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/script/scan.ts)_ +_See code: [src/commands/data-code-extension/script/scan.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/script/scan.ts)_ ## `sf data-code-extension script zip` @@ -642,10 +616,6 @@ EXAMPLES $ sf data-code-extension script zip --package-dir ./my-script-package - Create an archive with network configuration for Jupyter notebooks: - - $ sf data-code-extension script zip --package-dir ./my-script-package --network host - FLAG DESCRIPTIONS -n, --network= Network configuration, typically used for Jupyter notebook packages. @@ -658,6 +628,6 @@ FLAG DESCRIPTIONS contain a valid package structure with config.json. ``` -_See code: [src/commands/data-code-extension/script/zip.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/0.1.0/src/commands/data-code-extension/script/zip.ts)_ +_See code: [src/commands/data-code-extension/script/zip.ts](https://github.com/salesforcecli/plugin-data-code-extension/blob/v0.1.0/src/commands/data-code-extension/script/zip.ts)_ diff --git a/messages/deploy.md b/messages/deploy.md index 40028ec..025a893 100644 --- a/messages/deploy.md +++ b/messages/deploy.md @@ -16,10 +16,6 @@ Deploys an initialized and packaged Data Cloud code extension to a Salesforce or <%= config.bin %> data-code-extension %s deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./package --target-org myorg --cpu-size CPU_4XL -- Deploy with network configuration for Jupyter notebooks: - - <%= config.bin %> data-code-extension %s deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./package --target-org myorg --network host - # examples.script - Deploy a script package to the org with alias "myorg": @@ -30,10 +26,6 @@ Deploys an initialized and packaged Data Cloud code extension to a Salesforce or <%= config.bin %> data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./package --target-org myorg --cpu-size CPU_4XL -- Deploy with network configuration for Jupyter notebooks: - - <%= config.bin %> data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./package --target-org myorg --network host - # examples.function - Deploy a function package to the org with alias "myorg": diff --git a/messages/run.md b/messages/run.md index c78762f..a62e35a 100644 --- a/messages/run.md +++ b/messages/run.md @@ -10,15 +10,11 @@ Executes an initialized Data Cloud custom code package against a Salesforce org. - Run a %s package against the org with alias "myorg": - <%= config.bin %> data-code-extension %s run --entrypoint ./my-package --target-org myorg + <%= config.bin %> data-code-extension %s run --entrypoint ./my-package/entrypoint.py --target-org myorg - Run with a custom config file: - <%= config.bin %> data-code-extension %s run --entrypoint ./my-package --target-org myorg --config-file ./payload/config.json - -- Run with dependencies: - - <%= config.bin %> data-code-extension %s run --entrypoint ./my-package --target-org myorg --dependencies "pandas==2.0.0" + <%= config.bin %> data-code-extension %s run --entrypoint ./my-package/entrypoint.py --target-org myorg --config-file ./payload/config.json # info.checkingPython diff --git a/messages/scan.md b/messages/scan.md index 96d7388..6e04545 100644 --- a/messages/scan.md +++ b/messages/scan.md @@ -14,11 +14,7 @@ Scans Python files in an initialized Data Code Extension package directory to id - Scan with a custom entrypoint file: - <%= config.bin %> data-code-extension %s scan --entrypoint my_script.py - -- Scan with an alternate config file: - - <%= config.bin %> data-code-extension %s scan --config-file alternate-config.json + <%= config.bin %> data-code-extension %s scan --entrypoint payload/entrypoint.py - Perform a dry run to see what would be changed: @@ -109,7 +105,7 @@ Failed to scan package at '%s': %s - Verify the config file path is correct - Check if you're in the right directory - Run 'init' command first if package is not initialized -- Use default config path: payload/config.json +- Use default entrypoint path: payload/entrypoint.py # actions.notInPackageDir @@ -140,11 +136,11 @@ Optional path to an alternate JSON config file to use instead of the package's d # flags.entrypoint.summary -Path to the config.json file to update. +Path to the entrypoint Python file to scan. # flags.entrypoint.description -The path to the config.json file that will be analyzed and updated with discovered permissions. Defaults to 'payload/config.json' in the current directory. +The path to the entrypoint Python file that will be analyzed. Defaults to 'payload/entrypoint.py' in the current directory. # flags.dryRun.summary diff --git a/messages/zip.md b/messages/zip.md index 4ee6595..91b7a10 100644 --- a/messages/zip.md +++ b/messages/zip.md @@ -12,10 +12,6 @@ Creates a ZIP archive of an initialized Data Code Extension package for deployme <%= config.bin %> data-code-extension %s zip --package-dir ./my-%s-package -- Create an archive with network configuration for Jupyter notebooks: - - <%= config.bin %> data-code-extension %s zip --package-dir ./my-%s-package --network host - # info.checkingPython Checking Python version... diff --git a/src/commands/data-code-extension/function/run.ts b/src/commands/data-code-extension/function/run.ts index 4ff9e24..add97cc 100644 --- a/src/commands/data-code-extension/function/run.ts +++ b/src/commands/data-code-extension/function/run.ts @@ -24,7 +24,7 @@ export default class Run extends RunBase { public static readonly state = 'beta'; public static readonly summary = messages.getMessage('summary', ['function']); public static readonly description = messages.getMessage('description'); - public static readonly examples = messages.getMessages('examples', ['function', 'function', 'function', 'function']); + public static readonly examples = messages.getMessages('examples', ['function', 'function', 'function']); public static readonly flags = { entrypoint: Flags.file({ diff --git a/src/commands/data-code-extension/function/scan.ts b/src/commands/data-code-extension/function/scan.ts index 5e29bff..ee8e109 100644 --- a/src/commands/data-code-extension/function/scan.ts +++ b/src/commands/data-code-extension/function/scan.ts @@ -30,7 +30,6 @@ export default class Scan extends ScanBase { 'function', 'function', 'function', - 'function', ]); public static readonly flags = { diff --git a/src/commands/data-code-extension/function/zip.ts b/src/commands/data-code-extension/function/zip.ts index cf7f6d2..e81900e 100644 --- a/src/commands/data-code-extension/function/zip.ts +++ b/src/commands/data-code-extension/function/zip.ts @@ -24,13 +24,7 @@ export default class Zip extends ZipBase { public static readonly state = 'beta'; public static readonly summary = messages.getMessage('summary', ['function']); public static readonly description = messages.getMessage('description'); - public static readonly examples = messages.getMessages('examples', [ - 'function', - 'function', - 'function', - 'function', - 'function', - ]); + public static readonly examples = messages.getMessages('examples', ['function', 'function', 'function']); public static readonly flags = { 'package-dir': Flags.directory({ diff --git a/src/commands/data-code-extension/script/run.ts b/src/commands/data-code-extension/script/run.ts index 79f7e98..24ba0c5 100644 --- a/src/commands/data-code-extension/script/run.ts +++ b/src/commands/data-code-extension/script/run.ts @@ -24,7 +24,7 @@ export default class Run extends RunBase { public static readonly state = 'beta'; public static readonly summary = messages.getMessage('summary', ['script']); public static readonly description = messages.getMessage('description'); - public static readonly examples = messages.getMessages('examples', ['script', 'script', 'script', 'script']); + public static readonly examples = messages.getMessages('examples', ['script', 'script', 'script']); public static readonly flags = { entrypoint: Flags.file({ diff --git a/src/commands/data-code-extension/script/scan.ts b/src/commands/data-code-extension/script/scan.ts index 57ff80e..af3f6a0 100644 --- a/src/commands/data-code-extension/script/scan.ts +++ b/src/commands/data-code-extension/script/scan.ts @@ -30,7 +30,6 @@ export default class Scan extends ScanBase { 'script', 'script', 'script', - 'script', ]); public static readonly flags = { diff --git a/src/commands/data-code-extension/script/zip.ts b/src/commands/data-code-extension/script/zip.ts index d769427..c80889d 100644 --- a/src/commands/data-code-extension/script/zip.ts +++ b/src/commands/data-code-extension/script/zip.ts @@ -24,13 +24,7 @@ export default class Zip extends ZipBase { public static readonly state = 'beta'; public static readonly summary = messages.getMessage('summary', ['script']); public static readonly description = messages.getMessage('description'); - public static readonly examples = messages.getMessages('examples', [ - 'script', - 'script', - 'script', - 'script', - 'script', - ]); + public static readonly examples = messages.getMessages('examples', ['script', 'script', 'script']); public static readonly flags = { 'package-dir': Flags.directory({ diff --git a/src/utils/datacodeBinaryExecutor.ts b/src/utils/datacodeBinaryExecutor.ts index b89b6ea..1774153 100644 --- a/src/utils/datacodeBinaryExecutor.ts +++ b/src/utils/datacodeBinaryExecutor.ts @@ -14,7 +14,10 @@ * limitations under the License. */ import { spawn } from 'node:child_process'; +import { debuglog } from 'node:util'; import { SfError } from '@salesforce/core'; + +const debug = debuglog('datacustomcode'); import { Messages } from '@salesforce/core'; import { type PythonVersionInfo } from './pythonChecker.js'; import { type PipPackageInfo } from './pipChecker.js'; @@ -148,7 +151,7 @@ export class DatacodeBinaryExecutor { args.push('--config', configFile); } - args.push(config ?? 'payload/config.json'); + args.push(config ?? 'payload/entrypoint.py'); try { const { stdout, stderr } = await spawnAsync('datacustomcode', args, { @@ -313,6 +316,7 @@ export class DatacodeBinaryExecutor { } return new Promise((resolve, reject) => { + debug('deploy spawn: datacustomcode %o', args); const child = spawn('datacustomcode', args, { timeout: 300_000, env: { ...process.env, PYTHONUNBUFFERED: '1' }, @@ -324,16 +328,19 @@ export class DatacodeBinaryExecutor { child.stdout.on('data', (chunk: Buffer) => { const text = chunk.toString(); stdout += text; + debug('deploy stdout chunk: %s', text); process.stdout.write(text); }); child.stderr.on('data', (chunk: Buffer) => { const text = chunk.toString(); stderr += text; + debug('deploy stderr chunk: %s', text); process.stderr.write(text); }); child.on('close', (code) => { + debug('deploy exit code: %d', code); const stdoutTrimmed = stdout.trim(); const stderrTrimmed = stderr.trim(); @@ -395,6 +402,7 @@ export class DatacodeBinaryExecutor { }); child.on('error', (err) => { + debug('deploy spawn error: %o', err); const sfError = new SfError( messages.getMessage('error.deployExecutionFailed', [name, err.message]), 'DeployExecutionFailed', diff --git a/src/utils/spawnHelper.ts b/src/utils/spawnHelper.ts index 82e07b3..54402a6 100644 --- a/src/utils/spawnHelper.ts +++ b/src/utils/spawnHelper.ts @@ -14,6 +14,9 @@ * limitations under the License. */ import { spawn } from 'node:child_process'; +import { debuglog } from 'node:util'; + +const debug = debuglog('datacustomcode'); export type SpawnResult = { stdout: string; stderr: string }; @@ -35,6 +38,7 @@ export type SpawnOptions = { */ export async function spawnAsync(command: string, args: string[], options?: SpawnOptions): Promise { return new Promise((resolve, reject) => { + debug('spawn: %s %o options: %o', command, args, options); const child = spawn(command, args, { timeout: options?.timeout, cwd: options?.cwd, @@ -53,6 +57,7 @@ export async function spawnAsync(command: string, args: string[], options?: Spaw }); child.on('close', (code) => { + debug('exit %d | stdout: %s | stderr: %s', code, stdout, stderr); if (code !== 0) { const err = new Error(`Process exited with code ${code ?? 'unknown'}`) as SpawnError; err.stdout = stdout; @@ -65,6 +70,7 @@ export async function spawnAsync(command: string, args: string[], options?: Spaw }); child.on('error', (err) => { + debug('spawn error: %o', err); const spawnErr = err as SpawnError; spawnErr.stdout = stdout; spawnErr.stderr = stderr;