@heroku/plugin-compute 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +207 -0
- package/README.md +93 -0
- package/lib/commands/compute/config/get.d.ts +19 -0
- package/lib/commands/compute/config/get.js +76 -0
- package/lib/commands/compute/config/get.js.map +1 -0
- package/lib/commands/compute/config/list.d.ts +16 -0
- package/lib/commands/compute/config/list.js +57 -0
- package/lib/commands/compute/config/list.js.map +1 -0
- package/lib/commands/compute/config/set.d.ts +20 -0
- package/lib/commands/compute/config/set.js +99 -0
- package/lib/commands/compute/config/set.js.map +1 -0
- package/lib/commands/compute/config/unset.d.ts +20 -0
- package/lib/commands/compute/config/unset.js +93 -0
- package/lib/commands/compute/config/unset.js.map +1 -0
- package/lib/commands/compute/deploy.d.ts +18 -0
- package/lib/commands/compute/deploy.js +95 -0
- package/lib/commands/compute/deploy.js.map +1 -0
- package/lib/commands/compute/display.d.ts +26 -0
- package/lib/commands/compute/display.js +188 -0
- package/lib/commands/compute/display.js.map +1 -0
- package/lib/commands/compute/generate.d.ts +21 -0
- package/lib/commands/compute/generate.js +174 -0
- package/lib/commands/compute/generate.js.map +1 -0
- package/lib/commands/compute/get/build-log.d.ts +17 -0
- package/lib/commands/compute/get/build-log.js +62 -0
- package/lib/commands/compute/get/build-log.js.map +1 -0
- package/lib/commands/compute/get/runtime-log.d.ts +17 -0
- package/lib/commands/compute/get/runtime-log.js +79 -0
- package/lib/commands/compute/get/runtime-log.js.map +1 -0
- package/lib/commands/compute/list.d.ts +13 -0
- package/lib/commands/compute/list.js +55 -0
- package/lib/commands/compute/list.js.map +1 -0
- package/lib/commands/compute/scale.d.ts +23 -0
- package/lib/commands/compute/scale.js +112 -0
- package/lib/commands/compute/scale.js.map +1 -0
- package/lib/commands/compute/source/retrieve.d.ts +18 -0
- package/lib/commands/compute/source/retrieve.js +71 -0
- package/lib/commands/compute/source/retrieve.js.map +1 -0
- package/lib/commands/compute/tail/runtime-log.d.ts +17 -0
- package/lib/commands/compute/tail/runtime-log.js +82 -0
- package/lib/commands/compute/tail/runtime-log.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/shared/computeApp.d.ts +10 -0
- package/lib/shared/computeApp.js +82 -0
- package/lib/shared/computeApp.js.map +1 -0
- package/lib/shared/computeBundle.d.ts +9 -0
- package/lib/shared/computeBundle.js +202 -0
- package/lib/shared/computeBundle.js.map +1 -0
- package/lib/shared/computeConfig.d.ts +2 -0
- package/lib/shared/computeConfig.js +37 -0
- package/lib/shared/computeConfig.js.map +1 -0
- package/lib/shared/computeConnectApi.d.ts +16 -0
- package/lib/shared/computeConnectApi.js +59 -0
- package/lib/shared/computeConnectApi.js.map +1 -0
- package/lib/shared/computeGenerateSkeletons.d.ts +2 -0
- package/lib/shared/computeGenerateSkeletons.js +262 -0
- package/lib/shared/computeGenerateSkeletons.js.map +1 -0
- package/lib/shared/computeGenerateSource.d.ts +8 -0
- package/lib/shared/computeGenerateSource.js +120 -0
- package/lib/shared/computeGenerateSource.js.map +1 -0
- package/lib/shared/computeLogStream.d.ts +4 -0
- package/lib/shared/computeLogStream.js +108 -0
- package/lib/shared/computeLogStream.js.map +1 -0
- package/lib/shared/computeQuery.d.ts +52 -0
- package/lib/shared/computeQuery.js +168 -0
- package/lib/shared/computeQuery.js.map +1 -0
- package/lib/shared/computeTelemetryDrain.d.ts +11 -0
- package/lib/shared/computeTelemetryDrain.js +78 -0
- package/lib/shared/computeTelemetryDrain.js.map +1 -0
- package/lib/shared/herokuProxyApi.d.ts +62 -0
- package/lib/shared/herokuProxyApi.js +243 -0
- package/lib/shared/herokuProxyApi.js.map +1 -0
- package/lib/shared/metadataApiVersion.d.ts +2 -0
- package/lib/shared/metadataApiVersion.js +25 -0
- package/lib/shared/metadataApiVersion.js.map +1 -0
- package/lib/shared/metadataDeploy.d.ts +5 -0
- package/lib/shared/metadataDeploy.js +90 -0
- package/lib/shared/metadataDeploy.js.map +1 -0
- package/lib/shared/metadataRetrieve.d.ts +2 -0
- package/lib/shared/metadataRetrieve.js +68 -0
- package/lib/shared/metadataRetrieve.js.map +1 -0
- package/lib/shared/plugin-name.d.ts +13 -0
- package/lib/shared/plugin-name.js +29 -0
- package/lib/shared/plugin-name.js.map +1 -0
- package/messages/compute.config.get.md +39 -0
- package/messages/compute.config.list.md +24 -0
- package/messages/compute.config.set.md +49 -0
- package/messages/compute.config.unset.md +39 -0
- package/messages/compute.deploy.md +84 -0
- package/messages/compute.display.md +46 -0
- package/messages/compute.errors.md +182 -0
- package/messages/compute.generate.md +74 -0
- package/messages/compute.get.build-log.md +36 -0
- package/messages/compute.get.runtime-log.md +46 -0
- package/messages/compute.list.md +23 -0
- package/messages/compute.scale.md +67 -0
- package/messages/compute.source.retrieve.md +59 -0
- package/messages/compute.tail.runtime-log.md +55 -0
- package/npm-shrinkwrap.json +16162 -0
- package/oclif.manifest.json +982 -0
- package/package.json +117 -0
- package/schemas/compute-config-get.json +25 -0
- package/schemas/compute-config-list.json +25 -0
- package/schemas/compute-config-set.json +28 -0
- package/schemas/compute-config-unset.json +28 -0
- package/schemas/compute-deploy.json +30 -0
- package/schemas/compute-display.json +138 -0
- package/schemas/compute-generate.json +40 -0
- package/schemas/compute-get-build__log.json +30 -0
- package/schemas/compute-get-runtime__log.json +24 -0
- package/schemas/compute-list.json +94 -0
- package/schemas/compute-scale.json +41 -0
- package/schemas/compute-source-retrieve.json +26 -0
- package/schemas/compute-tail-runtime__log.json +18 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { mkdir } from 'node:fs/promises';
|
|
19
|
+
import { pathExists, resolveAppDir, validateName } from '../../../shared/computeApp.js';
|
|
20
|
+
import { unpackComputeBundle } from '../../../shared/computeBundle.js';
|
|
21
|
+
import { downloadComputeSource } from '../../../shared/computeConnectApi.js';
|
|
22
|
+
import { retrieveComputeMetadata } from '../../../shared/metadataRetrieve.js';
|
|
23
|
+
import { PLUGIN_NAME } from '../../../shared/plugin-name.js';
|
|
24
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
25
|
+
const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.source.retrieve');
|
|
26
|
+
export default class Retrieve extends SfCommand {
|
|
27
|
+
static description = messages.getMessage('description');
|
|
28
|
+
static examples = messages.getMessages('examples');
|
|
29
|
+
static flags = {
|
|
30
|
+
name: Flags.string({
|
|
31
|
+
char: 'n',
|
|
32
|
+
required: true,
|
|
33
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
34
|
+
}),
|
|
35
|
+
'target-org': Flags.requiredOrg({ char: 'o' }),
|
|
36
|
+
'output-dir': Flags.directory({
|
|
37
|
+
char: 'd',
|
|
38
|
+
summary: messages.getMessage('flags.output-dir.summary'),
|
|
39
|
+
description: messages.getMessage('flags.output-dir.description'),
|
|
40
|
+
default: 'force-app/main/default/platformComputeApps',
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
static requiresProject = true;
|
|
44
|
+
static summary = messages.getMessage('summary');
|
|
45
|
+
async run() {
|
|
46
|
+
const { flags } = await this.parse(Retrieve);
|
|
47
|
+
const { name } = flags;
|
|
48
|
+
validateName(name);
|
|
49
|
+
const appDir = resolveAppDir(flags['output-dir'], name);
|
|
50
|
+
if (await pathExists(appDir)) {
|
|
51
|
+
throw messages.createError('error.appAlreadyExists', [name, appDir]);
|
|
52
|
+
}
|
|
53
|
+
const connection = flags['target-org'].getConnection();
|
|
54
|
+
const username = connection.getUsername() ?? flags['target-org'].getUsername() ?? '<org>';
|
|
55
|
+
this.log(messages.getMessage('info.retrieving', [name, username]));
|
|
56
|
+
// No rollback on failure below -- if either API call fails, appDir is left in place,
|
|
57
|
+
// partially populated, same as generate.ts/deploy.ts's own "no automatic rollback" style
|
|
58
|
+
// elsewhere in this plugin. A retry after a failure here will need the directory removed
|
|
59
|
+
// first, since it now exists and would otherwise hit error.appAlreadyExists.
|
|
60
|
+
await mkdir(appDir, { recursive: true });
|
|
61
|
+
await retrieveComputeMetadata(connection, appDir, name);
|
|
62
|
+
this.log(messages.getMessage('info.retrievedMetadata', [`${name}.compute-meta.xml`]));
|
|
63
|
+
this.log(messages.getMessage('info.downloadingSource'));
|
|
64
|
+
const bundle = await downloadComputeSource(connection, { appIdOrName: name });
|
|
65
|
+
const { fileCount } = await unpackComputeBundle(bundle, appDir);
|
|
66
|
+
this.log(messages.getMessage('info.extractedSource', [fileCount]));
|
|
67
|
+
this.logSuccess(messages.getMessage('info.done', [name, appDir]));
|
|
68
|
+
return { name, path: appDir, files: fileCount };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=retrieve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieve.js","sourceRoot":"","sources":["../../../../src/commands/compute/source/retrieve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,6BAA6B,CAAC;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C,CAAC,CAAC;QACxD,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,UAAU,EAAE,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5E,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAElE,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC;IAChD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type ComputeTailRuntimeLogResult = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export default class TailRuntimeLog extends SfCommand<ComputeTailRuntimeLogResult> {
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly enableJsonFlag = false;
|
|
8
|
+
static readonly examples: string[];
|
|
9
|
+
static readonly flags: {
|
|
10
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
num: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
static readonly requiresProject = false;
|
|
15
|
+
static readonly summary: string;
|
|
16
|
+
run(): Promise<ComputeTailRuntimeLogResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { requireAppName, resolveComputeAppNameFromDir, validateName } from '../../../shared/computeApp.js';
|
|
19
|
+
import { streamLogplexOutput } from '../../../shared/computeLogStream.js';
|
|
20
|
+
import { queryComputeApp, requireHerokuAppId, toComputeAppSummary } from '../../../shared/computeQuery.js';
|
|
21
|
+
import { createComputeLogSessionViaProxy } from '../../../shared/herokuProxyApi.js';
|
|
22
|
+
import { PLUGIN_NAME } from '../../../shared/plugin-name.js';
|
|
23
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
24
|
+
const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.tail.runtime-log');
|
|
25
|
+
export default class TailRuntimeLog extends SfCommand {
|
|
26
|
+
static description = messages.getMessage('description');
|
|
27
|
+
// A live stream has no single point at which to emit one JSON result, so this command
|
|
28
|
+
// exposes no --json output. The verb-noun shape mirrors first-party `sf apex tail log`.
|
|
29
|
+
static enableJsonFlag = false;
|
|
30
|
+
static examples = messages.getMessages('examples');
|
|
31
|
+
static flags = {
|
|
32
|
+
name: Flags.string({
|
|
33
|
+
char: 'n',
|
|
34
|
+
env: 'COMPUTE_APP_NAME',
|
|
35
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
36
|
+
}),
|
|
37
|
+
'target-org': Flags.requiredOrg({ char: 'o' }),
|
|
38
|
+
num: Flags.integer({
|
|
39
|
+
default: 100,
|
|
40
|
+
summary: messages.getMessage('flags.num.summary'),
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
// Org-mediated lookup by --name -- no local project files are read.
|
|
44
|
+
static requiresProject = false;
|
|
45
|
+
static summary = messages.getMessage('summary');
|
|
46
|
+
async run() {
|
|
47
|
+
const { flags } = await this.parse(TailRuntimeLog);
|
|
48
|
+
const { num } = flags;
|
|
49
|
+
const name = requireAppName(flags.name ?? (await resolveComputeAppNameFromDir(process.cwd())));
|
|
50
|
+
validateName(name);
|
|
51
|
+
const connection = flags['target-org'].getConnection();
|
|
52
|
+
const record = await queryComputeApp(connection, name);
|
|
53
|
+
const { currentBuild } = toComputeAppSummary(record);
|
|
54
|
+
if (!currentBuild) {
|
|
55
|
+
this.info(messages.getMessage('info.noBuildsFound', [name]));
|
|
56
|
+
return { name };
|
|
57
|
+
}
|
|
58
|
+
const appId = requireHerokuAppId(record, name);
|
|
59
|
+
const session = await createComputeLogSessionViaProxy(connection, {
|
|
60
|
+
name, appId, lines: num, tail: true,
|
|
61
|
+
});
|
|
62
|
+
this.info(messages.getMessage('info.tailStarting', [name]));
|
|
63
|
+
const controller = new AbortController();
|
|
64
|
+
const onSigint = () => {
|
|
65
|
+
controller.abort();
|
|
66
|
+
};
|
|
67
|
+
process.once('SIGINT', onSigint);
|
|
68
|
+
try {
|
|
69
|
+
const reason = await streamLogplexOutput(session.logplexUrl, line => {
|
|
70
|
+
this.log(line);
|
|
71
|
+
}, controller.signal);
|
|
72
|
+
this.info(reason === 'aborted'
|
|
73
|
+
? messages.getMessage('info.tailStopped', [name])
|
|
74
|
+
: messages.getMessage('info.tailStreamEnded', [name]));
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
process.off('SIGINT', onSigint);
|
|
78
|
+
}
|
|
79
|
+
return { name };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=runtime-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-log.js","sourceRoot":"","sources":["../../../../src/commands/compute/tail/runtime-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAC,cAAc,EAAE,4BAA4B,EAAE,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAC,mBAAmB,EAAC,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAC,+BAA+B,EAAC,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAE3D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;AAMhF,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAsC;IACzE,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAExE,sFAAsF;IACtF,wFAAwF;IACjF,MAAM,CAAU,cAAc,GAAG,KAAK,CAAC;IAEvC,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAU,KAAK,GAAG;QAC7B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACjB,IAAI,EAAE,GAAG;YACT,GAAG,EAAE,kBAAkB;YACvB,OAAO,EAAE,QAAQ,CAA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BAA+B,CAAC,UAAU,EAAE;YAChE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;SACpC,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,GAAS,EAAE;YAC1B,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE;gBAClE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACtB,IAAI,CAAC,IAAI,CACP,MAAM,KAAK,SAAS;gBAClB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC;gBACjD,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,IAAI,CAAC,CAAC,CACxD,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,EAAC,IAAI,EAAC,CAAC;IAChB,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
// oclif discovers commands via the `oclif.commands` directory in package.json,
|
|
17
|
+
// not this barrel, so the plugin entry point is intentionally empty.
|
|
18
|
+
const plugin = {};
|
|
19
|
+
export default plugin;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+EAA+E;AAC/E,qEAAqE;AACrE,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ParsedComputeAppName = {
|
|
2
|
+
developerName: string;
|
|
3
|
+
namespace?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function parseName(name: string): ParsedComputeAppName;
|
|
6
|
+
export declare function validateName(name: string): void;
|
|
7
|
+
export declare function resolveAppDir(outputDir: string, name: string): string;
|
|
8
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
9
|
+
export declare function resolveComputeAppNameFromDir(dir: string): Promise<string | undefined>;
|
|
10
|
+
export declare function requireAppName(name: string | undefined): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { access } from 'node:fs/promises';
|
|
18
|
+
import { basename, join } from 'node:path';
|
|
19
|
+
import { PLUGIN_NAME } from './plugin-name.js';
|
|
20
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
|
+
const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.errors');
|
|
22
|
+
// Mirrors Salesforce's DeveloperName grammar (starts with a letter, alphanumeric/underscore only,
|
|
23
|
+
// no trailing or double underscore) -- every --name is now resolved as a DeveloperName via SOQL,
|
|
24
|
+
// so this also guards against path traversal, since `name` is joined directly into a filesystem path.
|
|
25
|
+
const NAME_PATTERN = /^(?!.*__)(?!.*_$)[A-Za-z]\w*$/v;
|
|
26
|
+
// Mirrors Salesforce's namespace grammar (starts with a letter, alphanumeric/underscore only,
|
|
27
|
+
// 1-15 characters total, no double underscore).
|
|
28
|
+
const NAMESPACE_PATTERN = /^[A-Za-z](?!.*__)[A-Za-z0-9_]{0,14}$/v;
|
|
29
|
+
// Splits a --name value on its first "__" into { namespace, developerName } when it's a
|
|
30
|
+
// namespace-qualified metadata name (<namespace>__<developerName>), validating each part against
|
|
31
|
+
// its own Salesforce grammar; otherwise validates the whole string as a bare DeveloperName. A
|
|
32
|
+
// DeveloperName can never itself contain "__" (see NAME_PATTERN's lookahead), so any "__" in --name
|
|
33
|
+
// means everything before the first one is a namespace -- DeveloperName and Namespace are separate
|
|
34
|
+
// compound-key fields (see PLATFORMCOMPUTEAPP_ENTITY_SCHEMA.md), not one combined identifier.
|
|
35
|
+
export function parseName(name) {
|
|
36
|
+
const separatorIndex = name.indexOf('__');
|
|
37
|
+
if (separatorIndex === -1) {
|
|
38
|
+
if (!NAME_PATTERN.test(name)) {
|
|
39
|
+
throw messages.createError('error.invalidName', [name]);
|
|
40
|
+
}
|
|
41
|
+
return { developerName: name };
|
|
42
|
+
}
|
|
43
|
+
const namespace = name.slice(0, separatorIndex);
|
|
44
|
+
const developerName = name.slice(separatorIndex + 2);
|
|
45
|
+
if (!NAMESPACE_PATTERN.test(namespace) || !NAME_PATTERN.test(developerName)) {
|
|
46
|
+
throw messages.createError('error.invalidName', [name]);
|
|
47
|
+
}
|
|
48
|
+
return { namespace, developerName };
|
|
49
|
+
}
|
|
50
|
+
// Shared by every command that takes --name, so the path-traversal/SOQL-injection guard has one
|
|
51
|
+
// source of truth. Delegates to parseName so a <namespace>__<developerName> value is accepted too.
|
|
52
|
+
export function validateName(name) {
|
|
53
|
+
parseName(name);
|
|
54
|
+
}
|
|
55
|
+
export function resolveAppDir(outputDir, name) {
|
|
56
|
+
return join(outputDir, name);
|
|
57
|
+
}
|
|
58
|
+
export async function pathExists(path) {
|
|
59
|
+
try {
|
|
60
|
+
await access(path);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// The same "does this look like a compute app's own directory" check deploy.ts uses to derive
|
|
68
|
+
// its app name from cwd, reused here as the last resort in the --name/COMPUTE_APP_NAME/directory
|
|
69
|
+
// fallback chain shared by every other command that takes --name.
|
|
70
|
+
export async function resolveComputeAppNameFromDir(dir) {
|
|
71
|
+
const name = basename(dir);
|
|
72
|
+
return (await pathExists(join(dir, `${name}.compute-meta.xml`))) ? name : undefined;
|
|
73
|
+
}
|
|
74
|
+
// Shared by every command in the --name/COMPUTE_APP_NAME/directory fallback chain, so the
|
|
75
|
+
// "couldn't figure out which app" error is thrown identically everywhere instead of duplicated.
|
|
76
|
+
export function requireAppName(name) {
|
|
77
|
+
if (!name) {
|
|
78
|
+
throw messages.createError('error.cannotResolveAppName');
|
|
79
|
+
}
|
|
80
|
+
return name;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=computeApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeApp.js","sourceRoot":"","sources":["../../src/shared/computeApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAEtE,kGAAkG;AAClG,iGAAiG;AACjG,sGAAsG;AACtG,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAEtD,8FAA8F;AAC9F,gDAAgD;AAChD,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAOlE,wFAAwF;AACxF,iGAAiG;AACjG,8FAA8F;AAC9F,oGAAoG;AACpG,mGAAmG;AACnG,8FAA8F;AAC9F,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,QAAQ,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC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CAAC;AAED,0FAA0F;AAC1F,gGAAgG;AAChG,MAAM,UAAU,cAAc,CAAC,IAAwB;IACrD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,QAAQ,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PackagedBundle = {
|
|
2
|
+
buffer: Buffer;
|
|
3
|
+
fileCount: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function packageComputeBundle(appDir: string, name: string, projectRoot: string): Promise<PackagedBundle>;
|
|
6
|
+
export type UnpackedBundle = {
|
|
7
|
+
fileCount: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function unpackComputeBundle(buffer: Buffer, appDir: string): Promise<UnpackedBundle>;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { getLogger } from '@oclif/core';
|
|
17
|
+
import { Messages } from '@salesforce/core';
|
|
18
|
+
import ignore from 'ignore';
|
|
19
|
+
import { mkdir, readdir, readFile, writeFile, } from 'node:fs/promises';
|
|
20
|
+
import { dirname, join, relative, resolve, sep, } from 'node:path';
|
|
21
|
+
import { buffer as streamToBuffer } from 'node:stream/consumers';
|
|
22
|
+
import { createGzip, gunzipSync } from 'node:zlib';
|
|
23
|
+
import tarStream from 'tar-stream';
|
|
24
|
+
import { pathExists } from './computeApp.js';
|
|
25
|
+
import { PLUGIN_NAME } from './plugin-name.js';
|
|
26
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
27
|
+
const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.errors');
|
|
28
|
+
// Gated by DEBUG=sf:compute:bundle (or DEBUG=*) -- see @oclif/core's Command#debug, which this
|
|
29
|
+
// mirrors for code that isn't a command instance.
|
|
30
|
+
const { debug } = getLogger('sf:compute:bundle');
|
|
31
|
+
// Bundle shape per the PlatformComputeAppBuild.SourceBlob design (deployment-bundle.tar.gz
|
|
32
|
+
// containing api-spec.yaml plus a nested source.tar.gz) -- see
|
|
33
|
+
// deployment/specs/PLATFORMCOMPUTEAPP_ENTITY_SCHEMA.md "Nested Tarball Structure".
|
|
34
|
+
export async function packageComputeBundle(appDir, name, projectRoot) {
|
|
35
|
+
const metaFileName = `${name}.compute-meta.xml`;
|
|
36
|
+
// api-spec.yaml and project.toml also go into the outer bundle/get read by the Fir builder
|
|
37
|
+
// respectively, but both are included here too: api-spec.yaml so the AppLink Service Mesh
|
|
38
|
+
// Proxy has it at runtime, project.toml so CNB picks up its declared buildpacks (notably
|
|
39
|
+
// heroku/heroku-applink-service-mesh, which nothing else installs).
|
|
40
|
+
const excluded = new Set(['.forceignore', metaFileName]);
|
|
41
|
+
// Build-critical, so a broad user .forceignore pattern (*.yaml, project.toml, ...) must not be
|
|
42
|
+
// able to silently strip them and recreate the failure described above.
|
|
43
|
+
const neverForceIgnored = new Set(['api-spec.yaml', 'project.toml']);
|
|
44
|
+
const isForceIgnored = await loadForceIgnore(appDir, projectRoot);
|
|
45
|
+
const allFiles = await listFilesRecursive(appDir);
|
|
46
|
+
const sourceRelativePaths = allFiles.filter(f => !excluded.has(f) && (neverForceIgnored.has(f) || !isForceIgnored(f)));
|
|
47
|
+
debug('packaging %s: %d of %d files after exclusions/.forceignore', appDir, sourceRelativePaths.length, allFiles.length);
|
|
48
|
+
const sourceEntries = await Promise.all(sourceRelativePaths.map(async (relativePath) => ({
|
|
49
|
+
name: relativePath,
|
|
50
|
+
data: await readFile(join(appDir, relativePath)),
|
|
51
|
+
})));
|
|
52
|
+
const sourceTarGz = await tarGzip(sourceEntries);
|
|
53
|
+
const apiSpec = await readFile(join(appDir, 'api-spec.yaml'));
|
|
54
|
+
const buffer = await tarGzip([
|
|
55
|
+
{ name: 'api-spec.yaml', data: apiSpec },
|
|
56
|
+
{ name: 'source.tar.gz', data: sourceTarGz },
|
|
57
|
+
]);
|
|
58
|
+
// api-spec.yaml appears in both the outer bundle and source.tar.gz but is one file on disk, so
|
|
59
|
+
// the source entries (which always include it) are the distinct-file count.
|
|
60
|
+
debug('packaged %s into %d bytes (%d files)', appDir, buffer.length, sourceEntries.length);
|
|
61
|
+
return { buffer, fileCount: sourceEntries.length };
|
|
62
|
+
}
|
|
63
|
+
// Inverse of packageComputeBundle above -- given the same outer tar.gz shape (api-spec.yaml plus
|
|
64
|
+
// a nested source.tar.gz), writes api-spec.yaml and every source file into appDir. Used by
|
|
65
|
+
// sf compute source retrieve, the only caller that needs to go this direction.
|
|
66
|
+
export async function unpackComputeBundle(buffer, appDir) {
|
|
67
|
+
const outer = await untarGzip(buffer);
|
|
68
|
+
const apiSpec = outer['api-spec.yaml'];
|
|
69
|
+
const sourceTarGz = outer['source.tar.gz'];
|
|
70
|
+
if (!apiSpec || !sourceTarGz) {
|
|
71
|
+
throw messages.createError('error.sourceBundleMalformed', [
|
|
72
|
+
`missing ${[!apiSpec && 'api-spec.yaml', !sourceTarGz && 'source.tar.gz'].filter(Boolean).join(', ')}`,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
await writeFile(join(appDir, 'api-spec.yaml'), apiSpec);
|
|
76
|
+
const sourceEntries = await untarGzip(sourceTarGz);
|
|
77
|
+
const resolvedAppDir = resolve(appDir);
|
|
78
|
+
await Promise.all(Object.entries(sourceEntries).map(async ([relativePath, data]) => {
|
|
79
|
+
const filePath = resolve(appDir, relativePath);
|
|
80
|
+
// Guards against a tar-slip: a malicious (or corrupted) entry name like "../../etc/foo"
|
|
81
|
+
// must not be allowed to write outside appDir. The bundle comes from the org's most
|
|
82
|
+
// recently deployed source, which this plugin doesn't otherwise validate the shape of.
|
|
83
|
+
if (filePath !== resolvedAppDir && !filePath.startsWith(resolvedAppDir + sep)) {
|
|
84
|
+
throw messages.createError('error.sourceBundleMalformed', [`unsafe entry path "${relativePath}"`]);
|
|
85
|
+
}
|
|
86
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
87
|
+
await writeFile(filePath, data);
|
|
88
|
+
}));
|
|
89
|
+
// Mirrors packageComputeBundle's convention: distinct files written. Bundles produced by this
|
|
90
|
+
// plugin carry api-spec.yaml in source.tar.gz too; older ones only had the outer copy.
|
|
91
|
+
return { fileCount: new Set([...Object.keys(sourceEntries), 'api-spec.yaml']).size };
|
|
92
|
+
}
|
|
93
|
+
// Inverse of tarGzip below -- decompress and read every tar entry into memory, keyed by name.
|
|
94
|
+
// Wraps decompression/parse failures as error.sourceBundleMalformed rather than letting a raw
|
|
95
|
+
// zlib/tar-stream error (e.g. "incorrect header check") reach the user -- a truncated download
|
|
96
|
+
// or an HTTP error page returned with a 200 status both land here.
|
|
97
|
+
async function untarGzip(buffer) {
|
|
98
|
+
return new Promise((resolveEntries, reject) => {
|
|
99
|
+
let decompressed;
|
|
100
|
+
try {
|
|
101
|
+
decompressed = gunzipSync(buffer);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
reject(messages.createError('error.sourceBundleMalformed', ['not a valid gzip archive']));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const entries = {};
|
|
108
|
+
const extract = tarStream.extract();
|
|
109
|
+
extract.on('entry', (header, stream, next) => {
|
|
110
|
+
const chunks = [];
|
|
111
|
+
stream.on('data', (chunk) => {
|
|
112
|
+
chunks.push(chunk);
|
|
113
|
+
});
|
|
114
|
+
stream.on('end', () => {
|
|
115
|
+
entries[header.name] = Buffer.concat(chunks);
|
|
116
|
+
next();
|
|
117
|
+
});
|
|
118
|
+
stream.on('error', reject);
|
|
119
|
+
stream.resume();
|
|
120
|
+
});
|
|
121
|
+
extract.on('finish', () => {
|
|
122
|
+
resolveEntries(entries);
|
|
123
|
+
});
|
|
124
|
+
extract.on('error', () => {
|
|
125
|
+
reject(messages.createError('error.sourceBundleMalformed', ['not a valid tar archive']));
|
|
126
|
+
});
|
|
127
|
+
extract.end(decompressed);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function tarGzip(entries) {
|
|
131
|
+
const pack = tarStream.pack();
|
|
132
|
+
// Pipe (i.e. attach a consumer) BEFORE writing any entries. pack is a streamx Readable with a
|
|
133
|
+
// 16KB highWaterMark; each pack.entry() write below only resolves its callback once
|
|
134
|
+
// backpressure clears. With no consumer attached, once buffered-but-unread bytes cross 16KB,
|
|
135
|
+
// push() returns false and the callback is deferred to the next _read() -- which never comes,
|
|
136
|
+
// since nothing is piping yet. That deadlocked every real app whose combined source exceeded
|
|
137
|
+
// ~16KB (small unit-test fixtures never hit the threshold, which is why this went unnoticed).
|
|
138
|
+
const gzippedBufferPromise = streamToBuffer(pack.pipe(createGzip()));
|
|
139
|
+
debug('tarGzip: %d entries, %d total bytes', entries.length, entries.reduce((sum, e) => sum + e.data.length, 0));
|
|
140
|
+
// Entries share one pack stream and must be written one at a time, in order, so build a
|
|
141
|
+
// single sequential promise chain (each entry waits on the previous) and await it once --
|
|
142
|
+
// avoids both an await-in-loop and a reduce used purely for its sequencing side effect.
|
|
143
|
+
let previous = Promise.resolve();
|
|
144
|
+
for (const { name, data } of entries) {
|
|
145
|
+
previous = previous.then(async () => new Promise((resolveEntry, reject) => {
|
|
146
|
+
pack.entry({ name, size: data.length }, data, err => {
|
|
147
|
+
if (err) {
|
|
148
|
+
reject(err);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resolveEntry();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
await previous;
|
|
157
|
+
pack.finalize();
|
|
158
|
+
return gzippedBufferPromise;
|
|
159
|
+
}
|
|
160
|
+
// A leading "/" in a .forceignore pattern anchors it to the directory that file lives in, so
|
|
161
|
+
// the project root's file and the app dir's file can't share one Ignore instance tested against
|
|
162
|
+
// app-relative paths -- a root-anchored "/src/**" would wrongly match the app's own src/ dir.
|
|
163
|
+
// Keep each file's Ignore in its own coordinate space: the app-dir filter tests app-relative
|
|
164
|
+
// paths directly, the project-root filter tests paths relative to the project root.
|
|
165
|
+
async function loadForceIgnore(appDir, projectRoot) {
|
|
166
|
+
const [appFilter, rootFilter] = await Promise.all([readForceIgnoreFile(appDir), readForceIgnoreFile(projectRoot)]);
|
|
167
|
+
const appDirFromRoot = relative(projectRoot, appDir).split(sep).join('/');
|
|
168
|
+
return (appRelativePath) => {
|
|
169
|
+
if (appFilter?.ignores(appRelativePath)) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (rootFilter) {
|
|
173
|
+
const rootRelativePath = appDirFromRoot ? `${appDirFromRoot}/${appRelativePath}` : appRelativePath;
|
|
174
|
+
if (rootFilter.ignores(rootRelativePath)) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async function readForceIgnoreFile(dir) {
|
|
182
|
+
const forceIgnorePath = join(dir, '.forceignore');
|
|
183
|
+
if (!(await pathExists(forceIgnorePath))) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
return ignore().add(await readFile(forceIgnorePath, 'utf8'));
|
|
187
|
+
}
|
|
188
|
+
async function listFilesRecursive(dir, base = dir) {
|
|
189
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
190
|
+
const nested = await Promise.all(entries.map(async (entry) => {
|
|
191
|
+
const full = join(dir, entry.name);
|
|
192
|
+
if (entry.isDirectory()) {
|
|
193
|
+
return listFilesRecursive(full, base);
|
|
194
|
+
}
|
|
195
|
+
if (entry.isFile()) {
|
|
196
|
+
return [relative(base, full).split(sep).join('/')];
|
|
197
|
+
}
|
|
198
|
+
return [];
|
|
199
|
+
}));
|
|
200
|
+
return nested.flat();
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=computeBundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeBundle.js","sourceRoot":"","sources":["../../src/shared/computeBundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,MAAqB,MAAM,QAAQ,CAAC;AAC3C,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAEtE,+FAA+F;AAC/F,kDAAkD;AAClD,MAAM,EAAC,KAAK,EAAC,GAAG,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AE;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CACH,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { PLUGIN_NAME } from './plugin-name.js';
|
|
18
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
19
|
+
const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.errors');
|
|
20
|
+
// Shared by `config get` and `config unset` -- both validate requested keys against the same
|
|
21
|
+
// fetched map and must raise byte-identical text for a missing key, so this is the one source of
|
|
22
|
+
// truth for that check rather than duplicating the message in each command's own .md file.
|
|
23
|
+
export function requireConfigVar(configVars, name, key) {
|
|
24
|
+
if (!Object.hasOwn(configVars, key)) {
|
|
25
|
+
throw messages.createError('error.configVarNotFound', [name, key]);
|
|
26
|
+
}
|
|
27
|
+
return configVars[key];
|
|
28
|
+
}
|
|
29
|
+
// Right-pads each key to the widest key's width (plus Heroku's own two-space minimum gap) so
|
|
30
|
+
// values line up in a column -- shared by `config` (list) and multi-key `config get` so the two
|
|
31
|
+
// commands agree visually when run back-to-back.
|
|
32
|
+
export function formatConfigVarLines(configVars) {
|
|
33
|
+
const keys = Object.keys(configVars);
|
|
34
|
+
const width = Math.max(0, ...keys.map(key => key.length));
|
|
35
|
+
return keys.map(key => `${key}:${' '.repeat(width - key.length + 2)}${configVars[key]}`);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=computeConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeConfig.js","sourceRoot":"","sources":["../../src/shared/computeConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAEtE,6FAA6F;AAC7F,iGAAiG;AACjG,2FAA2F;AAC3F,MAAM,UAAU,gBAAgB,CAAC,UAAkC,EAAE,IAAY,EAAE,GAAW;IAC5F,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,QAAQ,CAAC,WAAW,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,6FAA6F;AAC7F,gGAAgG;AAChG,iDAAiD;AACjD,MAAM,UAAU,oBAAoB,CAAC,UAAkC;IACrE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Connection } from '@salesforce/core';
|
|
2
|
+
import type { components } from '../generated/salesforce-connect-compute.js';
|
|
3
|
+
export type ComputeSourceUpload = components['schemas']['ComputeSourceUpload'];
|
|
4
|
+
export type ConnectError = components['schemas']['ConnectError'];
|
|
5
|
+
export type UploadComputeSourceParams = {
|
|
6
|
+
/** Deployment bundle tarball contents (OpenAPI spec plus application source). */
|
|
7
|
+
bundle: Buffer;
|
|
8
|
+
/** DeveloperName of the PlatformComputeApp to deploy source for. */
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function uploadComputeSource(connection: Connection, params: UploadComputeSourceParams): Promise<ComputeSourceUpload>;
|
|
12
|
+
export type DownloadComputeSourceParams = {
|
|
13
|
+
/** PlatformComputeApp Id or DeveloperName to download source for. */
|
|
14
|
+
appIdOrName: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function downloadComputeSource(connection: Connection, params: DownloadComputeSourceParams): Promise<Buffer>;
|