@serwist/cli 9.0.0-preview.8 → 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.
- package/cli.js +3 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/bin.d.ts +0 -1
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +133 -226
- package/dist/lib/ask-questions.d.ts +9 -0
- package/dist/lib/ask-questions.d.ts.map +1 -0
- package/dist/lib/cleanup-stack-trace.d.ts +1 -1
- package/dist/lib/cleanup-stack-trace.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/help-text.d.ts +1 -1
- package/dist/lib/help-text.d.ts.map +1 -1
- package/dist/lib/read-config.d.ts +1 -1
- package/dist/lib/read-config.d.ts.map +1 -1
- package/dist/lib/run-wizard.d.ts +1 -1
- package/dist/lib/run-wizard.d.ts.map +1 -1
- package/package.json +15 -23
- package/dist/lib/questions/ask-config-location.d.ts +0 -2
- package/dist/lib/questions/ask-config-location.d.ts.map +0 -1
- package/dist/lib/questions/ask-extensions-to-cache.d.ts +0 -2
- package/dist/lib/questions/ask-extensions-to-cache.d.ts.map +0 -1
- package/dist/lib/questions/ask-questions.d.ts +0 -9
- package/dist/lib/questions/ask-questions.d.ts.map +0 -1
- package/dist/lib/questions/ask-root-of-web-app.d.ts +0 -2
- package/dist/lib/questions/ask-root-of-web-app.d.ts.map +0 -1
- package/dist/lib/questions/ask-start_url-query-params.d.ts +0 -2
- package/dist/lib/questions/ask-start_url-query-params.d.ts.map +0 -1
- package/dist/lib/questions/ask-sw-dest.d.ts +0 -2
- package/dist/lib/questions/ask-sw-dest.d.ts.map +0 -1
- package/dist/lib/questions/ask-sw-src.d.ts +0 -2
- package/dist/lib/questions/ask-sw-src.d.ts.map +0 -1
package/cli.js
ADDED
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
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
package/dist/bin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";
|
|
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 {
|
|
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
|
|
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
|
|
66
|
-
|
|
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
|
|
90
|
-
|
|
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
|
|
111
|
-
const
|
|
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
|
-
|
|
128
|
+
const { swSrc, swDest, selectedExtensions, configLocation } = await inquirer.prompt([
|
|
119
129
|
{
|
|
120
|
-
name:
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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:
|
|
202
|
-
|
|
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:
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
251
|
-
|
|
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(
|
|
281
|
-
const { configLocation, config } = await askQuestions(
|
|
282
|
-
const contents =
|
|
283
|
-
|
|
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
|
|
209
|
+
serwist inject-manifest ${configLocation}
|
|
287
210
|
|
|
288
|
-
as part of a build process
|
|
289
|
-
|
|
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
|
|
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(
|
|
237
|
+
await runWizard();
|
|
317
238
|
break;
|
|
318
239
|
}
|
|
319
|
-
case "
|
|
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
|
-
|
|
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
|
|
325
|
+
wizard
|
|
410
326
|
Runs the configuration wizard, which will generate a
|
|
411
327
|
config file based on answers to questions.
|
|
412
328
|
|
|
413
|
-
|
|
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
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
-
|
|
430
|
-
|
|
431
|
-
JavaScript file,
|
|
432
|
-
|
|
433
|
-
directory
|
|
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
|
|
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 @@
|
|
|
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
|
|
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,
|
|
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"}
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,SAAS;;;;CAIrB,CAAC"}
|
package/dist/lib/help-text.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const helpText = "Usage:\n$ serwist <command> [options]\n\nCommands:\n wizard
|
|
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,
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/lib/run-wizard.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function runWizard(
|
|
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":"
|
|
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
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
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://
|
|
26
|
+
"homepage": "https://serwist.pages.dev",
|
|
26
27
|
"bin": {
|
|
27
|
-
"serwist": "
|
|
28
|
+
"serwist": "cli.js"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"chalk": "5.3.0",
|
|
31
|
-
"chokidar": "3.
|
|
32
|
+
"chokidar": "3.6.0",
|
|
32
33
|
"common-tags": "1.8.2",
|
|
33
34
|
"fs-extra": "11.2.0",
|
|
34
|
-
"glob": "10.3.
|
|
35
|
-
"inquirer": "9.2.
|
|
36
|
-
"meow": "13.
|
|
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
|
|
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.
|
|
51
|
-
"typescript": "5.
|
|
52
|
-
"@serwist/
|
|
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 +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 +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 +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 +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 +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 +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 +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"}
|