@fastly/compute-js-static-publish 8.1.0-beta.3 → 8.1.0-beta.5

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +602 -0
  2. package/DOCUMENTATION.md +53 -14
  3. package/MIGRATING.md +289 -0
  4. package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
  5. package/build/cli/cli/commands/manage/deploy.js +27 -7
  6. package/build/cli/cli/commands/manage/index.d.ts +1 -0
  7. package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
  8. package/build/cli/cli/commands/manage/index.js +13 -11
  9. package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
  10. package/build/cli/cli/commands/manage/publish-content.js +5 -3
  11. package/build/cli/cli/commands/manage/status.d.ts.map +1 -1
  12. package/build/cli/cli/commands/manage/status.js +7 -5
  13. package/build/cli/cli/commands/manage/template/init.js +6 -6
  14. package/build/cli/cli/commands/scaffold/generate-app.d.ts +2 -0
  15. package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
  16. package/build/cli/cli/commands/scaffold/generate-app.js +6 -0
  17. package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
  18. package/build/cli/cli/commands/scaffold/index.js +12 -6
  19. package/build/cli/cli/index.js +15 -1
  20. package/build/cli/cli/managed/fastly-service.d.ts +7 -0
  21. package/build/cli/cli/managed/fastly-service.d.ts.map +1 -1
  22. package/build/cli/cli/managed/fastly-service.js +31 -1
  23. package/build/cli/cli/managed/fingerprint.d.ts +12 -0
  24. package/build/cli/cli/managed/fingerprint.d.ts.map +1 -1
  25. package/build/cli/cli/managed/fingerprint.js +25 -0
  26. package/build/cli/cli/managed/project-file.d.ts.map +1 -1
  27. package/build/cli/cli/managed/project-file.js +9 -1
  28. package/build/cli/cli/managed/template-init.d.ts.map +1 -1
  29. package/build/cli/cli/managed/template-init.js +3 -1
  30. package/build/cli/cli/util/collection-selection-flags.d.ts +1 -1
  31. package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -1
  32. package/build/cli/cli/util/collection-selection-flags.js +31 -5
  33. package/build/cli/cli/util/config.d.ts +4 -0
  34. package/build/cli/cli/util/config.d.ts.map +1 -1
  35. package/build/cli/cli/util/config.js +33 -0
  36. package/build/cli/cli/util/fastly-options.d.ts +2 -0
  37. package/build/cli/cli/util/fastly-options.d.ts.map +1 -0
  38. package/build/cli/cli/util/fastly-options.js +52 -0
  39. package/build/cli/cli/util/output.js +1 -1
  40. package/build/cli/cli/util/package.d.ts.map +1 -1
  41. package/build/cli/cli/util/package.js +10 -4
  42. package/build/cli/models/config/collection-selection.d.ts +2 -0
  43. package/build/cli/models/config/collection-selection.d.ts.map +1 -1
  44. package/build/cli/models/config/collection-selection.js +48 -8
  45. package/build/cli/models/config/s3-storage-config.d.ts +1 -0
  46. package/build/cli/models/config/s3-storage-config.d.ts.map +1 -1
  47. package/build/cli/models/config/s3-storage-config.js +1 -0
  48. package/build/cli/models/config/static-publish-rc.d.ts +1 -0
  49. package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
  50. package/build/cli/models/config/static-publish-rc.js +3 -1
  51. package/build/server/hono/extensions.d.ts +3 -1
  52. package/build/server/hono/extensions.d.ts.map +1 -1
  53. package/build/server/hono/extensions.js +12 -7
  54. package/build/server/hono/index.d.ts +6 -1
  55. package/build/server/hono/index.d.ts.map +1 -1
  56. package/build/server/hono/index.js +21 -13
  57. package/build/server/models/config/collection-selection.d.ts +2 -0
  58. package/build/server/models/config/collection-selection.d.ts.map +1 -1
  59. package/build/server/models/config/collection-selection.js +48 -8
  60. package/build/server/models/config/s3-storage-config.d.ts +1 -0
  61. package/build/server/models/config/s3-storage-config.d.ts.map +1 -1
  62. package/build/server/models/config/s3-storage-config.js +1 -0
  63. package/build/server/models/config/static-publish-rc.d.ts +1 -0
  64. package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
  65. package/build/server/models/config/static-publish-rc.js +3 -1
  66. package/build/server/server/collection-selection/index.d.ts.map +1 -1
  67. package/build/server/server/collection-selection/index.js +16 -6
  68. package/build/server/server/publisher-server/index.d.ts +2 -0
  69. package/build/server/server/publisher-server/index.d.ts.map +1 -1
  70. package/build/server/server/publisher-server/index.js +4 -4
  71. package/build/server/server/storage/s3-storage-provider.d.ts +2 -1
  72. package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
  73. package/build/server/server/storage/s3-storage-provider.js +15 -7
  74. package/package.json +4 -2
  75. package/resources/app/fastly.toml.njk +8 -8
  76. package/resources/app/static-publish.project.js.njk +6 -0
  77. package/resources/app/static-publish.rc.js.njk +6 -0
  78. package/resources/template-init/hono/gitignore +1 -0
  79. package/resources/templates/hono/src/index.ts +6 -4
@@ -81,18 +81,20 @@ Examples:
81
81
  ${cliCommand()} publish-content --project-dir=./compute-js
82
82
  `);
83
83
  }
84
+ const modes = {
85
+ 'clean': cleanCommand,
86
+ 'deploy': deployCommand,
87
+ 'dev': devCommand,
88
+ 'eject': ejectCommand,
89
+ 'status': statusCommand,
90
+ 'upgrade': upgradeCommand,
91
+ 'publish-content': publishContentCommand,
92
+ 'collections': collectionsCommands,
93
+ 'template': templateCommands,
94
+ };
95
+ // The commands for a project or an app. Scaffolding mode does not have them.
96
+ export const MANAGEMENT_COMMANDS = Object.keys(modes);
84
97
  export async function action(actionArgs) {
85
- const modes = {
86
- 'clean': cleanCommand,
87
- 'deploy': deployCommand,
88
- 'dev': devCommand,
89
- 'eject': ejectCommand,
90
- 'status': statusCommand,
91
- 'upgrade': upgradeCommand,
92
- 'publish-content': publishContentCommand,
93
- 'collections': collectionsCommands,
94
- 'template': templateCommands,
95
- };
96
98
  const commandAndArgs = getCommandAndArgs(actionArgs, modes);
97
99
  if (commandAndArgs.needHelp) {
98
100
  if (commandAndArgs.error != null) {
@@ -1 +1 @@
1
- {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAiJA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwmBhD"}
1
+ {"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AAiJA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0mBhD"}
@@ -499,11 +499,13 @@ export async function action(actionArgs) {
499
499
  }
500
500
  console.log(`✅ Scan complete.`);
501
501
  console.log(` | ${Object.keys(assetsIndex).length} file(s) in the index, ${hiddenCount} of them hidden.`);
502
+ // Counted before applyBatch(), which can split the entries into chunks.
503
+ const uploadedVariantCount = batch.storageProviderBatchEntries.length;
502
504
  if (existingKeys != null) {
503
- console.log(` | ${existingVariantCount} variant(s) already in storage, ${batch.storageProviderBatchEntries.length} to upload.`);
505
+ console.log(` | ${existingVariantCount} variant(s) already in storage, ${uploadedVariantCount} to upload.`);
504
506
  }
505
507
  else {
506
- console.log(` | ${batch.storageProviderBatchEntries.length} variant(s) to upload.`);
508
+ console.log(` | ${uploadedVariantCount} variant(s) to upload.`);
507
509
  }
508
510
  await storageProvider.applyBatch(batch, { existingKeys, verbose });
509
511
  // #### INDEX FILE
@@ -606,7 +608,7 @@ export async function action(actionArgs) {
606
608
  },
607
609
  // Each file, and each compressed variant that is kept.
608
610
  storageItems: {
609
- uploaded: batch.storageProviderBatchEntries.length,
611
+ uploaded: uploadedVariantCount,
610
612
  reused: existingVariantCount,
611
613
  },
612
614
  expiresAt: expirationTime != null ? new Date(expirationTime * 1000).toISOString() : null,
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/status.ts"],"names":[],"mappings":"AAgDA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAsIhD"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/status.ts"],"names":[],"mappings":"AA+CA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAyIhD"}
@@ -5,8 +5,7 @@
5
5
  import path from 'node:path';
6
6
  import { managedAppState } from '../../managed/app.js';
7
7
  import { loadManagedProject } from '../../managed/command-helpers.js';
8
- import { getActiveVersion, getVersionDomains } from '../../managed/fastly-service.js';
9
- import { parseVersionComment } from '../../managed/fingerprint.js';
8
+ import { getActiveVersion, getDeployedApp, getVersionDomains } from '../../managed/fastly-service.js';
10
9
  import { checkProjectVersion } from '../../managed/version-check.js';
11
10
  import { loadApiToken } from '../../util/api-token.js';
12
11
  import { parseCommandLine } from '../../util/args.js';
@@ -81,6 +80,8 @@ export async function action(actionArgs) {
81
80
  let deployedFingerprint = null;
82
81
  let deployedStaticPublishVersion = null;
83
82
  let activeVersion = null;
83
+ // The version whose comment has the fingerprint, if it is not the active version.
84
+ let fingerprintVersion = null;
84
85
  let domain = null;
85
86
  let needsDeploy;
86
87
  const reasons = [];
@@ -102,13 +103,14 @@ export async function action(actionArgs) {
102
103
  else {
103
104
  activeVersion = active.number;
104
105
  domain = (await getVersionDomains(context, serviceId, active.number))[0] ?? null;
105
- const deployed = parseVersionComment(active.comment);
106
+ const deployed = await getDeployedApp(context, serviceId, active);
106
107
  if (deployed == null) {
107
108
  needsDeploy = true;
108
- reasons.push(`The active version (${active.number}) was not deployed by 'deploy' (its comment has no fingerprint).`);
109
+ reasons.push(`The active version (${active.number}) was not deployed by 'deploy': its comment has no fingerprint, and its package is not the package of the newest version that has one.`);
109
110
  }
110
111
  else {
111
112
  deployedFingerprint = deployed.fingerprint;
113
+ fingerprintVersion = deployed.fingerprintVersion ?? null;
112
114
  deployedStaticPublishVersion = deployed.staticPublishVersion;
113
115
  needsDeploy = deployed.fingerprint !== fingerprint;
114
116
  if (needsDeploy) {
@@ -137,7 +139,7 @@ export async function action(actionArgs) {
137
139
  console.log(`Version of the project : ${versionCheck.recorded ?? '(missing)'}`);
138
140
  console.log(`Version that runs : ${running}${versionCheck.result !== 'same' ? ` ⚠️ ${versionCheck.result}` : ''}`);
139
141
  console.log(`Fingerprint : ${fingerprint}`);
140
- console.log(`Deployed fingerprint : ${deployedFingerprint ?? '(unknown)'}${activeVersion != null ? ` (version ${activeVersion})` : ''}`);
142
+ console.log(`Deployed fingerprint : ${deployedFingerprint ?? '(unknown)'}${activeVersion != null ? ` (version ${activeVersion}${fingerprintVersion != null ? `, the same package as version ${fingerprintVersion}` : ''})` : ''}`);
141
143
  console.log(`Deploy necessary : ${needsDeploy == null ? 'unknown' : needsDeploy ? 'yes' : 'no'}`);
142
144
  for (const reason of reasons) {
143
145
  console.log(` * ${reason}`);
@@ -27,14 +27,14 @@ Description:
27
27
  The template is managed.template in ${PROJECT_FILE_NAME}, or
28
28
  generatedFrom.template in ${RC_FILE_NAME}.
29
29
 
30
- A new folder gets package.json, tsconfig.json, and inactive examples. In a
31
- folder that exists, it updates only the peer dependencies on the packages
32
- that the app provides, and adds the starter files that are missing. It never
33
- changes your modules. Then run npm install in the folder.
30
+ A new folder gets package.json, tsconfig.json, .gitignore, and an inactive
31
+ example. In a folder that exists, it updates only the peer dependencies on
32
+ the packages that the app provides, and adds the starter files that are
33
+ missing. It never changes your modules. Then run npm install in the folder.
34
34
 
35
35
  Options:
36
- --reset Also write the starter files again (tsconfig.json
37
- and the examples). Asks before it replaces a file,
36
+ --reset Also write the starter files again (tsconfig.json,
37
+ .gitignore, and the example). Asks before it replaces a file,
38
38
  or needs --force in non-interactive mode.
39
39
  --force With --reset: replace without a question.
40
40
  --check Change nothing. Fail (template-init-needed) if
@@ -17,6 +17,8 @@ export type AppConfig = {
17
17
  bucket: string;
18
18
  endpointUrl: string;
19
19
  endpointGenerated: boolean;
20
+ fastlyBackendName?: string;
21
+ secretStoreLinkName?: string;
20
22
  };
21
23
  publishId: string;
22
24
  defaultCollectionName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"generate-app.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/generate-app.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE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3BackendName;
86
+ let s3SecretStoreLinkName;
85
87
  if (storage.mode === 'kv-store') {
86
88
  localServerKvStorePath = dotRelative(computeJsDir, path.resolve(staticPublisherWorkingDir, 'kvstore.json'));
87
89
  // kvstore.json
@@ -91,6 +93,8 @@ export function generateApp(config) {
91
93
  const url = new URL(storage.endpointUrl);
92
94
  s3EndpointUrl = String(url);
93
95
  s3EndpointHostname = url.hostname;
96
+ s3BackendName = storage.fastlyBackendName ?? 's3_storage';
97
+ s3SecretStoreLinkName = storage.secretStoreLinkName ?? 'S3_CREDENTIALS';
94
98
  }
95
99
  resourceFiles['fastly.toml'] = addFastlyTomlSections(renderAppResource('fastly.toml', {
96
100
  author,
@@ -101,6 +105,8 @@ export function generateApp(config) {
101
105
  localServerKvStorePath,
102
106
  s3EndpointUrl,
103
107
  s3EndpointHostname,
108
+ s3BackendName,
109
+ s3SecretStoreLinkName,
104
110
  }), fastlyToml);
105
111
  // static-publish.rc.js
106
112
  resourceFiles['static-publish.rc.js'] = renderAppResource('static-publish.rc.js', {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AAoGA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,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,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA2UF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA4iBhD;AASD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAehH"}
@@ -839,6 +839,7 @@ To build and deploy to your Compute service:
839
839
 
840
840
  The application reads the S3 credentials from the Secret Store that has the resource
841
841
  link name 'S3_CREDENTIALS' on the service. The Secret Store can have a different name.
842
+ To use another resource link name, set s3.secretStoreLinkName in static-publish.rc.js.
842
843
 
843
844
  To deploy to an existing service, do these steps first:
844
845
  1. Create a Secret Store with the values 'S3_ACCESS_KEY_ID' and 'S3_SECRET_ACCESS_KEY'.
@@ -857,8 +858,8 @@ To build and deploy to your Compute service:
857
858
 
858
859
  If a Secret Store named 'S3_CREDENTIALS' already exists, the Fastly CLI asks for a
859
860
  different name. If you leave it empty, it uses the existing Secret Store. If you give
860
- a different name, the Fastly CLI uses it for the resource link too. Then call
861
- setSecretStoreForS3Credentials() with that name in ${appConfig.template.entry}, and deploy again.
861
+ a different name, the Fastly CLI uses it for the resource link too. Then set
862
+ s3.secretStoreLinkName in static-publish.rc.js to that name, and deploy again.
862
863
 
863
864
  After the deploy, fastly.toml has the service ID, so s3:publish also purges the
864
865
  service's cache. For this purge, s3:publish needs FASTLY_API_TOKEN too.
@@ -868,9 +869,12 @@ To build and deploy to your Compute service:
868
869
  }
869
870
  // The lines that scaffold --managed adds to the .gitignore of the project dir.
870
871
  const GITIGNORE_COMMENT = '# @fastly/compute-js-static-publish';
872
+ // A line is present also without its leading or trailing '/': for example,
873
+ // 'node_modules' in the file also ignores the directory of '/node_modules/'.
874
+ const gitignoreKey = (line) => line.trim().replace(/^\//, '').replace(/\/$/, '');
871
875
  export function addGitignoreLines(existing, lines) {
872
- const present = new Set((existing ?? '').split(/\r?\n/).map(x => x.trim()));
873
- const added = lines.filter(line => !present.has(line));
876
+ const present = new Set((existing ?? '').split(/\r?\n/).map(gitignoreKey));
877
+ const added = lines.filter(line => !present.has(gitignoreKey(line)));
874
878
  if (added.length === 0) {
875
879
  return { content: existing ?? '', added };
876
880
  }
@@ -888,11 +892,13 @@ function writeManagedProject(appConfig, projectDir) {
888
892
  const projectFilePath = path.resolve(projectDir, PROJECT_FILE_NAME);
889
893
  fs.writeFileSync(projectFilePath, renderProjectFile(appConfig, projectDir, getOwnVersion()), 'utf-8');
890
894
  console.log(`🚀 Managed project created: ${rootRelative(projectFilePath)}`);
891
- // Ignore the generated app and the working dir. Never change the customer's lines.
895
+ // Ignore the node_modules of the project (this package can be a dev
896
+ // dependency of the project), the generated app, and the working dir. Never
897
+ // change the customer's lines.
892
898
  const gitignorePath = path.resolve(projectDir, '.gitignore');
893
899
  const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf-8') : null;
894
900
  const workingDir = path.relative(projectDir, appConfig.staticPublisherWorkingDir).split(path.sep).join('/');
895
- const lines = ['/.static-publish/'];
901
+ const lines = ['/node_modules/', '/.static-publish/'];
896
902
  if (!workingDir.startsWith('..')) {
897
903
  lines.push(`/${workingDir}/`);
898
904
  }
@@ -13,7 +13,7 @@ import { runTemplateHook } from './commands/run-template-hook.js';
13
13
  import { parseGlobalOptions } from './util/global-options.js';
14
14
  import { ConfigError, EXIT_USAGE, JSON_SCHEMA_VERSION, fail, isJsonMode, recordFailure, setJsonResult, setUpOutput, writeJsonOutput, } from './util/output.js';
15
15
  import { getOwnVersion } from './util/package.js';
16
- import { detectProjectMode } from './util/config.js';
16
+ import { detectProjectMode, findProjectDirsNear } from './util/config.js';
17
17
  import { PROJECT_FILE_NAME, RC_FILE_NAME } from '../models/config/static-publish-project.js';
18
18
  // Register storage builder providers
19
19
  import { registerStorageProviderBuilder } from './storage/storage-provider.js';
@@ -108,6 +108,20 @@ async function run(globalOptions) {
108
108
  return;
109
109
  }
110
110
  if (mode === 'scaffold') {
111
+ // A command for a project or an app, in a directory that has none.
112
+ const command = process.argv[2];
113
+ if (command != null && manageCommands.MANAGEMENT_COMMANDS.includes(command)) {
114
+ fail('project-dir-not-found', `'${command}' is a command for a managed project or an app, but this directory has no ${PROJECT_FILE_NAME} or ${RC_FILE_NAME}.`);
115
+ const near = findProjectDirsNear();
116
+ for (const { dir, mode: kind } of near.slice(0, 3)) {
117
+ const relative = path.relative(process.cwd(), dir) || '.';
118
+ console.error(` * ${relative} has ${kind === 'managed' ? PROJECT_FILE_NAME : RC_FILE_NAME}. Run the command there, or add --project-dir=${relative}.`);
119
+ }
120
+ if (near.length === 0) {
121
+ console.error(` * Run it in the directory of the project (with ${PROJECT_FILE_NAME}) or of the app (with ${RC_FILE_NAME}), or add --project-dir.`);
122
+ }
123
+ return;
124
+ }
111
125
  console.log("🧑‍💻Fastly Compute JavaScript Static Publisher (Scaffolding mode)");
112
126
  if (isJsonMode()) {
113
127
  fail('json-not-supported', '--json is not supported for scaffolding.');
@@ -1,8 +1,15 @@
1
1
  import { type FastlyApiContext } from '../util/api-token.js';
2
+ import { type DeployedApp } from './fingerprint.js';
2
3
  export type ActiveVersion = {
3
4
  number: number;
4
5
  comment: string | null;
5
6
  };
6
7
  export declare function getActiveVersion(context: FastlyApiContext, serviceId: string): Promise<ActiveVersion | null>;
7
8
  export declare function getVersionDomains(context: FastlyApiContext, serviceId: string, version: number): Promise<string[]>;
9
+ export declare function getVersions(context: FastlyApiContext, serviceId: string): Promise<{
10
+ number: number;
11
+ comment: string | null;
12
+ }[]>;
13
+ export declare function getPackageHash(context: FastlyApiContext, serviceId: string, version: number): Promise<string | null>;
14
+ export declare function getDeployedApp(context: FastlyApiContext, serviceId: string, active: ActiveVersion): Promise<DeployedApp | null>;
8
15
  //# sourceMappingURL=fastly-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastly-service.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/fastly-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAGF,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQlH;AAGD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIxH"}
1
+ {"version":3,"file":"fastly-service.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/fastly-service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAA6B,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,KAAK,WAAW,EAAwC,MAAM,kBAAkB,CAAC;AAE1F,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAGF,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQlH;AAGD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIxH;AAGD,wBAAsB,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,CAAC,CAIrI;AAGD,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAY1H;AAGD,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAMrI"}
@@ -2,7 +2,8 @@
2
2
  * Copyright Fastly, Inc.
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
- import { callFastlyApi } from '../util/api-token.js';
5
+ import { FetchError, callFastlyApi } from '../util/api-token.js';
6
+ import { findDeployedApp, parseVersionComment } from './fingerprint.js';
6
7
  // The active version of a service, or null if no version is active.
7
8
  export async function getActiveVersion(context, serviceId) {
8
9
  const response = await callFastlyApi(context, `/service/${encodeURIComponent(serviceId)}/details`, 'Get service details');
@@ -19,3 +20,32 @@ export async function getVersionDomains(context, serviceId, version) {
19
20
  const domains = await response.json();
20
21
  return domains.flatMap(x => typeof x.name === 'string' ? [x.name] : []);
21
22
  }
23
+ // The versions of a service, with their comments.
24
+ export async function getVersions(context, serviceId) {
25
+ const response = await callFastlyApi(context, `/service/${encodeURIComponent(serviceId)}/version`, 'List versions');
26
+ const versions = await response.json();
27
+ return versions.flatMap(x => typeof x.number === 'number' ? [{ number: x.number, comment: x.comment ?? null }] : []);
28
+ }
29
+ // The hash of the package of a service version, or null if it has no package.
30
+ export async function getPackageHash(context, serviceId, version) {
31
+ let response;
32
+ try {
33
+ response = await callFastlyApi(context, `/service/${encodeURIComponent(serviceId)}/version/${version}/package`, 'Get package');
34
+ }
35
+ catch (err) {
36
+ if (err instanceof FetchError && err.status === 404) {
37
+ return null;
38
+ }
39
+ throw err;
40
+ }
41
+ const pkg = await response.json();
42
+ return typeof pkg.metadata?.hashsum === 'string' && pkg.metadata.hashsum !== '' ? pkg.metadata.hashsum : null;
43
+ }
44
+ // The app that the active version runs (see findDeployedApp()).
45
+ export async function getDeployedApp(context, serviceId, active) {
46
+ const own = parseVersionComment(active.comment);
47
+ if (own != null) {
48
+ return own;
49
+ }
50
+ return findDeployedApp(active, await getVersions(context, serviceId), (version) => getPackageHash(context, serviceId, version));
51
+ }
@@ -10,4 +10,16 @@ export declare function parseVersionComment(comment: string | null | undefined):
10
10
  staticPublishVersion: string;
11
11
  fingerprint: string;
12
12
  } | null;
13
+ export type DeployedApp = {
14
+ staticPublishVersion: string;
15
+ fingerprint: string;
16
+ fingerprintVersion?: number;
17
+ };
18
+ export declare function findDeployedApp(active: {
19
+ number: number;
20
+ comment: string | null;
21
+ }, versions: {
22
+ number: number;
23
+ comment: string | null;
24
+ }[], getPackageHash: (version: number) => Promise<string | null>): Promise<DeployedApp | null>;
13
25
  //# sourceMappingURL=fingerprint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/fingerprint.ts"],"names":[],"mappings":"AAkBA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIrF;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IAGjB,YAAY,EAAE,MAAM,EAAE,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,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IAGpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AASF,wBAAsB,eAAe,CACnC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAClD,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,EACtD,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAC1D,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAiB7B"}
@@ -58,3 +58,28 @@ export function parseVersionComment(comment) {
58
58
  }
59
59
  return { staticPublishVersion: match[1], fingerprint: match[2] };
60
60
  }
61
+ // The app that the active version runs. The fingerprint is in the comment of
62
+ // the version that deploy made. A version cloned by hand (for example to add a
63
+ // backend) has no comment, but it has the package of the version that it was
64
+ // cloned from. Thus, if the active version has no fingerprint, the newest
65
+ // earlier version with a fingerprint is used, but only if its package hash is
66
+ // the same as the package hash of the active version. Each deploy uploads a
67
+ // new package with a different hash, also for the same app.
68
+ export async function findDeployedApp(active, versions, getPackageHash) {
69
+ const own = parseVersionComment(active.comment);
70
+ if (own != null) {
71
+ return own;
72
+ }
73
+ const earlier = versions
74
+ .filter(version => version.number < active.number)
75
+ .sort((a, b) => b.number - a.number)
76
+ .find(version => parseVersionComment(version.comment) != null);
77
+ if (earlier == null) {
78
+ return null;
79
+ }
80
+ const [activeHash, earlierHash] = await Promise.all([getPackageHash(active.number), getPackageHash(earlier.number)]);
81
+ if (activeHash == null || activeHash !== earlierHash) {
82
+ return null;
83
+ }
84
+ return { ...parseVersionComment(earlier.comment), fingerprintVersion: earlier.number };
85
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"project-file.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/project-file.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAA0D,MAAM,0CAA0C,CAAC;AAGxI,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,sCAAsC,CAAC;AAMxF,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAKvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAyC7G;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,EAAE,WAAW,CAAC;IAGtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,eAAe,EACnB,cAAc,EAAE,8BAA8B,EAC9C,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE,2BAA2B,GACnC,SAAS,CA6DX"}
1
+ {"version":3,"file":"project-file.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/project-file.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAA0D,MAAM,0CAA0C,CAAC;AAGxI,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,sCAAsC,CAAC;AAMxF,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AAKvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAyC7G;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,MAAM,CAAC;IACjC,QAAQ,EAAE,WAAW,CAAC;IAGtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,eAAe,EACnB,cAAc,EAAE,8BAA8B,EAC9C,OAAO,EAAE,2BAA2B,EACpC,OAAO,EAAE,2BAA2B,GACnC,SAAS,CAqEX"}
@@ -78,7 +78,15 @@ export function appConfigFromProject(rc, publishContent, managed, options) {
78
78
  else {
79
79
  throw new Error('The S3 endpoint of the project is not resolved.');
80
80
  }
81
- storage = { mode: 's3', region: rc.s3.region, bucket: rc.s3.bucket, endpointUrl, endpointGenerated: rc.s3.endpoint == null };
81
+ storage = {
82
+ mode: 's3',
83
+ region: rc.s3.region,
84
+ bucket: rc.s3.bucket,
85
+ endpointUrl,
86
+ endpointGenerated: rc.s3.endpoint == null,
87
+ ...(rc.s3.fastlyBackendName != null ? { fastlyBackendName: rc.s3.fastlyBackendName } : {}),
88
+ ...(rc.s3.secretStoreLinkName != null ? { secretStoreLinkName: rc.s3.secretStoreLinkName } : {}),
89
+ };
82
90
  }
83
91
  else {
84
92
  storage = { mode: 'kv-store', kvStoreName: getKvStoreConfigFromRc(rc).kvStoreName };
@@ -1 +1 @@
1
- {"version":3,"file":"template-init.d.ts","sourceRoot":"","sources":["../../../../src/cli/managed/template-init.ts"],"names":[],"mappings":"AAoBA,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE7D;AAwBD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,iBAAiB,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BAAgB,CAsDzJ;AAGD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,QAM1E"}
@@ -17,6 +17,8 @@ export function templateHasInit(templateName) {
17
17
  return fs.existsSync(path.resolve(resourcesDir, 'template-init', templateName));
18
18
  }
19
19
  // The starter files of a template, keyed by the path relative to its folder.
20
+ // The file 'gitignore' is written as '.gitignore', because npm leaves a file
21
+ // named .gitignore out of the published package.
20
22
  function starterFiles(templateName) {
21
23
  const dir = path.resolve(resourcesDir, 'template-init', templateName);
22
24
  const files = {};
@@ -27,7 +29,7 @@ function starterFiles(templateName) {
27
29
  walk(rel);
28
30
  }
29
31
  else {
30
- files[rel] = fs.readFileSync(path.resolve(dir, rel), 'utf-8');
32
+ files[rel === 'gitignore' ? '.gitignore' : rel] = fs.readFileSync(path.resolve(dir, rel), 'utf-8');
31
33
  }
32
34
  }
33
35
  };
@@ -5,7 +5,7 @@ export type CollectionSelectionFlags = {
5
5
  onMissing?: string;
6
6
  noindex?: string;
7
7
  };
8
- export declare const COLLECTION_SELECTION_FLAGS_HELP = " --collection-selection <source> Select the collection of a request, for example for\n previews. Can be repeated; the sources are tried in order.\n host:<pattern> host:{collection}.preview.example.com\n path:<prefix>[,sticky] path:/_preview/{collection},sticky\n query:<param>[,sticky] query:collection,sticky\n cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]\n header:<name> header:x-publisher-collection\n 'sticky' also sets the cookie of the cookie source, so it needs a cookie source.\n --collection-allow <patterns> The collections that can be selected, for example \"pr-*,staging\".\n Default: any collection.\n --collection-on-missing <value> When the selected collection is not published or has\n expired: 'not-found' (default: a 404 response) or\n 'default' (serve the default collection).\n --collection-noindex <true|false> Add 'X-Robots-Tag: noindex' to the responses of a collection\n that is not the default collection. Default: true.";
8
+ export declare const COLLECTION_SELECTION_FLAGS_HELP = " --collection-selection <source> Select the collection of a request, for example for\n previews. Can be repeated; the sources are tried in order.\n host:<pattern> host:{collection}.preview.example.com\n host:<host>,value=<name> host:stag.example.com,value=staging\n path:<prefix>[,sticky] path:/_preview/{collection},sticky\n path:<prefix>,value=<name> path:/_staging,value=staging,sticky\n query:<param>[,sticky] query:collection,sticky\n cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]\n header:<name> header:x-publisher-collection\n 'sticky' also sets the cookie of the cookie source, so it needs a cookie source.\n 'value' gives one collection for a hostname or a prefix without {collection}.\n --collection-allow <patterns> The collections that can be selected, for example \"pr-*,staging\".\n Default: any collection.\n --collection-on-missing <value> When the selected collection is not published or has\n expired: 'not-found' (default: a 404 response) or\n 'default' (serve the default collection).\n --collection-noindex <true|false> Add 'X-Robots-Tag: noindex' to the responses of a collection\n that is not the default collection. Default: true.";
9
9
  export declare function collectionSelectionFromFlags(flags: CollectionSelectionFlags): {
10
10
  collectionSelection: CollectionSelection | undefined;
11
11
  errors: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"collection-selection-flags.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/collection-selection-flags.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,6CAA6C,CAAC;AAcrD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,+BAA+B,y8CAe+C,CAAC;AA0E5F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,wBAAwB,GAAG;IAC7E,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqCA"}
1
+ {"version":3,"file":"collection-selection-flags.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/collection-selection-flags.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,6CAA6C,CAAC;AAcrD,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,+BAA+B,oxDAkB+C,CAAC;AA+F5F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,wBAAwB,GAAG;IAC7E,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAqCA"}
@@ -7,11 +7,14 @@ export const COLLECTION_SELECTION_FLAGS_HELP = `\
7
7
  --collection-selection <source> Select the collection of a request, for example for
8
8
  previews. Can be repeated; the sources are tried in order.
9
9
  host:<pattern> host:{collection}.preview.example.com
10
+ host:<host>,value=<name> host:stag.example.com,value=staging
10
11
  path:<prefix>[,sticky] path:/_preview/{collection},sticky
12
+ path:<prefix>,value=<name> path:/_staging,value=staging,sticky
11
13
  query:<param>[,sticky] query:collection,sticky
12
14
  cookie[:<name>][,maxAge=<seconds>][,activatePath=<path>][,resetPath=<path>]
13
15
  header:<name> header:x-publisher-collection
14
16
  'sticky' also sets the cookie of the cookie source, so it needs a cookie source.
17
+ 'value' gives one collection for a hostname or a prefix without {collection}.
15
18
  --collection-allow <patterns> The collections that can be selected, for example "pr-*,staging".
16
19
  Default: any collection.
17
20
  --collection-on-missing <value> When the selected collection is not published or has
@@ -31,6 +34,23 @@ function parseSource(spec, errors) {
31
34
  }
32
35
  return true;
33
36
  };
37
+ // The options of a host or path source: value=<collection>, and sticky
38
+ // (only if allowSticky).
39
+ const valueAndSticky = (allowSticky) => {
40
+ const result = {};
41
+ for (const option of options) {
42
+ if (allowSticky && option === 'sticky') {
43
+ result.sticky = 'cookie';
44
+ }
45
+ else if (option.startsWith('value=')) {
46
+ result.value = option.slice('value='.length);
47
+ }
48
+ else {
49
+ errors.push(`--collection-selection ${type}: unknown option '${option}'.`);
50
+ }
51
+ }
52
+ return result;
53
+ };
34
54
  const sticky = () => {
35
55
  let result;
36
56
  for (const option of options) {
@@ -49,12 +69,18 @@ function parseSource(spec, errors) {
49
69
  }
50
70
  };
51
71
  switch (type) {
52
- case 'host':
53
- noOptions();
54
- return needValue('pattern') ? { type, pattern: value } : null;
72
+ case 'host': {
73
+ const o = valueAndSticky(false);
74
+ return needValue('pattern') ? { type, pattern: value, ...(o.value != null ? { value: o.value } : {}) } : null;
75
+ }
55
76
  case 'path': {
56
- const s = sticky();
57
- return needValue('prefix') ? { type, prefix: value, ...(s != null ? { sticky: s } : {}) } : null;
77
+ const o = valueAndSticky(true);
78
+ return needValue('prefix') ? {
79
+ type,
80
+ prefix: value,
81
+ ...(o.value != null ? { value: o.value } : {}),
82
+ ...(o.sticky != null ? { sticky: o.sticky } : {}),
83
+ } : null;
58
84
  }
59
85
  case 'query': {
60
86
  const s = sticky();
@@ -8,6 +8,10 @@ export declare class LoadConfigError extends Error {
8
8
  }
9
9
  export type ProjectMode = 'managed' | 'ejected' | 'scaffold' | 'conflict';
10
10
  export declare function detectProjectMode(dir?: string): ProjectMode;
11
+ export declare function findProjectDirsNear(dir?: string): {
12
+ dir: string;
13
+ mode: 'managed' | 'ejected';
14
+ }[];
11
15
  export declare function getComputeAppDir(): string;
12
16
  export declare function configFileName(): string;
13
17
  export type StaticPublishProjectNormalized = {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/config.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,+CAA+C,CAAC;AAWvD,OAAO,EACL,KAAK,8BAA8B,EAEpC,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KA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CAAC"}
@@ -29,6 +29,39 @@ export function detectProjectMode(dir = '.') {
29
29
  }
30
30
  return hasProject ? 'managed' : hasRc ? 'ejected' : 'scaffold';
31
31
  }
32
+ // The directories near dir that have a project file or an rc file: the parent
33
+ // directories, and the directories directly in dir (for example compute-js/).
34
+ // For the message when a command for a project or an app runs in another
35
+ // directory.
36
+ export function findProjectDirsNear(dir = '.') {
37
+ const found = [];
38
+ const add = (candidate) => {
39
+ const mode = detectProjectMode(candidate);
40
+ if (mode === 'managed' || mode === 'ejected') {
41
+ found.push({ dir: candidate, mode });
42
+ }
43
+ };
44
+ const start = path.resolve(dir);
45
+ for (let current = path.dirname(start);; current = path.dirname(current)) {
46
+ add(current);
47
+ if (path.dirname(current) === current) {
48
+ break;
49
+ }
50
+ }
51
+ let entries = [];
52
+ try {
53
+ entries = fs.readdirSync(start, { withFileTypes: true });
54
+ }
55
+ catch {
56
+ // An unreadable directory has no subdirectories to check.
57
+ }
58
+ for (const entry of entries) {
59
+ if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
60
+ add(path.join(start, entry.name));
61
+ }
62
+ }
63
+ return found;
64
+ }
32
65
  // The directory of the Compute app: the current directory in an ejected app,
33
66
  // or .static-publish/app in a managed project. The local KV Store file has
34
67
  // paths relative to it, because `fastly compute serve` runs there.
@@ -0,0 +1,2 @@
1
+ export declare function findRefusedFastlyOption(args: string[]): string | null;
2
+ //# sourceMappingURL=fastly-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastly-options.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/fastly-options.ts"],"names":[],"mappings":"AAiCA,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAqBrE"}