@heroku/plugin-compute 0.4.2 → 0.4.4

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.
@@ -15,8 +15,10 @@
15
15
  */
16
16
  import { Messages } from '@salesforce/core';
17
17
  import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
18
+ import { mkdir, rm, writeFile } from 'node:fs/promises';
19
+ import { dirname, join } from 'node:path';
18
20
  import { pathExists, resolveAppDir, validateName } from '../../../shared/computeApp.js';
19
- import { unpackComputeBundle } from '../../../shared/computeBundle.js';
21
+ import { decodeComputeBundle, writeBundleFiles } from '../../../shared/computeBundle.js';
20
22
  import { downloadComputeSource } from '../../../shared/computeConnectApi.js';
21
23
  import { retrieveComputeMetadata } from '../../../shared/metadataRetrieve.js';
22
24
  import { PLUGIN_NAME } from '../../../shared/plugin-name.js';
@@ -53,18 +55,43 @@ export default class Retrieve extends SfCommand {
53
55
  const connection = flags['target-org'].getConnection(flags['api-version']);
54
56
  const username = connection.getUsername() ?? flags['target-org'].getUsername() ?? '<org>';
55
57
  this.log(messages.getMessage('info.retrieving', [name, username]));
56
- // No rollback on failure below -- if the source download 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 retrieveComputeMetadata(connection, appDir, name);
61
- this.log(messages.getMessage('info.retrievedMetadata', [`${name}.computeApp-meta.xml`]));
58
+ // Finish every network call before touching disk (as generate.ts does), so a failed retrieve
59
+ // or download leaves nothing behind for a retry to trip over.
60
+ const metadata = await retrieveComputeMetadata(connection, name);
61
+ this.log(messages.getMessage('info.retrievedMetadata', [metadata.fileName]));
62
62
  this.log(messages.getMessage('info.downloadingSource'));
63
63
  const bundle = await downloadComputeSource(connection, { appIdOrName: name });
64
- const { fileCount } = await unpackComputeBundle(bundle, appDir);
65
- this.log(messages.getMessage('info.extractedSource', [fileCount]));
64
+ // Check the archive and every entry path now, so a bad bundle fails before anything touches
65
+ // disk and the cleanup below only has to cover real I/O failures (ENOSPC, EACCES, ...).
66
+ const files = await decodeComputeBundle(bundle, appDir);
67
+ // The existence check above ran before two slow network calls, so claim appDir itself with a
68
+ // non-recursive mkdir: it throws EEXIST if the folder appeared in the meantime. That makes
69
+ // the cleanup below safe -- it only ever removes a folder this run created.
70
+ await mkdir(dirname(appDir), { recursive: true });
71
+ try {
72
+ await mkdir(appDir);
73
+ }
74
+ catch (error) {
75
+ if (error.code === 'EEXIST') {
76
+ throw messages.createError('error.appAlreadyExists', [name, appDir]);
77
+ }
78
+ throw error;
79
+ }
80
+ try {
81
+ await writeFile(join(appDir, metadata.fileName), metadata.contents);
82
+ await writeBundleFiles(files);
83
+ }
84
+ catch (error) {
85
+ // Remove the half-written folder so a retry isn't blocked by error.appAlreadyExists. A
86
+ // failed cleanup must not replace the error that caused it, so warn and rethrow the original.
87
+ await rm(appDir, { force: true, recursive: true }).catch((rmError) => {
88
+ this.warn(messages.getMessage('warning.cleanupFailed', [appDir, String(rmError)]));
89
+ });
90
+ throw error;
91
+ }
92
+ this.log(messages.getMessage('info.extractedSource', [files.length]));
66
93
  this.logSuccess(messages.getMessage('info.done', [name, appDir]));
67
- return { name, path: appDir, files: fileCount };
94
+ return { name, path: appDir, files: files.length };
68
95
  }
69
96
  }
70
97
  //# sourceMappingURL=retrieve.js.map
@@ -1 +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;AAE7D,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAC,mBAAmB,EAAC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C,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACvE,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpE,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uFAAuF;YACvF,8FAA8F;YAC9F,MAAM,EAAE,CAAC,MAAM,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAgB,EAAE,EAAE;gBAC1E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACrF,CAAC,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAEtE,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,KAAK,CAAC,MAAM,EAAC,CAAC;IACnD,CAAC"}
@@ -6,4 +6,10 @@ export declare function packageComputeBundle(appDir: string, name: string, proje
6
6
  export type UnpackedBundle = {
7
7
  fileCount: number;
8
8
  };
9
+ export type BundleFile = {
10
+ data: Buffer;
11
+ filePath: string;
12
+ };
13
+ export declare function decodeComputeBundle(buffer: Buffer, appDir: string): Promise<BundleFile[]>;
14
+ export declare function writeBundleFiles(files: readonly BundleFile[]): Promise<void>;
9
15
  export declare function unpackComputeBundle(buffer: Buffer, appDir: string): Promise<UnpackedBundle>;
@@ -60,40 +60,68 @@ export async function packageComputeBundle(appDir, name, projectRoot) {
60
60
  debug('packaged %s into %d bytes (%d files)', appDir, buffer.length, sourceEntries.length);
61
61
  return { buffer, fileCount: sourceEntries.length };
62
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) {
63
+ // Reads and checks the downloaded source.tar.gz without touching disk, so every archive or path
64
+ // problem (bad gzip/tar, empty or nested bundle, unsafe or duplicate entry paths) surfaces before
65
+ // the caller creates anything. The download endpoint returns that inner tarball directly
66
+ // (api-spec.yaml included), unlike the nested bundle packageComputeBundle uploads -- the
67
+ // asymmetry is deliberate: the appserver inspects the upload's top-level files without untarring
68
+ // the source. Used by sf compute source retrieve, the only caller that needs to go this direction.
69
+ export async function decodeComputeBundle(buffer, appDir) {
70
+ const sourceEntries = await untarGzip(buffer);
71
+ // Release ordering alone doesn't protect against an org still returning the old nested bundle
72
+ // (api-spec.yaml + source.tar.gz), which would otherwise "succeed" with an unextracted blob.
73
+ if (Object.keys(sourceEntries).length === 0) {
74
+ throw messages.createError('error.sourceBundleMalformed', ['archive contains no files']);
75
+ }
76
+ if ('source.tar.gz' in sourceEntries) {
71
77
  throw messages.createError('error.sourceBundleMalformed', [
72
- `missing ${[!apiSpec && 'api-spec.yaml', !sourceTarGz && 'source.tar.gz'].filter(Boolean).join(', ')}`,
78
+ 'unexpected nested source.tar.gz (the org returned the older nested bundle shape)',
73
79
  ]);
74
80
  }
75
- await writeFile(join(appDir, 'api-spec.yaml'), apiSpec);
76
- const sourceEntries = await untarGzip(sourceTarGz);
77
81
  const resolvedAppDir = resolve(appDir);
78
- await Promise.all(Object.entries(sourceEntries).map(async ([relativePath, data]) => {
82
+ // Keyed by resolved path so entries that name the same file ("a" and "./a") collapse to one
83
+ // write (the later entry wins, as in tar) instead of racing each other.
84
+ const filesByPath = new Map();
85
+ for (const [relativePath, data] of Object.entries(sourceEntries)) {
79
86
  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)) {
87
+ // A tar-slip guard: a malicious (or corrupted) entry name like "../../etc/foo" must not be
88
+ // allowed to write outside appDir, and a file entry can't be appDir itself. The bundle comes
89
+ // from the org's most recently deployed source, which this plugin doesn't otherwise validate
90
+ // the shape of.
91
+ if (!filePath.startsWith(resolvedAppDir + sep)) {
84
92
  throw messages.createError('error.sourceBundleMalformed', [`unsafe entry path "${relativePath}"`]);
85
93
  }
94
+ filesByPath.set(filePath, data);
95
+ }
96
+ return [...filesByPath].map(([filePath, data]) => ({ data, filePath }));
97
+ }
98
+ // Writes decoded files to disk. Waits for every write to settle before failing, so a caller that
99
+ // cleans up after an error never races writes that are still in flight (which could recreate
100
+ // directories it just removed, or make its rm fail with ENOTEMPTY).
101
+ export async function writeBundleFiles(files) {
102
+ const results = await Promise.allSettled(files.map(async ({ data, filePath }) => {
86
103
  await mkdir(dirname(filePath), { recursive: true });
87
104
  await writeFile(filePath, data);
88
105
  }));
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 };
106
+ const failed = results.find((result) => result.status === 'rejected');
107
+ if (failed) {
108
+ throw failed.reason;
109
+ }
92
110
  }
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.
111
+ // Decode + write in one call. Kept as a convenience for tests; the retrieve command calls
112
+ // decodeComputeBundle and writeBundleFiles separately so it can create the app directory
113
+ // between the two.
114
+ export async function unpackComputeBundle(buffer, appDir) {
115
+ const files = await decodeComputeBundle(buffer, appDir);
116
+ await writeBundleFiles(files);
117
+ return { fileCount: files.length };
118
+ }
119
+ // Inverse of tarGzip below -- decompress and read every file entry into memory, keyed by name.
120
+ // Directory entries are skipped (writing a file mkdirs its parents), and anything that isn't a
121
+ // plain file or directory (symlinks, hardlinks, devices) is rejected rather than silently
122
+ // written as an empty file. Wraps decompression/parse failures as error.sourceBundleMalformed
123
+ // rather than letting a raw zlib/tar-stream error (e.g. "incorrect header check") reach the
124
+ // user -- a truncated download or an HTTP error page returned with a 200 status both land here.
97
125
  async function untarGzip(buffer) {
98
126
  return new Promise((resolveEntries, reject) => {
99
127
  let decompressed;
@@ -107,12 +135,23 @@ async function untarGzip(buffer) {
107
135
  const entries = {};
108
136
  const extract = tarStream.extract();
109
137
  extract.on('entry', (header, stream, next) => {
138
+ const isFile = header.type === 'file' || header.type === 'contiguous-file';
139
+ if (!isFile && header.type !== 'directory') {
140
+ // Stop reading the rest of the archive; the answer is already decided.
141
+ extract.destroy();
142
+ reject(messages.createError('error.sourceBundleMalformed', [
143
+ `unsupported entry type "${header.type}" for "${header.name}"`,
144
+ ]));
145
+ return;
146
+ }
110
147
  const chunks = [];
111
148
  stream.on('data', (chunk) => {
112
149
  chunks.push(chunk);
113
150
  });
114
151
  stream.on('end', () => {
115
- entries[header.name] = Buffer.concat(chunks);
152
+ if (isFile) {
153
+ entries[header.name] = Buffer.concat(chunks);
154
+ }
116
155
  next();
117
156
  });
118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ACxC,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"}
@@ -41,15 +41,16 @@ export async function uploadComputeSource(connection, params) {
41
41
  }
42
42
  }
43
43
  // Speculative resource -- see the Compute tag description in salesforce-connect-compute.yaml.
44
- // The response body is the same binary deployment-bundle.tar.gz uploadComputeSource sends, so
45
- // this must round-trip exact bytes. connection.request()'s default string decoding is UTF-8,
44
+ // The CLI always asks for the `latest` build (it has no build id); Heroku Builds pins a build id.
45
+ // The response body is the flat source.tar.gz (not the nested deployment-bundle.tar.gz
46
+ // uploadComputeSource sends), binary, so this must round-trip exact bytes. connection.request()'s default string decoding is UTF-8,
46
47
  // which is lossy for arbitrary gzip bytes (any byte >0x7F gets re-encoded) -- passing
47
48
  // { encoding: 'binary' } (Node's alias for latin1) as the second argument makes jsforce decode
48
49
  // the response 1:1 into a string, which Buffer.from(str, 'binary') then turns back into the
49
50
  // exact original bytes.
50
51
  export async function downloadComputeSource(connection, params) {
51
52
  try {
52
- const body = await connection.request({ method: 'GET', url: `/connect/compute/${encodeURIComponent(params.appIdOrName)}/source` }, { encoding: 'binary' });
53
+ const body = await connection.request({ method: 'GET', url: `/connect/compute/${encodeURIComponent(params.appIdOrName)}/builds/latest/source` }, { encoding: 'binary' });
53
54
  return Buffer.from(body, 'binary');
54
55
  }
55
56
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"computeConnectApi.js","sourceRoot":"","sources":["../../src/shared/computeConnectApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAkB,QAAQ,EAA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sB;YACnD,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,yBAAyB;YAC9B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC,WAAW,CAAC,+BAA+B,EAAE,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAOD,8FAA8F;AAC9F,kGAAkG;AAClG,uFAAuF;AACvF,oIAAoI;AACpI,sFAAsF;AACtF,+FAA+F;AAC/F,4FAA4F;AAC5F,wBAAwB;AACxB,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAsB,EACtB,MAAmC;IAEnC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CACnC,EAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,oBAAoB,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,uBAAuB,EAAC,EACvG,EAAC,QAAQ,EAAE,QAAQ,EAAC,CACrB,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IACvF,CAAC;AACH,CAAC"}
@@ -1,2 +1,6 @@
1
1
  import { type Connection } from '@salesforce/core';
2
- export declare function retrieveComputeMetadata(connection: Connection, appDir: string, name: string): Promise<void>;
2
+ export type RetrievedMetadata = {
3
+ contents: Buffer;
4
+ fileName: string;
5
+ };
6
+ export declare function retrieveComputeMetadata(connection: Connection, name: string): Promise<RetrievedMetadata>;
@@ -16,23 +16,13 @@
16
16
  import { getLogger } from '@oclif/core';
17
17
  import { Messages } from '@salesforce/core';
18
18
  import JSZip from 'jszip';
19
- import { mkdir, writeFile } from 'node:fs/promises';
20
- import { join } from 'node:path';
21
19
  import { resolveComputeApiVersion } from './metadataApiVersion.js';
22
20
  import { PLUGIN_NAME } from './plugin-name.js';
23
21
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
24
22
  const messages = Messages.loadMessages(PLUGIN_NAME, 'compute.errors');
25
23
  // Gated by DEBUG=sf:compute:metadataRetrieve (or DEBUG=*).
26
24
  const { debug } = getLogger('sf:compute:metadataRetrieve');
27
- // Inverse of deployComputeMetadata in metadataDeploy.ts, but NOT built on SDR's
28
- // ComponentSet/MetadataApiRetrieve the way that function is built on MetadataApiDeploy --
29
- // ComputeApp has no entry in SDR's metadata registry, and ComponentSet.getObject()
30
- // (called internally when building a retrieve request) requires resolving every member's type
31
- // against that registry, so it throws for this type today. This uses jsforce's lower-level
32
- // retrieve API directly instead. Note the asymmetry with deployComputeMetadata's
33
- // deployResult.complete(true): RetrieveResultLocator#complete() takes no argument (unlike
34
- // DeployResultLocator#complete(includeDetails?)), per @jsforce/jsforce-node's metadata.d.ts.
35
- export async function retrieveComputeMetadata(connection, appDir, name) {
25
+ export async function retrieveComputeMetadata(connection, name) {
36
26
  const version = resolveComputeApiVersion(connection);
37
27
  const retrieveResult = connection.metadata.retrieve({
38
28
  apiVersion: Number(version),
@@ -66,7 +56,6 @@ export async function retrieveComputeMetadata(connection, appDir, name) {
66
56
  `the retrieved metadata is missing computeApps/${wireFileName}${problemDetail}`,
67
57
  ]);
68
58
  }
69
- await mkdir(appDir, { recursive: true });
70
- await writeFile(join(appDir, metaFileName), await metaEntry.async('nodebuffer'));
59
+ return { contents: await metaEntry.async('nodebuffer'), fileName: metaFileName };
71
60
  }
72
61
  //# sourceMappingURL=metadataRetrieve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadataRetrieve.js","sourceRoot":"","sources":["../../src/shared/metadataRetrieve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EA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EAAC,QAAQ,EAAE,MAAM,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;AACjF,CAAC"}
@@ -57,3 +57,7 @@ extracted %s files
57
57
  # info.done
58
58
 
59
59
  Retrieved compute app %s into %s.
60
+
61
+ # warning.cleanupFailed
62
+
63
+ Retrieving the compute app failed, and the partially written directory %s could not be removed (%s). Delete it before running this command again, or it will stop with "already exists".
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@heroku/plugin-compute",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@heroku/plugin-compute",
9
- "version": "0.4.2",
9
+ "version": "0.4.4",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@oclif/core": "^4",
@@ -1070,12 +1070,19 @@
1070
1070
  "telemetry-drain:list:compute"
1071
1071
  ]
1072
1072
  },
1073
- "compute:source:retrieve": {
1073
+ "compute:set:config": {
1074
1074
  "aliases": [],
1075
- "args": {},
1076
- "description": "Creates the compute app's directory under force-app/main/default/computeApps/<name>/\n(or --output-dir), retrieves its <name>.computeApp-meta.xml through the Metadata\nAPI, then downloads its source code through the Connect API and extracts it\ninto that same directory. Deploy it with project deploy start.",
1075
+ "args": {
1076
+ "pair": {
1077
+ "multiple": true,
1078
+ "name": "pair"
1079
+ }
1080
+ },
1081
+ "deprecateAliases": true,
1082
+ "description": "Goes through the target org's Salesforce Connect API, which calls Heroku on\nyour behalf. Setting a config var restarts the app's dynos so the new value\ntakes effect. Pass one or more KEY=VALUE pairs; a key that doesn't already\nexist is created.",
1077
1083
  "examples": [
1078
- "Retrieve a compute app's source and metadata from an org:\n<%= config.bin %> <%= command.id %> --name CreditRatingScorer --target-org my-org"
1084
+ "Set a single config var:\n<%= config.bin %> <%= command.id %> STRIPE_KEY=sk_live_xyz789 --name CreditRatingScorer --target-org my-org",
1085
+ "Set more than one config var in one command:\n<%= config.bin %> <%= command.id %> STRIPE_KEY=sk_live_xyz789 LOG_LEVEL=debug --name CreditRatingScorer --target-org my-org"
1079
1086
  ],
1080
1087
  "flags": {
1081
1088
  "json": {
@@ -1095,9 +1102,9 @@
1095
1102
  },
1096
1103
  "name": {
1097
1104
  "char": "n",
1105
+ "env": "COMPUTE_APP_NAME",
1098
1106
  "name": "name",
1099
- "required": true,
1100
- "summary": "DeveloperName of the compute app to retrieve (or <namespace>\\_\\_<developerName>\nif it was deployed under a namespace).",
1107
+ "summary": "DeveloperName of the compute app to change config for (or\n<namespace>\\_\\_<developerName> if it was deployed under a namespace).\nDefaults to the COMPUTE_APP_NAME environment variable, or the current\ndirectory's app name if that isn't set either.",
1101
1108
  "hasDynamicHelp": false,
1102
1109
  "multiple": false,
1103
1110
  "type": "option"
@@ -1118,59 +1125,44 @@
1118
1125
  "hasDynamicHelp": false,
1119
1126
  "multiple": false,
1120
1127
  "type": "option"
1121
- },
1122
- "output-dir": {
1123
- "char": "d",
1124
- "description": "Defaults to force-app/main/default/computeApps. The app itself is created in a\nsubdirectory named after --name.",
1125
- "name": "output-dir",
1126
- "summary": "Directory to create the app in.",
1127
- "default": "force-app/main/default/computeApps",
1128
- "hasDynamicHelp": false,
1129
- "multiple": false,
1130
- "type": "option"
1131
1128
  }
1132
1129
  },
1133
1130
  "hasDynamicHelp": true,
1134
- "hiddenAliases": [],
1135
- "id": "compute:source:retrieve",
1131
+ "hiddenAliases": [
1132
+ "compute:config:set"
1133
+ ],
1134
+ "id": "compute:set:config",
1136
1135
  "pluginAlias": "@heroku/plugin-compute",
1137
1136
  "pluginName": "@heroku/plugin-compute",
1138
1137
  "pluginType": "core",
1139
1138
  "strict": true,
1140
- "summary": "Retrieve a compute app's source and metadata from an org into your local Salesforce DX project.",
1139
+ "summary": "Set one or more of a compute app's config vars.",
1141
1140
  "enableJsonFlag": true,
1142
- "requiresProject": true,
1141
+ "requiresProject": false,
1143
1142
  "isESM": true,
1144
1143
  "relativePath": [
1145
1144
  "dist",
1146
1145
  "commands",
1147
1146
  "compute",
1148
- "source",
1149
- "retrieve.js"
1147
+ "set",
1148
+ "config.js"
1150
1149
  ],
1151
1150
  "aliasPermutations": [],
1152
1151
  "permutations": [
1153
- "compute:source:retrieve",
1154
- "source:compute:retrieve",
1155
- "source:retrieve:compute",
1156
- "compute:retrieve:source",
1157
- "retrieve:compute:source",
1158
- "retrieve:source:compute"
1152
+ "compute:set:config",
1153
+ "set:compute:config",
1154
+ "set:config:compute",
1155
+ "compute:config:set",
1156
+ "config:compute:set",
1157
+ "config:set:compute"
1159
1158
  ]
1160
1159
  },
1161
- "compute:set:config": {
1160
+ "compute:source:retrieve": {
1162
1161
  "aliases": [],
1163
- "args": {
1164
- "pair": {
1165
- "multiple": true,
1166
- "name": "pair"
1167
- }
1168
- },
1169
- "deprecateAliases": true,
1170
- "description": "Goes through the target org's Salesforce Connect API, which calls Heroku on\nyour behalf. Setting a config var restarts the app's dynos so the new value\ntakes effect. Pass one or more KEY=VALUE pairs; a key that doesn't already\nexist is created.",
1162
+ "args": {},
1163
+ "description": "Creates the compute app's directory under force-app/main/default/computeApps/<name>/\n(or --output-dir), retrieves its <name>.computeApp-meta.xml through the Metadata\nAPI, then downloads its source code through the Connect API and extracts it\ninto that same directory. Deploy it with project deploy start.",
1171
1164
  "examples": [
1172
- "Set a single config var:\n<%= config.bin %> <%= command.id %> STRIPE_KEY=sk_live_xyz789 --name CreditRatingScorer --target-org my-org",
1173
- "Set more than one config var in one command:\n<%= config.bin %> <%= command.id %> STRIPE_KEY=sk_live_xyz789 LOG_LEVEL=debug --name CreditRatingScorer --target-org my-org"
1165
+ "Retrieve a compute app's source and metadata from an org:\n<%= config.bin %> <%= command.id %> --name CreditRatingScorer --target-org my-org"
1174
1166
  ],
1175
1167
  "flags": {
1176
1168
  "json": {
@@ -1190,9 +1182,9 @@
1190
1182
  },
1191
1183
  "name": {
1192
1184
  "char": "n",
1193
- "env": "COMPUTE_APP_NAME",
1194
1185
  "name": "name",
1195
- "summary": "DeveloperName of the compute app to change config for (or\n<namespace>\\_\\_<developerName> if it was deployed under a namespace).\nDefaults to the COMPUTE_APP_NAME environment variable, or the current\ndirectory's app name if that isn't set either.",
1186
+ "required": true,
1187
+ "summary": "DeveloperName of the compute app to retrieve (or <namespace>\\_\\_<developerName>\nif it was deployed under a namespace).",
1196
1188
  "hasDynamicHelp": false,
1197
1189
  "multiple": false,
1198
1190
  "type": "option"
@@ -1213,36 +1205,44 @@
1213
1205
  "hasDynamicHelp": false,
1214
1206
  "multiple": false,
1215
1207
  "type": "option"
1208
+ },
1209
+ "output-dir": {
1210
+ "char": "d",
1211
+ "description": "Defaults to force-app/main/default/computeApps. The app itself is created in a\nsubdirectory named after --name.",
1212
+ "name": "output-dir",
1213
+ "summary": "Directory to create the app in.",
1214
+ "default": "force-app/main/default/computeApps",
1215
+ "hasDynamicHelp": false,
1216
+ "multiple": false,
1217
+ "type": "option"
1216
1218
  }
1217
1219
  },
1218
1220
  "hasDynamicHelp": true,
1219
- "hiddenAliases": [
1220
- "compute:config:set"
1221
- ],
1222
- "id": "compute:set:config",
1221
+ "hiddenAliases": [],
1222
+ "id": "compute:source:retrieve",
1223
1223
  "pluginAlias": "@heroku/plugin-compute",
1224
1224
  "pluginName": "@heroku/plugin-compute",
1225
1225
  "pluginType": "core",
1226
1226
  "strict": true,
1227
- "summary": "Set one or more of a compute app's config vars.",
1227
+ "summary": "Retrieve a compute app's source and metadata from an org into your local Salesforce DX project.",
1228
1228
  "enableJsonFlag": true,
1229
- "requiresProject": false,
1229
+ "requiresProject": true,
1230
1230
  "isESM": true,
1231
1231
  "relativePath": [
1232
1232
  "dist",
1233
1233
  "commands",
1234
1234
  "compute",
1235
- "set",
1236
- "config.js"
1235
+ "source",
1236
+ "retrieve.js"
1237
1237
  ],
1238
1238
  "aliasPermutations": [],
1239
1239
  "permutations": [
1240
- "compute:set:config",
1241
- "set:compute:config",
1242
- "set:config:compute",
1243
- "compute:config:set",
1244
- "config:compute:set",
1245
- "config:set:compute"
1240
+ "compute:source:retrieve",
1241
+ "source:compute:retrieve",
1242
+ "source:retrieve:compute",
1243
+ "compute:retrieve:source",
1244
+ "retrieve:compute:source",
1245
+ "retrieve:source:compute"
1246
1246
  ]
1247
1247
  },
1248
1248
  "compute:tail:runtime-log": {
@@ -1517,5 +1517,5 @@
1517
1517
  ]
1518
1518
  }
1519
1519
  },
1520
- "version": "0.4.2"
1520
+ "version": "0.4.4"
1521
1521
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heroku/plugin-compute",
3
3
  "description": "CLI for Compute",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "author": "Heroku",
6
6
  "bugs": "https://github.com/heroku/plugin-compute/issues",
7
7
  "dependencies": {