@serwist/cli 9.0.2 → 9.0.4
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.js +76 -81
- package/dist/lib/ask-questions.d.ts.map +1 -1
- package/dist/lib/read-config.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,UAAU,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,IAAI,CAiF1E,CAAC"}
|
package/dist/bin.js
CHANGED
|
@@ -11,7 +11,7 @@ import chalk from 'chalk';
|
|
|
11
11
|
import { statSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import stringifyObject from 'stringify-object';
|
|
13
13
|
import { glob } from 'glob';
|
|
14
|
-
import
|
|
14
|
+
import { input, checkbox, select, Separator } from '@inquirer/prompts';
|
|
15
15
|
|
|
16
16
|
const constants = {
|
|
17
17
|
defaultConfigFile: "serwist.config.js",
|
|
@@ -67,35 +67,40 @@ const getSubdirectories = async ()=>{
|
|
|
67
67
|
};
|
|
68
68
|
const askRootOfWebApp = async ()=>{
|
|
69
69
|
const subdirectories = await getSubdirectories();
|
|
70
|
-
const {
|
|
70
|
+
const { globDirectory, manualDirectoryInput } = await (async ()=>{
|
|
71
71
|
if (subdirectories.length > 0) {
|
|
72
72
|
const manualEntryChoice = "Manually enter path";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
const globDirectory = await select({
|
|
74
|
+
message: "What is the root of your web app (i.e. which directory do you deploy)?",
|
|
75
|
+
choices: [
|
|
76
|
+
...subdirectories.map((dir)=>({
|
|
77
|
+
value: dir
|
|
78
|
+
})),
|
|
79
|
+
new Separator(),
|
|
80
|
+
{
|
|
81
|
+
value: manualEntryChoice
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
let manualDirectoryInput = undefined;
|
|
86
|
+
if (globDirectory === manualEntryChoice) {
|
|
87
|
+
manualDirectoryInput = await input({
|
|
88
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: "."
|
|
89
|
+
});
|
|
97
90
|
}
|
|
98
|
-
|
|
91
|
+
return {
|
|
92
|
+
globDirectory,
|
|
93
|
+
manualDirectoryInput
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const globDirectory = await input({
|
|
97
|
+
message: "Please enter the path to the root of your web app:",
|
|
98
|
+
default: "."
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
globDirectory,
|
|
102
|
+
manualDirectoryInput: undefined
|
|
103
|
+
};
|
|
99
104
|
})();
|
|
100
105
|
const stat = statSync(manualDirectoryInput || globDirectory);
|
|
101
106
|
assert(stat.isDirectory(), errors["glob-directory-invalid"]);
|
|
@@ -125,66 +130,56 @@ const askQuestions = async ()=>{
|
|
|
125
130
|
const globDirectory = await askRootOfWebApp();
|
|
126
131
|
const fileExtensions = await getAllFileExtensions(globDirectory);
|
|
127
132
|
assert(fileExtensions.length > 0, errors["no-file-extensions-found"]);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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;
|
|
133
|
+
const swSrc = await input({
|
|
134
|
+
message: "Where's your existing service worker file? To be used with 'injectManifest', it should include a call to 'self.__SW_MANIFEST'",
|
|
135
|
+
validate (input) {
|
|
136
|
+
if (typeof input !== "string") {
|
|
137
|
+
return "You must provide a valid 'swSrc'!";
|
|
145
138
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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;
|
|
139
|
+
if (!statSync(input, {
|
|
140
|
+
throwIfNoEntry: false
|
|
141
|
+
})?.isFile()) {
|
|
142
|
+
return "'swSrc' must point to a valid file!";
|
|
157
143
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const swDest = await input({
|
|
148
|
+
message: "Where would you like your service worker file to be saved?",
|
|
149
|
+
default: upath.join(globDirectory, "sw.js"),
|
|
150
|
+
validate (input) {
|
|
151
|
+
if (typeof input !== "string") {
|
|
152
|
+
return "You must provide a valid 'swDest'!";
|
|
173
153
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
const selectedExtensions = await checkbox({
|
|
158
|
+
message: "Which file types would you like to precache?",
|
|
159
|
+
choices: fileExtensions.map((ext)=>({
|
|
160
|
+
value: ext,
|
|
161
|
+
checked: true
|
|
162
|
+
})),
|
|
163
|
+
validate (input) {
|
|
164
|
+
if (!Array.isArray(input)) {
|
|
165
|
+
return "'selectedExtensions' is not an array. This is most likely a bug.";
|
|
185
166
|
}
|
|
167
|
+
if (input.length === 0) {
|
|
168
|
+
return errors["no-file-extensions-selected"];
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
186
171
|
}
|
|
187
|
-
|
|
172
|
+
});
|
|
173
|
+
const configLocation = await input({
|
|
174
|
+
message: "Where would you like to save these configuration options?",
|
|
175
|
+
default: constants.defaultConfigFile,
|
|
176
|
+
validate (input) {
|
|
177
|
+
if (typeof input !== "string") {
|
|
178
|
+
return "You must provide a valid location!";
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
188
183
|
const globPatterns = [
|
|
189
184
|
`**/*.${selectedExtensions.length === 1 ? selectedExtensions[0] : `{${selectedExtensions.join(",")}}`}`
|
|
190
185
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-questions.d.ts","sourceRoot":"","sources":["../../src/lib/ask-questions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ask-questions.d.ts","sourceRoot":"","sources":["../../src/lib/ask-questions.ts"],"names":[],"mappings":"AAmFA,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,OAAO,CAAC,wBAAwB,CAuErE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,OAAO,CAAC,qBAAqB,CAElF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/cli",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The command line interface of Serwist.",
|
|
6
6
|
"files": [
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"serwist": "cli.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@inquirer/prompts": "5.1.2",
|
|
31
32
|
"chalk": "5.3.0",
|
|
32
33
|
"chokidar": "3.6.0",
|
|
33
34
|
"common-tags": "1.8.2",
|
|
34
35
|
"fs-extra": "11.2.0",
|
|
35
|
-
"glob": "
|
|
36
|
-
"inquirer": "9.2.18",
|
|
36
|
+
"glob": "11.0.0",
|
|
37
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
|
-
"update-notifier": "7.
|
|
42
|
-
"@serwist/build": "9.0.
|
|
41
|
+
"update-notifier": "7.1.0",
|
|
42
|
+
"@serwist/build": "9.0.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/common-tags": "1.8.4",
|
|
@@ -47,9 +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.5.
|
|
52
|
-
"@serwist/configs": "9.0.
|
|
50
|
+
"rollup": "4.18.1",
|
|
51
|
+
"typescript": "5.5.3",
|
|
52
|
+
"@serwist/configs": "9.0.4"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
|