@serwist/cli 9.0.0-preview.9 → 9.0.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.
Files changed (32) hide show
  1. package/cli.js +3 -0
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/bin.d.ts +0 -1
  4. package/dist/bin.d.ts.map +1 -1
  5. package/dist/bin.js +133 -226
  6. package/dist/lib/ask-questions.d.ts +9 -0
  7. package/dist/lib/ask-questions.d.ts.map +1 -0
  8. package/dist/lib/cleanup-stack-trace.d.ts +1 -1
  9. package/dist/lib/cleanup-stack-trace.d.ts.map +1 -1
  10. package/dist/lib/constants.d.ts +0 -1
  11. package/dist/lib/constants.d.ts.map +1 -1
  12. package/dist/lib/help-text.d.ts +1 -1
  13. package/dist/lib/help-text.d.ts.map +1 -1
  14. package/dist/lib/read-config.d.ts +1 -1
  15. package/dist/lib/read-config.d.ts.map +1 -1
  16. package/dist/lib/run-wizard.d.ts +1 -1
  17. package/dist/lib/run-wizard.d.ts.map +1 -1
  18. package/package.json +15 -23
  19. package/dist/lib/questions/ask-config-location.d.ts +0 -2
  20. package/dist/lib/questions/ask-config-location.d.ts.map +0 -1
  21. package/dist/lib/questions/ask-extensions-to-cache.d.ts +0 -2
  22. package/dist/lib/questions/ask-extensions-to-cache.d.ts.map +0 -1
  23. package/dist/lib/questions/ask-questions.d.ts +0 -9
  24. package/dist/lib/questions/ask-questions.d.ts.map +0 -1
  25. package/dist/lib/questions/ask-root-of-web-app.d.ts +0 -2
  26. package/dist/lib/questions/ask-root-of-web-app.d.ts.map +0 -1
  27. package/dist/lib/questions/ask-start_url-query-params.d.ts +0 -2
  28. package/dist/lib/questions/ask-start_url-query-params.d.ts.map +0 -1
  29. package/dist/lib/questions/ask-sw-dest.d.ts +0 -2
  30. package/dist/lib/questions/ask-sw-dest.d.ts.map +0 -1
  31. package/dist/lib/questions/ask-sw-src.d.ts +0 -2
  32. package/dist/lib/questions/ask-sw-src.d.ts.map +0 -1
package/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // @ts-ignore
3
+ import "./dist/bin.js";
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAyC/C,eAAO,MAAM,GAAG,WAAkB,WAAW,cAAc,CAAC,KAAG,QAAQ,IAAI,CAgG1E,CAAC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAyC/C,eAAO,MAAM,GAAG,WAAkB,WAAW,cAAc,CAAC,KAAG,QAAQ,IAAI,CAiF1E,CAAC"}
package/dist/bin.d.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  import type { AnyFlags, BooleanFlag } from "./types.js";
3
3
  export interface SupportedFlags extends AnyFlags {
4
4
  debug: BooleanFlag;
5
- injectManifest: BooleanFlag;
6
5
  watch: BooleanFlag;
7
6
  }
8
7
  //# sourceMappingURL=bin.d.ts.map
package/dist/bin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,WAAW,CAAC;IACnB,cAAc,EAAE,WAAW,CAAC;IAC5B,KAAK,EAAE,WAAW,CAAC;CACpB"}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAiBA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,WAAW,CAAC;CACpB"}
package/dist/bin.js CHANGED
@@ -1,19 +1,17 @@
1
1
  #! /usr/bin/env node
2
2
  import meow from 'meow';
3
3
  import updateNotifier from 'update-notifier';
4
- import assert from 'assert';
4
+ import assert from 'node:assert';
5
5
  import { injectManifest } from '@serwist/build';
6
6
  import chokidar from 'chokidar';
7
7
  import prettyBytes from 'pretty-bytes';
8
8
  import upath from 'upath';
9
9
  import { oneLine } from 'common-tags';
10
10
  import chalk from 'chalk';
11
- import { createRequire } from 'node:module';
12
- import fse from 'fs-extra';
11
+ import { statSync, writeFileSync } from 'node:fs';
13
12
  import stringifyObject from 'stringify-object';
14
- import inquirer from 'inquirer';
15
13
  import { glob } from 'glob';
16
- import ora from 'ora';
14
+ import inquirer from 'inquirer';
17
15
 
18
16
  const constants = {
19
17
  defaultConfigFile: "serwist.config.js",
@@ -22,10 +20,6 @@ const constants = {
22
20
  ],
23
21
  ignoredFileExtensions: [
24
22
  "map"
25
- ],
26
- ignoreURLParametersMatching: [
27
- /^utm_/,
28
- /^fbclid$/
29
23
  ]
30
24
  };
31
25
 
@@ -62,32 +56,52 @@ const logger = {
62
56
  error: (...args)=>console.error(chalk.red.bold(...args))
63
57
  };
64
58
 
65
- const require = createRequire(import.meta.url);
66
- function readConfig(configFile) {
67
- return require(configFile);
68
- }
69
-
70
- const name$3 = "configLocation";
71
- const configLocationQuestion = {
72
- name: name$3,
73
- message: oneLine`Where would you like to save these configuration options?`,
74
- type: "input",
75
- default: constants.defaultConfigFile
59
+ const readConfig = async (configFile)=>{
60
+ return (await import(configFile)).default;
76
61
  };
77
- function askQuestion$5() {
78
- return inquirer.prompt([
79
- configLocationQuestion
80
- ]);
81
- }
82
- async function askConfigLocation() {
83
- const answers = await askQuestion$5();
84
- const configLocation = answers[name$3].trim();
85
- assert(configLocation, errors["invalid-config-location"]);
86
- return configLocation;
87
- }
88
62
 
89
- const name$2 = "globPatterns";
90
- async function getAllFileExtensions(globDirectory) {
63
+ const getSubdirectories = async ()=>{
64
+ return await glob("*/", {
65
+ ignore: constants.ignoredDirectories.map((directory)=>`${directory}/`)
66
+ });
67
+ };
68
+ const askRootOfWebApp = async ()=>{
69
+ const subdirectories = await getSubdirectories();
70
+ const { manualDirectoryInput, globDirectory } = await (()=>{
71
+ if (subdirectories.length > 0) {
72
+ const manualEntryChoice = "Manually enter path";
73
+ return inquirer.prompt([
74
+ {
75
+ name: "globDirectory",
76
+ type: "list",
77
+ message: oneLine`What is the root of your web app (i.e. which directory do
78
+ you deploy)?`,
79
+ choices: [
80
+ ...subdirectories,
81
+ new inquirer.Separator(),
82
+ manualEntryChoice
83
+ ]
84
+ },
85
+ {
86
+ name: "manualDirectoryInput",
87
+ when: (answers)=>answers.globDirectory === manualEntryChoice,
88
+ message: "Please enter the path to the root of your web app:"
89
+ }
90
+ ]);
91
+ }
92
+ return inquirer.prompt([
93
+ {
94
+ name: "globDirectory",
95
+ message: "Please enter the path to the root of your web app:",
96
+ default: "."
97
+ }
98
+ ]);
99
+ })();
100
+ const stat = statSync(manualDirectoryInput || globDirectory);
101
+ assert(stat.isDirectory(), errors["glob-directory-invalid"]);
102
+ return manualDirectoryInput || globDirectory;
103
+ };
104
+ const getAllFileExtensions = async (globDirectory)=>{
91
105
  const files = await glob("**/*.*", {
92
106
  cwd: globDirectory,
93
107
  nodir: true,
@@ -106,192 +120,99 @@ async function getAllFileExtensions(globDirectory) {
106
120
  return [
107
121
  ...extensions
108
122
  ];
109
- }
110
- async function askQuestion$4(globDirectory) {
111
- const spinner = ora({
112
- text: `Examining files in ${globDirectory}...`,
113
- stream: process.stdout
114
- }).start();
123
+ };
124
+ const askQuestions = async ()=>{
125
+ const globDirectory = await askRootOfWebApp();
115
126
  const fileExtensions = await getAllFileExtensions(globDirectory);
116
- spinner.stop();
117
127
  assert(fileExtensions.length > 0, errors["no-file-extensions-found"]);
118
- return inquirer.prompt([
128
+ const { swSrc, swDest, selectedExtensions, configLocation } = await inquirer.prompt([
119
129
  {
120
- name: name$2,
130
+ name: "swSrc",
131
+ message: oneLine`Where's your existing service worker file? To be used with
132
+ injectManifest, it should include a call to
133
+ 'self.__SW_MANIFEST'`,
134
+ type: "input",
135
+ validate (input) {
136
+ if (typeof input !== "string") {
137
+ return "You must provide a valid 'swSrc'!";
138
+ }
139
+ if (!statSync(input, {
140
+ throwIfNoEntry: false
141
+ })?.isFile()) {
142
+ return "'swSrc' must point to a valid file!";
143
+ }
144
+ return true;
145
+ }
146
+ },
147
+ {
148
+ name: "swDest",
149
+ message: "Where would you like your service worker file to be saved?",
150
+ type: "input",
151
+ default: upath.join(globDirectory, "sw.js"),
152
+ validate (input) {
153
+ if (typeof input !== "string") {
154
+ return "You must provide a valid 'swDest'!";
155
+ }
156
+ return true;
157
+ }
158
+ },
159
+ {
160
+ name: "selectedExtensions",
121
161
  message: "Which file types would you like to precache?",
122
162
  type: "checkbox",
123
163
  choices: fileExtensions,
124
- default: fileExtensions
125
- }
126
- ]);
127
- }
128
- async function askExtensionsToCache(globDirectory) {
129
- const answers = await askQuestion$4(globDirectory);
130
- const extensions = answers[name$2];
131
- assert(extensions.length > 0, errors["no-file-extensions-selected"]);
132
- const extensionsPattern = extensions.length === 1 ? extensions[0] : `{${extensions.join(",")}}`;
133
- return [
134
- `**/*.${extensionsPattern}`
135
- ];
136
- }
137
-
138
- const ROOT_PROMPT = "Please enter the path to the root of your web app:";
139
- const questionRootDirectory = "globDirectory";
140
- const questionManualInput = "manualDirectoryInput";
141
- async function getSubdirectories() {
142
- return await glob("*/", {
143
- ignore: constants.ignoredDirectories.map((directory)=>`${directory}/`)
144
- });
145
- }
146
- async function askQuestion$3() {
147
- const subdirectories = await getSubdirectories();
148
- if (subdirectories.length > 0) {
149
- const manualEntryChoice = "Manually enter path";
150
- return inquirer.prompt([
151
- {
152
- name: questionRootDirectory,
153
- type: "list",
154
- message: oneLine`What is the root of your web app (i.e. which directory do
155
- you deploy)?`,
156
- choices: subdirectories.concat([
157
- new inquirer.Separator(),
158
- manualEntryChoice
159
- ])
160
- },
161
- {
162
- name: questionManualInput,
163
- when: (answers)=>answers.globDirectory === manualEntryChoice,
164
- message: ROOT_PROMPT
164
+ default: fileExtensions,
165
+ validate (input) {
166
+ if (!Array.isArray(input)) {
167
+ return "'selectedExtensions' is not an array. This is most likely a bug.";
168
+ }
169
+ if (input.length === 0) {
170
+ return errors["no-file-extensions-selected"];
171
+ }
172
+ return true;
165
173
  }
166
- ]);
167
- }
168
- return inquirer.prompt([
169
- {
170
- name: questionRootDirectory,
171
- message: ROOT_PROMPT,
172
- default: "."
173
- }
174
- ]);
175
- }
176
- async function askRootOfWebApp() {
177
- const { manualDirectoryInput, globDirectory } = await askQuestion$3();
178
- try {
179
- const stat = await fse.stat(manualDirectoryInput || globDirectory);
180
- assert(stat.isDirectory());
181
- } catch (error) {
182
- throw new Error(errors["glob-directory-invalid"]);
183
- }
184
- return manualDirectoryInput || globDirectory;
185
- }
186
-
187
- const START_URL_QUERY_PARAMS_PROMPT = "Please enter the search parameter(s) that you would like to ignore (separated by comma):";
188
- const question_ignoreURLParametersMatching = "ignoreURLParametersMatching";
189
- const question_shouldAskForIgnoreURLParametersMatching = "shouldAskForIgnoreURLParametersMatching";
190
- async function askQuestion$2() {
191
- return inquirer.prompt([
192
- {
193
- name: question_shouldAskForIgnoreURLParametersMatching,
194
- message: oneLine`Does your web app manifest include search parameter(s)
195
- in the 'start_url', other than 'utm_' or 'fbclid'
196
- (like '?source=pwa')?`,
197
- type: "confirm",
198
- default: false
199
174
  },
200
175
  {
201
- name: question_ignoreURLParametersMatching,
202
- when: (answer)=>answer.shouldAskForIgnoreURLParametersMatching,
203
- message: START_URL_QUERY_PARAMS_PROMPT,
204
- type: "input"
205
- }
206
- ]);
207
- }
208
- async function askQueryParametersInStartUrl(defaultIgnoredSearchParameters = constants.ignoreURLParametersMatching) {
209
- const { shouldAskForIgnoreURLParametersMatching, ignoreURLParametersMatching = "" } = await askQuestion$2();
210
- if (!shouldAskForIgnoreURLParametersMatching) {
211
- return defaultIgnoredSearchParameters;
212
- }
213
- assert(ignoreURLParametersMatching.length > 0, errors["no-search-parameters-supplied"]);
214
- const ignoreSearchParameters = ignoreURLParametersMatching.trim().split(",").filter(Boolean);
215
- assert(ignoreSearchParameters.length > 0, errors["no-search-parameters-supplied"]);
216
- assert(ignoreSearchParameters.every((param)=>!param.match(/^[^\w|-]/g)), errors["invalid-search-parameters-supplied"]);
217
- return defaultIgnoredSearchParameters.concat(ignoreSearchParameters.map((searchParam)=>new RegExp(`^${searchParam}`)));
218
- }
219
-
220
- const name$1 = "swDest";
221
- function askQuestion$1(defaultDir) {
222
- return inquirer.prompt([
223
- {
224
- name: name$1,
225
- message: "Where would you like your service worker file to be saved?",
176
+ name: "configLocation",
177
+ message: "Where would you like to save these configuration options?",
226
178
  type: "input",
227
- default: upath.join(defaultDir, "sw.js")
228
- }
229
- ]);
230
- }
231
- async function askSWDest(defaultDir = ".") {
232
- const answers = await askQuestion$1(defaultDir);
233
- const swDest = answers[name$1].trim();
234
- assert(swDest, errors["invalid-sw-dest"]);
235
- return swDest;
236
- }
237
-
238
- const name = "swSrc";
239
- function askQuestion() {
240
- return inquirer.prompt([
241
- {
242
- name,
243
- message: oneLine`Where's your existing service worker file? To be used with
244
- injectManifest, it should include a call to
245
- 'self.__SW_MANIFEST'`,
246
- type: "input"
179
+ default: constants.defaultConfigFile,
180
+ validate (input) {
181
+ if (typeof input !== "string") {
182
+ return "You must provide a valid location!";
183
+ }
184
+ return true;
185
+ }
247
186
  }
248
187
  ]);
249
- }
250
- async function askSWSrc() {
251
- const answers = await askQuestion();
252
- return answers[name] ? answers[name].trim() : null;
253
- }
254
-
255
- async function askQuestions(options = {}) {
256
- const isInjectManifest = "injectManifest" in options;
257
- const globDirectory = await askRootOfWebApp();
258
- const globPatterns = await askExtensionsToCache(globDirectory);
259
- const swSrc = isInjectManifest ? await askSWSrc() : undefined;
260
- const swDest = await askSWDest(globDirectory);
261
- const configLocation = await askConfigLocation();
262
- const ignoreURLParametersMatching = isInjectManifest ? undefined : await askQueryParametersInStartUrl();
188
+ const globPatterns = [
189
+ `**/*.${selectedExtensions.length === 1 ? selectedExtensions[0] : `{${selectedExtensions.join(",")}}`}`
190
+ ];
263
191
  const config = {
264
192
  globDirectory,
265
193
  globPatterns,
194
+ swSrc,
266
195
  swDest
267
196
  };
268
- if (swSrc) {
269
- config.swSrc = swSrc;
270
- }
271
- if (ignoreURLParametersMatching) {
272
- config.ignoreURLParametersMatching = ignoreURLParametersMatching;
273
- }
274
197
  return {
275
198
  config,
276
199
  configLocation
277
200
  };
278
- }
201
+ };
279
202
 
280
- async function runWizard(options = {}) {
281
- const { configLocation, config } = await askQuestions(options);
282
- const contents = `module.exports = ${stringifyObject(config)};`;
283
- await fse.writeFile(configLocation, contents);
203
+ async function runWizard() {
204
+ const { configLocation, config } = await askQuestions();
205
+ const contents = `/** @type {import("@serwist/build").InjectManifestOptions} */\nexport default ${stringifyObject(config)};`;
206
+ writeFileSync(configLocation, contents);
284
207
  logger.log(`To build your service worker, run
285
208
 
286
- serwist injectManifest ${configLocation}
209
+ serwist inject-manifest ${configLocation}
287
210
 
288
- as part of a build process. See https://goo.gl/fdTQBf for details.`);
289
- const configDocsURL = "injectManifest" in options ? "https://goo.gl/8bs14N" : "https://goo.gl/gVo87N";
290
- logger.log(oneLine`You can further customize your service worker by making changes
291
- to ${configLocation}. See ${configDocsURL} for details.`);
211
+ as part of a build process.`);
212
+ logger.log(`You can further customize your service worker by making changes to ${configLocation}. See https://serwist.pages.dev/docs/build/configuring for details.`);
292
213
  }
293
214
 
294
- async function runBuildCommand({ config, watch }) {
215
+ const runBuildCommand = async ({ config, watch })=>{
295
216
  const { count, filePaths, size, warnings } = await injectManifest(config);
296
217
  for (const warning of warnings){
297
218
  logger.warn(warning);
@@ -306,27 +227,22 @@ async function runBuildCommand({ config, watch }) {
306
227
  if (watch) {
307
228
  logger.log("\nWatching for changes...");
308
229
  }
309
- }
230
+ };
310
231
  const app = async (params)=>{
311
232
  assert(params && Array.isArray(params.input), errors["missing-input"]);
312
233
  const [command = "help", option] = params.input;
313
234
  switch(command){
314
235
  case "wizard":
315
236
  {
316
- await runWizard(params.flags);
237
+ await runWizard();
317
238
  break;
318
239
  }
319
- case "copyLibraries":
320
- {
321
- logger.log("This feature is under maintenance. We are really sorry for the inconvenience.");
322
- break;
323
- }
324
- case "injectManifest":
240
+ case "inject-manifest":
325
241
  {
326
242
  const configPath = upath.resolve(process.cwd(), option || constants.defaultConfigFile);
327
243
  let config;
328
244
  try {
329
- config = readConfig(configPath);
245
+ config = await readConfig(configPath);
330
246
  } catch (error) {
331
247
  config = null;
332
248
  if (error instanceof Error) {
@@ -384,7 +300,7 @@ const app = async (params)=>{
384
300
  }
385
301
  };
386
302
 
387
- function cleanupStackTrace(error, moduleName) {
303
+ const cleanupStackTrace = (error, moduleName)=>{
388
304
  if (!error.stack) {
389
305
  return "";
390
306
  }
@@ -400,43 +316,34 @@ function cleanupStackTrace(error, moduleName) {
400
316
  }
401
317
  });
402
318
  return frames.slice(startFrame, lastFrame + 1).join("\n");
403
- }
319
+ };
404
320
 
405
321
  const helpText = `Usage:
406
322
  $ serwist <command> [options]
407
323
 
408
324
  Commands:
409
- wizard [--injectManifest]
325
+ wizard
410
326
  Runs the configuration wizard, which will generate a
411
327
  config file based on answers to questions.
412
328
 
413
- injectManifest [<path/to/config.js>] [--watch]
329
+ inject-manifest [<path/to/config.js>] [--watch]
414
330
  Takes an existing service worker file and creates a
415
- copy of it with a precache manifest "injected" into
416
- it. The precache manifest is generated based on the
417
- options in the config file (defaults to serwist.config.js).
418
- If --watch is provided, the CLI will stay running, and will
419
- rebuild the service worker each time a file in the precache
420
- manifest changes.
421
- See https://bit.ly/wb-injectManifest
422
-
423
- copyLibraries <path/to/parent/dir>
424
- Makes a local copy of all of the Workbox libraries inside
425
- a version directory at the location specified. This is intended
426
- for developers using injectManifest who prefer using local,
427
- rather than CDN hosted, libraries.
331
+ copy of it with a precache manifest injected. The precache
332
+ manifest is generated based on the options in the config file
333
+ (defaults to 'serwist.config.js'). If '--watch' is provided, the
334
+ CLI will stay running and rebuild the service worker each
335
+ time a file in the precache manifest changes. See
336
+ https://serwist.pages.dev/docs/cli for more information.
428
337
 
429
- Config file:
430
- In 'injectManifest' mode, the config file should be a
431
- JavaScript file, in CommonJS module format.
432
- By default, a config file named serwist.config.js in the current
433
- directory is assumed, but this can be overridden.
338
+ Configuration file:
339
+ The 'inject-manifest' command expects the configuration
340
+ file to be a JavaScript file. By default, it is assumed
341
+ to be named 'serwist.config.js' and located in the current
342
+ directory, but this can be overridden.
434
343
 
435
344
  Examples:
436
345
  $ serwist wizard
437
- $ serwist wizard --injectManifest
438
- $ serwist injectManifest configs/serwist-dev-config.js
439
- $ serwist copyLibraries build/
346
+ $ serwist inject-manifest configs/serwist-config.js
440
347
  `;
441
348
 
442
349
  void (async ()=>{
@@ -0,0 +1,9 @@
1
+ interface ConfigWithConfigLocation {
2
+ config: {
3
+ [key: string]: any;
4
+ };
5
+ configLocation: string;
6
+ }
7
+ export declare const askQuestions: () => Promise<ConfigWithConfigLocation>;
8
+ export {};
9
+ //# sourceMappingURL=ask-questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-questions.d.ts","sourceRoot":"","sources":["../../src/lib/ask-questions.ts"],"names":[],"mappings":"AAuFA,UAAU,wBAAwB;IAChC,MAAM,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,YAAY,QAAa,QAAQ,wBAAwB,CAsFrE,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function cleanupStackTrace(error: Error, moduleName: string): string;
1
+ export declare const cleanupStackTrace: (error: Error, moduleName: string) => string;
2
2
  //# sourceMappingURL=cleanup-stack-trace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup-stack-trace.d.ts","sourceRoot":"","sources":["../../src/lib/cleanup-stack-trace.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiB1E"}
1
+ {"version":3,"file":"cleanup-stack-trace.d.ts","sourceRoot":"","sources":["../../src/lib/cleanup-stack-trace.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,iBAAiB,UAAW,KAAK,cAAc,MAAM,KAAG,MAiBpE,CAAC"}
@@ -2,6 +2,5 @@ export declare const constants: {
2
2
  defaultConfigFile: string;
3
3
  ignoredDirectories: string[];
4
4
  ignoredFileExtensions: string[];
5
- ignoreURLParametersMatching: RegExp[];
6
5
  };
7
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;CAIrB,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const helpText = "Usage:\n$ serwist <command> [options]\n\nCommands:\n wizard [--injectManifest]\n Runs the configuration wizard, which will generate a\n config file based on answers to questions.\n\n injectManifest [<path/to/config.js>] [--watch]\n Takes an existing service worker file and creates a\n copy of it with a precache manifest \"injected\" into\n it. The precache manifest is generated based on the\n options in the config file (defaults to serwist.config.js).\n If --watch is provided, the CLI will stay running, and will\n rebuild the service worker each time a file in the precache\n manifest changes.\n See https://bit.ly/wb-injectManifest\n\n copyLibraries <path/to/parent/dir>\n Makes a local copy of all of the Workbox libraries inside\n a version directory at the location specified. This is intended\n for developers using injectManifest who prefer using local,\n rather than CDN hosted, libraries.\n\nConfig file:\n In 'injectManifest' mode, the config file should be a\n JavaScript file, in CommonJS module format.\n By default, a config file named serwist.config.js in the current\n directory is assumed, but this can be overridden.\n\nExamples:\n $ serwist wizard\n $ serwist wizard --injectManifest\n $ serwist injectManifest configs/serwist-dev-config.js\n $ serwist copyLibraries build/\n";
1
+ export declare const helpText = "Usage:\n$ serwist <command> [options]\n\nCommands:\n wizard\n Runs the configuration wizard, which will generate a\n config file based on answers to questions.\n\n inject-manifest [<path/to/config.js>] [--watch]\n Takes an existing service worker file and creates a\n copy of it with a precache manifest injected. The precache \n manifest is generated based on the options in the config file \n (defaults to 'serwist.config.js'). If '--watch' is provided, the \n CLI will stay running and rebuild the service worker each \n time a file in the precache manifest changes. See \n https://serwist.pages.dev/docs/cli for more information.\n\nConfiguration file:\n The 'inject-manifest' command expects the configuration \n file to be a JavaScript file. By default, it is assumed \n to be named 'serwist.config.js' and located in the current\n directory, but this can be overridden.\n\nExamples:\n $ serwist wizard\n $ serwist inject-manifest configs/serwist-config.js\n";
2
2
  //# sourceMappingURL=help-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"help-text.d.ts","sourceRoot":"","sources":["../../src/lib/help-text.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,60CAmCpB,CAAC"}
1
+ {"version":3,"file":"help-text.d.ts","sourceRoot":"","sources":["../../src/lib/help-text.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ,4+BA0BpB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import type { InjectManifestOptions } from "@serwist/build";
2
- export declare function readConfig(configFile: string): InjectManifestOptions;
2
+ export declare const readConfig: (configFile: string) => Promise<InjectManifestOptions>;
3
3
  //# sourceMappingURL=read-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read-config.d.ts","sourceRoot":"","sources":["../../src/lib/read-config.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAM5D,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,CAEpE"}
1
+ {"version":3,"file":"read-config.d.ts","sourceRoot":"","sources":["../../src/lib/read-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAO,MAAM,UAAU,eAAsB,MAAM,KAAG,QAAQ,qBAAqB,CAElF,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function runWizard(options?: {}): Promise<void>;
1
+ export declare function runWizard(): Promise<void>;
2
2
  //# sourceMappingURL=run-wizard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-wizard.d.ts","sourceRoot":"","sources":["../../src/lib/run-wizard.ts"],"names":[],"mappings":"AAeA,wBAAsB,SAAS,CAAC,OAAO,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB3D"}
1
+ {"version":3,"file":"run-wizard.d.ts","sourceRoot":"","sources":["../../src/lib/run-wizard.ts"],"names":[],"mappings":"AAaA,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAgB/C"}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@serwist/cli",
3
- "version": "9.0.0-preview.9",
3
+ "version": "9.0.0",
4
4
  "type": "module",
5
- "description": "@serwist/cli is the command line interface for Serwist.",
5
+ "description": "The command line interface of Serwist.",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "cli.js"
8
9
  ],
9
10
  "keywords": [
10
11
  "serwist",
@@ -20,26 +21,25 @@
20
21
  },
21
22
  "author": "Google's Web DevRel Team, Serwist's Team",
22
23
  "license": "MIT",
23
- "repository": "serwist/serwist",
24
+ "repository": "https://github.com/serwist/serwist",
24
25
  "bugs": "https://github.com/serwist/serwist/issues",
25
- "homepage": "https://github.com/serwist/serwist",
26
+ "homepage": "https://serwist.pages.dev",
26
27
  "bin": {
27
- "serwist": "dist/bin.js"
28
+ "serwist": "cli.js"
28
29
  },
29
30
  "dependencies": {
30
31
  "chalk": "5.3.0",
31
- "chokidar": "3.5.3",
32
+ "chokidar": "3.6.0",
32
33
  "common-tags": "1.8.2",
33
34
  "fs-extra": "11.2.0",
34
- "glob": "10.3.10",
35
- "inquirer": "9.2.14",
36
- "meow": "13.1.0",
37
- "ora": "8.0.1",
35
+ "glob": "10.3.12",
36
+ "inquirer": "9.2.18",
37
+ "meow": "13.2.0",
38
38
  "pretty-bytes": "6.1.1",
39
39
  "stringify-object": "5.0.0",
40
40
  "upath": "2.0.1",
41
41
  "update-notifier": "7.0.0",
42
- "@serwist/build": "9.0.0-preview.9"
42
+ "@serwist/build": "9.0.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/common-tags": "1.8.4",
@@ -47,17 +47,9 @@
47
47
  "@types/inquirer": "9.0.7",
48
48
  "@types/stringify-object": "4.0.5",
49
49
  "@types/update-notifier": "6.0.8",
50
- "rollup": "4.9.6",
51
- "typescript": "5.4.0-dev.20240206",
52
- "@serwist/constants": "9.0.0-preview.9"
53
- },
54
- "peerDependencies": {
55
- "typescript": ">=5.0.0"
56
- },
57
- "peerDependenciesMeta": {
58
- "typescript": {
59
- "optional": true
60
- }
50
+ "rollup": "4.14.3",
51
+ "typescript": "5.5.0-dev.20240415",
52
+ "@serwist/configs": "9.0.0"
61
53
  },
62
54
  "scripts": {
63
55
  "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
@@ -1,2 +0,0 @@
1
- export declare function askConfigLocation(): Promise<string>;
2
- //# sourceMappingURL=ask-config-location.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-config-location.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-config-location.ts"],"names":[],"mappings":"AAgCA,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CASzD"}
@@ -1,2 +0,0 @@
1
- export declare function askExtensionsToCache(globDirectory: string): Promise<string[]>;
2
- //# sourceMappingURL=ask-extensions-to-cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-extensions-to-cache.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-extensions-to-cache.ts"],"names":[],"mappings":"AA8EA,wBAAsB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAWnF"}
@@ -1,9 +0,0 @@
1
- interface ConfigWithConfigLocation {
2
- config: {
3
- [key: string]: any;
4
- };
5
- configLocation: string;
6
- }
7
- export declare function askQuestions(options?: {}): Promise<ConfigWithConfigLocation>;
8
- export {};
9
- //# sourceMappingURL=ask-questions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-questions.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-questions.ts"],"names":[],"mappings":"AAeA,UAAU,wBAAwB;IAChC,MAAM,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAsB,YAAY,CAAC,OAAO,KAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA6BlF"}
@@ -1,2 +0,0 @@
1
- export declare function askRootOfWebApp(): Promise<string>;
2
- //# sourceMappingURL=ask-root-of-web-app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-root-of-web-app.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-root-of-web-app.ts"],"names":[],"mappings":"AAqEA,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAWvD"}
@@ -1,2 +0,0 @@
1
- export declare function askQueryParametersInStartUrl(defaultIgnoredSearchParameters?: RegExp[]): Promise<RegExp[]>;
2
- //# sourceMappingURL=ask-start_url-query-params.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-start_url-query-params.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-start_url-query-params.ts"],"names":[],"mappings":"AA8CA,wBAAsB,4BAA4B,CAChD,8BAA8B,GAAE,MAAM,EAA0C,GAC/E,OAAO,CAAC,MAAM,EAAE,CAAC,CAkBnB"}
@@ -1,2 +0,0 @@
1
- export declare function askSWDest(defaultDir?: string): Promise<string>;
2
- //# sourceMappingURL=ask-sw-dest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-sw-dest.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-sw-dest.ts"],"names":[],"mappings":"AAiCA,wBAAsB,SAAS,CAAC,UAAU,SAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASjE"}
@@ -1,2 +0,0 @@
1
- export declare function askSWSrc(): Promise<string | null>;
2
- //# sourceMappingURL=ask-sw-src.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ask-sw-src.d.ts","sourceRoot":"","sources":["../../../src/lib/questions/ask-sw-src.ts"],"names":[],"mappings":"AA8BA,wBAAsB,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIvD"}