@serwist/cli 9.0.0-preview.13 → 9.0.0-preview.14
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 +1 -1
- package/dist/bin.d.ts +0 -1
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +136 -228
- 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 +5 -14
- 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/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;
|
|
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,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,18 @@
|
|
|
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
|
+
import path from 'node:path';
|
|
5
6
|
import { injectManifest } from '@serwist/build';
|
|
6
7
|
import chokidar from 'chokidar';
|
|
7
8
|
import prettyBytes from 'pretty-bytes';
|
|
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';
|
|
15
|
+
import upath from 'upath';
|
|
17
16
|
|
|
18
17
|
const constants = {
|
|
19
18
|
defaultConfigFile: "serwist.config.js",
|
|
@@ -22,10 +21,6 @@ const constants = {
|
|
|
22
21
|
],
|
|
23
22
|
ignoredFileExtensions: [
|
|
24
23
|
"map"
|
|
25
|
-
],
|
|
26
|
-
ignoreURLParametersMatching: [
|
|
27
|
-
/^utm_/,
|
|
28
|
-
/^fbclid$/
|
|
29
24
|
]
|
|
30
25
|
};
|
|
31
26
|
|
|
@@ -62,32 +57,52 @@ const logger = {
|
|
|
62
57
|
error: (...args)=>console.error(chalk.red.bold(...args))
|
|
63
58
|
};
|
|
64
59
|
|
|
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
|
|
60
|
+
const readConfig = async (configFile)=>{
|
|
61
|
+
return (await import(configFile)).default;
|
|
76
62
|
};
|
|
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
63
|
|
|
89
|
-
const
|
|
90
|
-
|
|
64
|
+
const getSubdirectories = async ()=>{
|
|
65
|
+
return await glob("*/", {
|
|
66
|
+
ignore: constants.ignoredDirectories.map((directory)=>`${directory}/`)
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const askRootOfWebApp = async ()=>{
|
|
70
|
+
const subdirectories = await getSubdirectories();
|
|
71
|
+
const { manualDirectoryInput, globDirectory } = await (()=>{
|
|
72
|
+
if (subdirectories.length > 0) {
|
|
73
|
+
const manualEntryChoice = "Manually enter path";
|
|
74
|
+
return inquirer.prompt([
|
|
75
|
+
{
|
|
76
|
+
name: "globDirectory",
|
|
77
|
+
type: "list",
|
|
78
|
+
message: oneLine`What is the root of your web app (i.e. which directory do
|
|
79
|
+
you deploy)?`,
|
|
80
|
+
choices: [
|
|
81
|
+
...subdirectories,
|
|
82
|
+
new inquirer.Separator(),
|
|
83
|
+
manualEntryChoice
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "manualDirectoryInput",
|
|
88
|
+
when: (answers)=>answers.globDirectory === manualEntryChoice,
|
|
89
|
+
message: "Please enter the path to the root of your web app:"
|
|
90
|
+
}
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
return inquirer.prompt([
|
|
94
|
+
{
|
|
95
|
+
name: "globDirectory",
|
|
96
|
+
message: "Please enter the path to the root of your web app:",
|
|
97
|
+
default: "."
|
|
98
|
+
}
|
|
99
|
+
]);
|
|
100
|
+
})();
|
|
101
|
+
const stat = statSync(manualDirectoryInput || globDirectory);
|
|
102
|
+
assert(stat.isDirectory(), errors["glob-directory-invalid"]);
|
|
103
|
+
return manualDirectoryInput || globDirectory;
|
|
104
|
+
};
|
|
105
|
+
const getAllFileExtensions = async (globDirectory)=>{
|
|
91
106
|
const files = await glob("**/*.*", {
|
|
92
107
|
cwd: globDirectory,
|
|
93
108
|
nodir: true,
|
|
@@ -106,192 +121,99 @@ async function getAllFileExtensions(globDirectory) {
|
|
|
106
121
|
return [
|
|
107
122
|
...extensions
|
|
108
123
|
];
|
|
109
|
-
}
|
|
110
|
-
async
|
|
111
|
-
const
|
|
112
|
-
text: `Examining files in ${globDirectory}...`,
|
|
113
|
-
stream: process.stdout
|
|
114
|
-
}).start();
|
|
124
|
+
};
|
|
125
|
+
const askQuestions = async ()=>{
|
|
126
|
+
const globDirectory = await askRootOfWebApp();
|
|
115
127
|
const fileExtensions = await getAllFileExtensions(globDirectory);
|
|
116
|
-
spinner.stop();
|
|
117
128
|
assert(fileExtensions.length > 0, errors["no-file-extensions-found"]);
|
|
118
|
-
|
|
129
|
+
const { swSrc, swDest, selectedExtensions, configLocation } = await inquirer.prompt([
|
|
119
130
|
{
|
|
120
|
-
name:
|
|
131
|
+
name: "swSrc",
|
|
132
|
+
message: oneLine`Where's your existing service worker file? To be used with
|
|
133
|
+
injectManifest, it should include a call to
|
|
134
|
+
'self.__SW_MANIFEST'`,
|
|
135
|
+
type: "input",
|
|
136
|
+
validate (input) {
|
|
137
|
+
if (typeof input !== "string") {
|
|
138
|
+
return "You must provide a valid 'swSrc'!";
|
|
139
|
+
}
|
|
140
|
+
if (!statSync(input, {
|
|
141
|
+
throwIfNoEntry: false
|
|
142
|
+
})?.isFile()) {
|
|
143
|
+
return "'swSrc' must point to a valid file!";
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "swDest",
|
|
150
|
+
message: "Where would you like your service worker file to be saved?",
|
|
151
|
+
type: "input",
|
|
152
|
+
default: upath.join(globDirectory, "sw.js"),
|
|
153
|
+
validate (input) {
|
|
154
|
+
if (typeof input !== "string") {
|
|
155
|
+
return "You must provide a valid 'swDest'!";
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "selectedExtensions",
|
|
121
162
|
message: "Which file types would you like to precache?",
|
|
122
163
|
type: "checkbox",
|
|
123
164
|
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
|
|
165
|
+
default: fileExtensions,
|
|
166
|
+
validate (input) {
|
|
167
|
+
if (!Array.isArray(input)) {
|
|
168
|
+
return "'selectedExtensions' is not an array. This is most likely a bug.";
|
|
169
|
+
}
|
|
170
|
+
if (input.length === 0) {
|
|
171
|
+
return errors["no-file-extensions-selected"];
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
165
174
|
}
|
|
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
175
|
},
|
|
200
176
|
{
|
|
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?",
|
|
177
|
+
name: "configLocation",
|
|
178
|
+
message: "Where would you like to save these configuration options?",
|
|
226
179
|
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"
|
|
180
|
+
default: constants.defaultConfigFile,
|
|
181
|
+
validate (input) {
|
|
182
|
+
if (typeof input !== "string") {
|
|
183
|
+
return "You must provide a valid location!";
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
247
187
|
}
|
|
248
188
|
]);
|
|
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();
|
|
189
|
+
const globPatterns = [
|
|
190
|
+
`**/*.${selectedExtensions.length === 1 ? selectedExtensions[0] : `{${selectedExtensions.join(",")}}`}`
|
|
191
|
+
];
|
|
263
192
|
const config = {
|
|
264
193
|
globDirectory,
|
|
265
194
|
globPatterns,
|
|
195
|
+
swSrc,
|
|
266
196
|
swDest
|
|
267
197
|
};
|
|
268
|
-
if (swSrc) {
|
|
269
|
-
config.swSrc = swSrc;
|
|
270
|
-
}
|
|
271
|
-
if (ignoreURLParametersMatching) {
|
|
272
|
-
config.ignoreURLParametersMatching = ignoreURLParametersMatching;
|
|
273
|
-
}
|
|
274
198
|
return {
|
|
275
199
|
config,
|
|
276
200
|
configLocation
|
|
277
201
|
};
|
|
278
|
-
}
|
|
202
|
+
};
|
|
279
203
|
|
|
280
|
-
async function runWizard(
|
|
281
|
-
const { configLocation, config } = await askQuestions(
|
|
282
|
-
const contents =
|
|
283
|
-
|
|
204
|
+
async function runWizard() {
|
|
205
|
+
const { configLocation, config } = await askQuestions();
|
|
206
|
+
const contents = `/** @type {import("@serwist/build").InjectManifestOptions} */\nexport default ${stringifyObject(config)};`;
|
|
207
|
+
writeFileSync(configLocation, contents);
|
|
284
208
|
logger.log(`To build your service worker, run
|
|
285
209
|
|
|
286
|
-
serwist
|
|
210
|
+
serwist inject-manifest ${configLocation}
|
|
287
211
|
|
|
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.`);
|
|
212
|
+
as part of a build process.`);
|
|
213
|
+
logger.log(`You can further customize your service worker by making changes to ${configLocation}. See https://serwist.pages.dev/docs/build/inject-manifest/configuring for details.`);
|
|
292
214
|
}
|
|
293
215
|
|
|
294
|
-
async
|
|
216
|
+
const runBuildCommand = async ({ config, watch })=>{
|
|
295
217
|
const { count, filePaths, size, warnings } = await injectManifest(config);
|
|
296
218
|
for (const warning of warnings){
|
|
297
219
|
logger.warn(warning);
|
|
@@ -306,27 +228,22 @@ async function runBuildCommand({ config, watch }) {
|
|
|
306
228
|
if (watch) {
|
|
307
229
|
logger.log("\nWatching for changes...");
|
|
308
230
|
}
|
|
309
|
-
}
|
|
231
|
+
};
|
|
310
232
|
const app = async (params)=>{
|
|
311
233
|
assert(params && Array.isArray(params.input), errors["missing-input"]);
|
|
312
234
|
const [command = "help", option] = params.input;
|
|
313
235
|
switch(command){
|
|
314
236
|
case "wizard":
|
|
315
237
|
{
|
|
316
|
-
await runWizard(
|
|
238
|
+
await runWizard();
|
|
317
239
|
break;
|
|
318
240
|
}
|
|
319
|
-
case "
|
|
241
|
+
case "inject-manifest":
|
|
320
242
|
{
|
|
321
|
-
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
case "injectManifest":
|
|
325
|
-
{
|
|
326
|
-
const configPath = upath.resolve(process.cwd(), option || constants.defaultConfigFile);
|
|
243
|
+
const configPath = path.resolve(process.cwd(), option || constants.defaultConfigFile);
|
|
327
244
|
let config;
|
|
328
245
|
try {
|
|
329
|
-
config = readConfig(configPath);
|
|
246
|
+
config = await readConfig(configPath);
|
|
330
247
|
} catch (error) {
|
|
331
248
|
config = null;
|
|
332
249
|
if (error instanceof Error) {
|
|
@@ -384,7 +301,7 @@ const app = async (params)=>{
|
|
|
384
301
|
}
|
|
385
302
|
};
|
|
386
303
|
|
|
387
|
-
|
|
304
|
+
const cleanupStackTrace = (error, moduleName)=>{
|
|
388
305
|
if (!error.stack) {
|
|
389
306
|
return "";
|
|
390
307
|
}
|
|
@@ -400,43 +317,34 @@ function cleanupStackTrace(error, moduleName) {
|
|
|
400
317
|
}
|
|
401
318
|
});
|
|
402
319
|
return frames.slice(startFrame, lastFrame + 1).join("\n");
|
|
403
|
-
}
|
|
320
|
+
};
|
|
404
321
|
|
|
405
322
|
const helpText = `Usage:
|
|
406
323
|
$ serwist <command> [options]
|
|
407
324
|
|
|
408
325
|
Commands:
|
|
409
|
-
wizard
|
|
326
|
+
wizard
|
|
410
327
|
Runs the configuration wizard, which will generate a
|
|
411
328
|
config file based on answers to questions.
|
|
412
329
|
|
|
413
|
-
|
|
330
|
+
inject-manifest [<path/to/config.js>] [--watch]
|
|
414
331
|
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.
|
|
332
|
+
copy of it with a precache manifest injected. The precache
|
|
333
|
+
manifest is generated based on the options in the config file
|
|
334
|
+
(defaults to 'serwist.config.js'). If '--watch' is provided, the
|
|
335
|
+
CLI will stay running and rebuild the service worker each
|
|
336
|
+
time a file in the precache manifest changes. See
|
|
337
|
+
https://serwist.pages.dev/docs/cli for more information.
|
|
428
338
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
JavaScript file,
|
|
432
|
-
|
|
433
|
-
directory
|
|
339
|
+
Configuration file:
|
|
340
|
+
The 'inject-manifest' command expects the configuration
|
|
341
|
+
file to be a JavaScript file. By default, it is assumed
|
|
342
|
+
to be named 'serwist.config.js' and located in the current
|
|
343
|
+
directory, but this can be overridden.
|
|
434
344
|
|
|
435
345
|
Examples:
|
|
436
346
|
$ serwist wizard
|
|
437
|
-
$ serwist
|
|
438
|
-
$ serwist injectManifest configs/serwist-dev-config.js
|
|
439
|
-
$ serwist copyLibraries build/
|
|
347
|
+
$ serwist inject-manifest configs/serwist-config.js
|
|
440
348
|
`;
|
|
441
349
|
|
|
442
350
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/cli",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The command line interface of Serwist.",
|
|
6
6
|
"files": [
|
|
@@ -34,12 +34,11 @@
|
|
|
34
34
|
"glob": "10.3.10",
|
|
35
35
|
"inquirer": "9.2.15",
|
|
36
36
|
"meow": "13.2.0",
|
|
37
|
-
"ora": "8.0.1",
|
|
38
37
|
"pretty-bytes": "6.1.1",
|
|
39
38
|
"stringify-object": "5.0.0",
|
|
40
39
|
"upath": "2.0.1",
|
|
41
40
|
"update-notifier": "7.0.0",
|
|
42
|
-
"@serwist/build": "9.0.0-preview.
|
|
41
|
+
"@serwist/build": "9.0.0-preview.14"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@types/common-tags": "1.8.4",
|
|
@@ -47,17 +46,9 @@
|
|
|
47
46
|
"@types/inquirer": "9.0.7",
|
|
48
47
|
"@types/stringify-object": "4.0.5",
|
|
49
48
|
"@types/update-notifier": "6.0.8",
|
|
50
|
-
"rollup": "4.
|
|
51
|
-
"typescript": "5.5.0-dev.
|
|
52
|
-
"@serwist/constants": "9.0.0-preview.
|
|
53
|
-
},
|
|
54
|
-
"peerDependencies": {
|
|
55
|
-
"typescript": ">=5.0.0"
|
|
56
|
-
},
|
|
57
|
-
"peerDependenciesMeta": {
|
|
58
|
-
"typescript": {
|
|
59
|
-
"optional": true
|
|
60
|
-
}
|
|
49
|
+
"rollup": "4.13.0",
|
|
50
|
+
"typescript": "5.5.0-dev.20240312",
|
|
51
|
+
"@serwist/constants": "9.0.0-preview.14"
|
|
61
52
|
},
|
|
62
53
|
"scripts": {
|
|
63
54
|
"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"}
|