@serwist/cli 9.3.0 → 9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAyC/C,eAAO,MAAM,GAAG,GAAU,QAAQ,UAAU,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,IAAI,CAkF1E,CAAC"}
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;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ/C,eAAO,MAAM,GAAG,GAAU,QAAQ,UAAU,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,IAAI,CA+G1E,CAAC"}
package/dist/bin.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- #! /usr/bin/env node
2
1
  import type { AnyFlags, BooleanFlag } from "./types.js";
3
2
  export interface SupportedFlags extends AnyFlags {
4
3
  debug: BooleanFlag;
package/dist/bin.d.ts.map CHANGED
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAeA,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,59 +1,21 @@
1
- #! /usr/bin/env node
2
1
  import meow from 'meow';
3
2
  import updateNotifier from 'update-notifier';
4
3
  import assert from 'node:assert';
5
4
  import path from 'node:path';
6
5
  import { pathToFileURL } from 'node:url';
7
- import { injectManifest } from '@serwist/build';
8
6
  import chokidar from 'chokidar';
9
7
  import { glob } from 'glob';
10
- import prettyBytes from 'pretty-bytes';
11
- import { oneLine } from 'common-tags';
12
- import chalk from 'chalk';
8
+ import { e as errors, l as logger, a as runInjectManifestCommand, r as runBuildCommand } from './chunks/errors.js';
9
+ import { c as constants } from './chunks/constants.js';
13
10
  import { statSync, writeFileSync } from 'node:fs';
14
11
  import stringifyObject from 'stringify-object';
15
12
  import { input, checkbox, select, Separator } from '@inquirer/prompts';
16
-
17
- const constants = {
18
- defaultConfigFile: "serwist.config.js",
19
- ignoredDirectories: [
20
- "node_modules"
21
- ],
22
- ignoredFileExtensions: [
23
- "map"
24
- ]
25
- };
26
-
27
- const errors = {
28
- "missing-input": "params.input value was not set properly.",
29
- "missing-dest-dir-param": oneLine`Please provide the path to a directory in which
30
- the libraries will be copied.`,
31
- "invalid-common-js-module": oneLine`Please pass in a valid CommonJS module that
32
- exports your configuration.`,
33
- "unknown-command": "Unknown command:",
34
- "no-file-extensions-found": oneLine`No files could be found that are suitable for
35
- caching.`,
36
- "no-file-extensions-selected": "Please select at least one file extension.",
37
- "invalid-sw-dest": oneLine`Please enter a valid path to use for the service worker
38
- file that's created.`,
39
- "glob-directory-invalid": oneLine`The path you entered isn't a valid directory.`,
40
- "invalid-config-location": oneLine`Please enter a valid path to use for the saved
41
- configuration file.`,
42
- "sw-src-missing-injection-point": oneLine`That is not a valid source service worker
43
- file. Please try again with a file containing
44
- 'self.__SW_MANIFEST'.`,
45
- "no-search-parameters-supplied": oneLine`Please provide the url search param(s)
46
- you would like to ignore.`,
47
- "invalid-search-parameters-supplied": oneLine`Please provide the valid URL search parameter(s)
48
- without the leading '/' or '?' (i.e. source,version,language).`
49
- };
50
-
51
- const logger = {
52
- debug: (...args)=>console.log(chalk.gray(...args)),
53
- log: (...args)=>console.log(...args),
54
- warn: (...args)=>console.warn(chalk.yellow(...args)),
55
- error: (...args)=>console.error(chalk.red.bold(...args))
56
- };
13
+ import '@serwist/build';
14
+ import 'pretty-bytes';
15
+ import 'chalk';
16
+ import 'common-tags';
17
+ import '@serwist/build/schema';
18
+ import 'zod';
57
19
 
58
20
  const readConfig = async (configFile)=>{
59
21
  return (await import(configFile)).default;
@@ -210,31 +172,41 @@ as part of a build process.`);
210
172
  logger.log(`You can further customize your service worker by making changes to ${configLocation}. See https://serwist.pages.dev/docs/build/configuring for details.`);
211
173
  }
212
174
 
213
- const runBuildCommand = async ({ config, watch })=>{
214
- const { count, filePaths, size, warnings } = await injectManifest(config);
215
- for (const warning of warnings){
216
- logger.warn(warning);
217
- }
218
- if (filePaths.length === 1) {
219
- logger.log(`The service worker file was written to ${config.swDest}`);
220
- } else {
221
- const message = filePaths.sort().map((filePath)=>` • ${filePath}`).join("\n");
222
- logger.log(`The service worker files were written to:\n${message}`);
223
- }
224
- logger.log(`The service worker will precache ${count} URLs, ` + `totaling ${prettyBytes(size)}.`);
225
- if (watch) {
226
- logger.log("\nWatching for changes...");
227
- }
228
- };
229
175
  const app = async (params)=>{
230
176
  assert(params && Array.isArray(params.input), errors["missing-input"]);
231
177
  const [command = "help", option] = params.input;
178
+ process.env.SERWIST_ENV = params.flags.watch ? "watch" : "build";
179
+ process.env.NODE_ENV = params.flags.watch ? "development" : "production";
232
180
  switch(command){
233
181
  case "wizard":
234
182
  {
235
183
  await runWizard();
236
184
  break;
237
185
  }
186
+ case "build":
187
+ {
188
+ const configPath = path.resolve(process.cwd(), option || constants.defaultConfigFile);
189
+ const configUrl = pathToFileURL(configPath).href;
190
+ let config;
191
+ try {
192
+ config = await readConfig(configUrl);
193
+ } catch (error) {
194
+ config = null;
195
+ if (error instanceof Error) {
196
+ logger.error(errors["invalid-common-js-module"]);
197
+ throw error;
198
+ }
199
+ }
200
+ if (config === null) {
201
+ throw logger.error(errors["invalid-config-location"]);
202
+ }
203
+ logger.log(`Using configuration from ${configPath}.`);
204
+ await runBuildCommand({
205
+ config,
206
+ watch: !!params.flags.watch
207
+ });
208
+ break;
209
+ }
238
210
  case "inject-manifest":
239
211
  {
240
212
  const configPath = path.resolve(process.cwd(), option || constants.defaultConfigFile);
@@ -253,7 +225,7 @@ const app = async (params)=>{
253
225
  throw logger.error(errors["invalid-config-location"]);
254
226
  }
255
227
  logger.log(`Using configuration from ${configPath}.`);
256
- if (params?.flags?.watch) {
228
+ if (params.flags.watch) {
257
229
  if (config.globPatterns) {
258
230
  chokidar.watch(await glob(config.globPatterns, {
259
231
  cwd: config.globDirectory,
@@ -264,13 +236,13 @@ const app = async (params)=>{
264
236
  cwd: config.globDirectory
265
237
  }).on("all", async ()=>{
266
238
  if (config === null) return;
267
- await runBuildCommand({
239
+ await runInjectManifestCommand({
268
240
  config,
269
241
  watch: true
270
242
  });
271
243
  }).on("ready", async ()=>{
272
244
  if (config === null) return;
273
- await runBuildCommand({
245
+ await runInjectManifestCommand({
274
246
  config,
275
247
  watch: true
276
248
  });
@@ -279,7 +251,7 @@ const app = async (params)=>{
279
251
  });
280
252
  }
281
253
  } else {
282
- await runBuildCommand({
254
+ await runInjectManifestCommand({
283
255
  config,
284
256
  watch: false
285
257
  });
@@ -0,0 +1,84 @@
1
+ import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
2
+ import z from 'zod';
3
+
4
+ const validateBuildOptions = async (input)=>{
5
+ const result = await (await import('./schema.js')).buildOptions.spa(input, {
6
+ error: validationErrorMap
7
+ });
8
+ if (!result.success) {
9
+ throw new SerwistConfigError({
10
+ moduleName: "@serwist/cli",
11
+ message: z.prettifyError(result.error)
12
+ });
13
+ }
14
+ return result.data;
15
+ };
16
+
17
+ const constants = {
18
+ defaultConfigFile: "serwist.config.js",
19
+ ignoredDirectories: [
20
+ "node_modules"
21
+ ],
22
+ ignoredFileExtensions: [
23
+ "map"
24
+ ]
25
+ };
26
+ const SUPPORTED_ESBUILD_OPTIONS = [
27
+ "sourcemap",
28
+ "legalComments",
29
+ "sourceRoot",
30
+ "sourcesContent",
31
+ "format",
32
+ "globalName",
33
+ "target",
34
+ "supported",
35
+ "define",
36
+ "treeShaking",
37
+ "minify",
38
+ "mangleProps",
39
+ "reserveProps",
40
+ "mangleQuoted",
41
+ "mangleCache",
42
+ "drop",
43
+ "dropLabels",
44
+ "minifyWhitespace",
45
+ "minifyIdentifiers",
46
+ "minifySyntax",
47
+ "lineLimit",
48
+ "charset",
49
+ "ignoreAnnotations",
50
+ "jsx",
51
+ "jsxFactory",
52
+ "jsxFragment",
53
+ "jsxImportSource",
54
+ "jsxDev",
55
+ "jsxSideEffects",
56
+ "pure",
57
+ "keepNames",
58
+ "absPaths",
59
+ "color",
60
+ "logLevel",
61
+ "logLimit",
62
+ "logOverride",
63
+ "tsconfigRaw",
64
+ "bundle",
65
+ "splitting",
66
+ "preserveSymlinks",
67
+ "external",
68
+ "packages",
69
+ "alias",
70
+ "loader",
71
+ "resolveExtensions",
72
+ "mainFields",
73
+ "conditions",
74
+ "allowOverwrite",
75
+ "tsconfig",
76
+ "outExtension",
77
+ "publicPath",
78
+ "inject",
79
+ "banner",
80
+ "footer",
81
+ "plugins"
82
+ ];
83
+
84
+ export { SUPPORTED_ESBUILD_OPTIONS as S, constants as c, validateBuildOptions as v };
@@ -0,0 +1,152 @@
1
+ import path from 'node:path';
2
+ import { injectManifest, getFileManifestEntries } from '@serwist/build';
3
+ import chokidar from 'chokidar';
4
+ import { glob } from 'glob';
5
+ import prettyBytes from 'pretty-bytes';
6
+ import chalk from 'chalk';
7
+ import { v as validateBuildOptions } from './constants.js';
8
+ import { oneLine } from 'common-tags';
9
+
10
+ const logger = {
11
+ debug: (...args)=>console.log(chalk.gray(...args)),
12
+ log: (...args)=>console.log(...args),
13
+ warn: (...args)=>console.warn(chalk.yellow(...args)),
14
+ error: (...args)=>console.error(chalk.red.bold(...args))
15
+ };
16
+
17
+ const runInjectManifestCommand = async ({ config, watch })=>{
18
+ const { count, filePaths, size, warnings } = await injectManifest(config);
19
+ for (const warning of warnings){
20
+ logger.warn(warning);
21
+ }
22
+ if (filePaths.length === 1) {
23
+ logger.log(`The service worker file was written to ${config.swDest}.`);
24
+ } else {
25
+ const message = filePaths.sort().map((filePath)=>` • ${filePath}`).join("\n");
26
+ logger.log(`The service worker files were written to:\n${message}`);
27
+ }
28
+ if (count > 0) {
29
+ logger.log(`The service worker will precache ${count} URLs, ` + `totaling ${prettyBytes(size)}.`);
30
+ }
31
+ if (watch) {
32
+ logger.log("\nWatching for changes...");
33
+ }
34
+ };
35
+ const runBuildCommand = async ({ config, watch })=>{
36
+ const options = await validateBuildOptions(config);
37
+ const { count, manifestEntries, size, warnings } = await getFileManifestEntries(options);
38
+ for (const warning of warnings){
39
+ logger.warn(warning);
40
+ }
41
+ const manifestString = manifestEntries === undefined ? "undefined" : JSON.stringify(manifestEntries, null, 2);
42
+ let esbuild;
43
+ try {
44
+ esbuild = await import('esbuild');
45
+ } catch (err) {
46
+ throw logger.error(`${err}\nThis command needs esbuild. Install it using "npm i esbuild".`);
47
+ }
48
+ const parsedDest = path.parse(config.swDest);
49
+ const esbuildContext = await esbuild.context({
50
+ metafile: true,
51
+ sourcemap: watch,
52
+ format: "esm",
53
+ target: [
54
+ "chrome64",
55
+ "edge79",
56
+ "firefox67",
57
+ "opera51",
58
+ "safari12"
59
+ ],
60
+ treeShaking: true,
61
+ minify: !watch,
62
+ bundle: true,
63
+ ...options.esbuildOptions,
64
+ platform: "browser",
65
+ define: {
66
+ ...options.esbuildOptions.define,
67
+ ...options.injectionPoint ? {
68
+ [options.injectionPoint]: manifestString
69
+ } : {}
70
+ },
71
+ outdir: parsedDest.dir,
72
+ entryNames: "[name]",
73
+ assetNames: "[name]-[hash]",
74
+ chunkNames: "[name]-[hash]",
75
+ entryPoints: [
76
+ {
77
+ in: config.swSrc,
78
+ out: parsedDest.name
79
+ }
80
+ ]
81
+ });
82
+ const rebuild = async ()=>{
83
+ const result = await esbuildContext.rebuild();
84
+ const filePaths = Object.keys(result.metafile.outputs);
85
+ if (filePaths.length === 1) {
86
+ logger.log(`The service worker file was written to ${config.swDest}.`);
87
+ } else {
88
+ const message = filePaths.sort().map((filePath)=>` • ${filePath}`).join("\n");
89
+ logger.log(`The service worker files were written to:\n${message}`);
90
+ }
91
+ if (count > 0) {
92
+ logger.log(`The service worker will precache ${count} URLs, ` + `totaling ${prettyBytes(size)}.`);
93
+ }
94
+ if (watch) {
95
+ logger.log("\nWatching for changes...");
96
+ }
97
+ };
98
+ if (watch) {
99
+ if (config.globPatterns) {
100
+ chokidar.watch([
101
+ config.swSrc,
102
+ ...config.disablePrecacheManifest ? [] : await glob(config.globPatterns, {
103
+ cwd: config.globDirectory,
104
+ follow: config.globFollow,
105
+ ignore: config.globIgnores
106
+ })
107
+ ], {
108
+ ignoreInitial: true,
109
+ cwd: config.globDirectory
110
+ }).on("all", async ()=>{
111
+ if (config === null) return;
112
+ await rebuild();
113
+ }).on("ready", async ()=>{
114
+ if (config === null) return;
115
+ await rebuild();
116
+ }).on("error", (err)=>{
117
+ logger.error(err instanceof Error ? err.toString() : "Unknown error");
118
+ });
119
+ }
120
+ } else {
121
+ await rebuild();
122
+ await esbuildContext.dispose();
123
+ }
124
+ };
125
+
126
+ const errors = {
127
+ "missing-input": "params.input value was not set properly.",
128
+ "missing-dest-dir-param": oneLine`Please provide the path to a directory in which
129
+ the libraries will be copied.`,
130
+ "invalid-common-js-module": oneLine`Please pass in a valid CommonJS module that
131
+ exports your configuration.`,
132
+ "config-validation-failed": "Your configuration is invalid:",
133
+ "serwist-build-runtime-error": "Service worker generation failed:",
134
+ "unknown-command": "Unknown command:",
135
+ "no-file-extensions-found": oneLine`No files could be found that are suitable for
136
+ caching.`,
137
+ "no-file-extensions-selected": "Please select at least one file extension.",
138
+ "invalid-sw-dest": oneLine`Please enter a valid path to use for the service worker
139
+ file that's created.`,
140
+ "glob-directory-invalid": oneLine`The path you entered isn't a valid directory.`,
141
+ "invalid-config-location": oneLine`Please enter a valid path to use for the saved
142
+ configuration file.`,
143
+ "sw-src-missing-injection-point": oneLine`That is not a valid source service worker
144
+ file. Please try again with a file containing
145
+ 'self.__SW_MANIFEST'.`,
146
+ "no-search-parameters-supplied": oneLine`Please provide the url search param(s)
147
+ you would like to ignore.`,
148
+ "invalid-search-parameters-supplied": oneLine`Please provide the valid URL search parameter(s)
149
+ without the leading '/' or '?' (i.e. source,version,language).`
150
+ };
151
+
152
+ export { runInjectManifestCommand as a, errors as e, logger as l, runBuildCommand as r };
@@ -0,0 +1,13 @@
1
+ import { injectManifestOptions } from '@serwist/build/schema';
2
+ import z from 'zod';
3
+ import { S as SUPPORTED_ESBUILD_OPTIONS } from './constants.js';
4
+
5
+ const buildPartial = z.strictObject({
6
+ esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({})
7
+ });
8
+ const buildOptions = z.strictObject({
9
+ ...injectManifestOptions.shape,
10
+ ...buildPartial.shape
11
+ });
12
+
13
+ export { buildOptions, buildPartial };
@@ -0,0 +1,5 @@
1
+ export { type BuildCommand, type InjectManifestCommand, runBuildCommand, runInjectManifestCommand } from "./lib/build.js";
2
+ export { constants, SUPPORTED_ESBUILD_OPTIONS } from "./lib/constants.js";
3
+ export { errors } from "./lib/errors.js";
4
+ export type * from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,qBAAqB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1H,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,mBAAmB,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export { e as errors, r as runBuildCommand, a as runInjectManifestCommand } from './chunks/errors.js';
2
+ export { S as SUPPORTED_ESBUILD_OPTIONS, c as constants } from './chunks/constants.js';
3
+ import 'node:path';
4
+ import '@serwist/build';
5
+ import 'chokidar';
6
+ import 'glob';
7
+ import 'pretty-bytes';
8
+ import 'chalk';
9
+ import 'common-tags';
10
+ import '@serwist/build/schema';
11
+ import 'zod';
@@ -0,0 +1,3 @@
1
+ export { buildOptions, buildPartial } from "./lib/schema.js";
2
+ export { validateBuildOptions } from "./lib/validation.js";
3
+ //# sourceMappingURL=index.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { buildOptions, buildPartial } from './chunks/schema.js';
2
+ export { v as validateBuildOptions } from './chunks/constants.js';
3
+ import '@serwist/build/schema';
4
+ import 'zod';
@@ -0,0 +1,18 @@
1
+ import { type InjectManifestOptions } from "@serwist/build";
2
+ import type { BuildOptions } from "../types.js";
3
+ export interface InjectManifestCommand {
4
+ watch: boolean;
5
+ config: InjectManifestOptions;
6
+ }
7
+ /**
8
+ * Runs the specified build command with the provided configuration.
9
+ *
10
+ * @param options
11
+ */
12
+ export declare const runInjectManifestCommand: ({ config, watch }: InjectManifestCommand) => Promise<void>;
13
+ export interface BuildCommand {
14
+ config: BuildOptions;
15
+ watch: boolean;
16
+ }
17
+ export declare const runBuildCommand: ({ config, watch }: BuildCommand) => Promise<void>;
18
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/lib/build.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,qBAAqB,EAAkB,MAAM,gBAAgB,CAAC;AAKpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAU,mBAAmB,qBAAqB,kBAwBtF,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,GAAU,mBAAmB,YAAY,kBAuGpE,CAAC"}
@@ -3,4 +3,5 @@ export declare const constants: {
3
3
  ignoredDirectories: string[];
4
4
  ignoredFileExtensions: string[];
5
5
  };
6
+ export declare const SUPPORTED_ESBUILD_OPTIONS: readonly ["sourcemap", "legalComments", "sourceRoot", "sourcesContent", "format", "globalName", "target", "supported", "define", "treeShaking", "minify", "mangleProps", "reserveProps", "mangleQuoted", "mangleCache", "drop", "dropLabels", "minifyWhitespace", "minifyIdentifiers", "minifySyntax", "lineLimit", "charset", "ignoreAnnotations", "jsx", "jsxFactory", "jsxFragment", "jsxImportSource", "jsxDev", "jsxSideEffects", "pure", "keepNames", "absPaths", "color", "logLevel", "logLimit", "logOverride", "tsconfigRaw", "bundle", "splitting", "preserveSymlinks", "external", "packages", "alias", "loader", "resolveExtensions", "mainFields", "conditions", "allowOverwrite", "tsconfig", "outExtension", "publicPath", "inject", "banner", "footer", "plugins"];
6
7
  //# 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;;;;CAIrB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAEF,eAAO,MAAM,yBAAyB,ovBA0Dc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAwBlB,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;CAwBlB,CAAC"}
@@ -0,0 +1,79 @@
1
+ import z from "zod";
2
+ export declare const buildPartial: z.ZodObject<{
3
+ esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
4
+ }, z.z.core.$strict>;
5
+ export declare const buildOptions: z.ZodObject<{
6
+ esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
7
+ globDirectory: z.ZodString;
8
+ swDest: z.ZodString;
9
+ injectionPoint: z.ZodDefault<z.ZodString>;
10
+ swSrc: z.ZodString;
11
+ globFollow: z.ZodDefault<z.ZodBoolean>;
12
+ globIgnores: z.ZodDefault<z.ZodArray<z.ZodString>>;
13
+ globPatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
14
+ globStrict: z.ZodDefault<z.ZodBoolean>;
15
+ templatedURLs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
16
+ additionalPrecacheEntries: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
17
+ integrity: z.ZodOptional<z.ZodString>;
18
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ url: z.ZodString;
20
+ }, z.z.core.$strict>]>>>;
21
+ disablePrecacheManifest: z.ZodDefault<z.ZodBoolean>;
22
+ dontCacheBustURLsMatching: z.ZodOptional<z.ZodCustom<RegExp, RegExp>>;
23
+ manifestTransforms: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodCustom<z.z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
24
+ size: z.ZodNumber;
25
+ integrity: z.ZodOptional<z.ZodString>;
26
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ url: z.ZodString;
28
+ }, z.z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
29
+ manifest: z.ZodArray<z.ZodObject<{
30
+ size: z.ZodNumber;
31
+ integrity: z.ZodOptional<z.ZodString>;
32
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ url: z.ZodString;
34
+ }, z.z.core.$strip>>;
35
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ }, z.z.core.$strict>>, z.z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
37
+ size: z.ZodNumber;
38
+ integrity: z.ZodOptional<z.ZodString>;
39
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
+ url: z.ZodString;
41
+ }, z.z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
42
+ manifest: z.ZodArray<z.ZodObject<{
43
+ size: z.ZodNumber;
44
+ integrity: z.ZodOptional<z.ZodString>;
45
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ url: z.ZodString;
47
+ }, z.z.core.$strip>>;
48
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
49
+ }, z.z.core.$strict>>>, z.ZodTransform<z.z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
50
+ size: z.ZodNumber;
51
+ integrity: z.ZodOptional<z.ZodString>;
52
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ url: z.ZodString;
54
+ }, z.z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
55
+ manifest: z.ZodArray<z.ZodObject<{
56
+ size: z.ZodNumber;
57
+ integrity: z.ZodOptional<z.ZodString>;
58
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ url: z.ZodString;
60
+ }, z.z.core.$strip>>;
61
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
+ }, z.z.core.$strict>>, z.z.core.$InferInnerFunctionTypeAsync<z.ZodTuple<[z.ZodArray<z.ZodObject<{
63
+ size: z.ZodNumber;
64
+ integrity: z.ZodOptional<z.ZodString>;
65
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ url: z.ZodString;
67
+ }, z.z.core.$strip>>, z.ZodOptional<z.ZodUnknown>], null>, z.ZodObject<{
68
+ manifest: z.ZodArray<z.ZodObject<{
69
+ size: z.ZodNumber;
70
+ integrity: z.ZodOptional<z.ZodString>;
71
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ url: z.ZodString;
73
+ }, z.z.core.$strip>>;
74
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ }, z.z.core.$strict>>>>>>;
76
+ maximumFileSizeToCacheInBytes: z.ZodDefault<z.ZodNumber>;
77
+ modifyURLPrefix: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
78
+ }, z.z.core.$strict>;
79
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/lib/schema.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,YAAY;;oBAEvB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAGvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BuildOptionsComplete } from "../types.js";
2
+ export declare const validateBuildOptions: (input: unknown) => Promise<BuildOptionsComplete>;
3
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,oBAAoB,GAAU,OAAO,OAAO,KAAG,OAAO,CAAC,oBAAoB,CASvF,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,23 @@
1
+ import type { InjectManifestOptions, InjectManifestOptionsComplete } from "@serwist/build";
2
+ import type { Prettify, Require } from "@serwist/utils";
3
+ import type { BuildOptions as BaseEsbuildOptions } from "esbuild";
1
4
  import type { Flag } from "meow";
5
+ import type { SUPPORTED_ESBUILD_OPTIONS } from "./lib/constants.js";
2
6
  export type StringFlag = Flag<"string", string> | Flag<"string", string[], true>;
3
7
  export type BooleanFlag = Flag<"boolean", boolean> | Flag<"boolean", boolean[], true>;
4
8
  export type NumberFlag = Flag<"number", number> | Flag<"number", number[], true>;
5
9
  export type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
6
10
  export type AnyFlags = Record<string, AnyFlag>;
11
+ export type EsbuildSupportedOptions = (typeof SUPPORTED_ESBUILD_OPTIONS)[number];
12
+ export type EsbuildOptions = Pick<BaseEsbuildOptions, EsbuildSupportedOptions>;
13
+ export interface BuildPartial {
14
+ /**
15
+ * Options to configure the esbuild instance used to bundle
16
+ * the service worker.
17
+ */
18
+ esbuildOptions?: EsbuildOptions;
19
+ }
20
+ export type BuildResolved = Require<BuildPartial, "esbuildOptions">;
21
+ export type BuildOptions = Prettify<InjectManifestOptions & BuildPartial>;
22
+ export type BuildOptionsComplete = Prettify<InjectManifestOptionsComplete & BuildResolved>;
7
23
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;AACtF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAC5D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;AACtF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;AACjF,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAC5D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAEpE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,qBAAqB,GAAG,YAAY,CAAC,CAAC;AAE1E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,6BAA6B,GAAG,aAAa,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/cli",
3
- "version": "9.3.0",
3
+ "version": "9.3.1",
4
4
  "type": "module",
5
5
  "description": "The command line interface of Serwist.",
6
6
  "files": [
@@ -27,6 +27,26 @@
27
27
  "repository": "https://github.com/serwist/serwist",
28
28
  "bugs": "https://github.com/serwist/serwist/issues",
29
29
  "homepage": "https://serwist.pages.dev",
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "typesVersions": {
33
+ "*": {
34
+ "schema": [
35
+ "./dist/index.schema.d.ts"
36
+ ]
37
+ }
38
+ },
39
+ "exports": {
40
+ ".": {
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.js"
43
+ },
44
+ "./schema": {
45
+ "types": "./dist/index.schema.d.ts",
46
+ "default": "./dist/index.schema.js"
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
30
50
  "bin": {
31
51
  "serwist": "cli.js"
32
52
  },
@@ -40,17 +60,27 @@
40
60
  "pretty-bytes": "6.1.1",
41
61
  "stringify-object": "6.0.0",
42
62
  "update-notifier": "7.3.1",
43
- "@serwist/build": "9.3.0"
63
+ "zod": "4.2.1",
64
+ "@serwist/build": "9.3.1"
44
65
  },
45
66
  "devDependencies": {
46
67
  "@types/common-tags": "1.8.4",
47
68
  "@types/inquirer": "9.0.9",
48
69
  "@types/stringify-object": "4.0.5",
49
70
  "@types/update-notifier": "6.0.8",
71
+ "esbuild": "0.27.2",
50
72
  "rollup": "4.54.0",
51
73
  "typescript": "5.9.3",
52
- "@serwist/configs": "9.3.0",
53
- "@serwist/utils": "9.3.0"
74
+ "@serwist/configs": "9.3.1",
75
+ "@serwist/utils": "9.3.1"
76
+ },
77
+ "peerDependencies": {
78
+ "esbuild": ">=0.25.0 <1.0.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "esbuild": {
82
+ "optional": true
83
+ }
54
84
  },
55
85
  "scripts": {
56
86
  "build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",