@fastly/compute-js-static-publish 2.2.0 → 2.2.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/build/build-static.js +13 -13
- package/package.json +1 -1
- package/resources/default-content-types.cjs +4 -4
- package/src/build-static.ts +13 -13
package/build/build-static.js
CHANGED
|
@@ -41,14 +41,14 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
41
41
|
getFiles(results, config.publicDir);
|
|
42
42
|
const outputDir = path.resolve();
|
|
43
43
|
const publicDirRoot = path.resolve(config.publicDir);
|
|
44
|
-
console.log(
|
|
44
|
+
console.log(`✔️ Public directory '${publicDirRoot}'.`);
|
|
45
45
|
const staticDirs = (_a = config.staticDirs) !== null && _a !== void 0 ? _a : [];
|
|
46
46
|
if (staticDirs.length > 0) {
|
|
47
|
-
console.log(
|
|
47
|
+
console.log(`✔️ Using static directories: ${staticDirs.join(', ')}`);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
if (displayFrameworkWarnings) {
|
|
51
|
-
console.log(
|
|
51
|
+
console.log(`✔️ No static directories defined.`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
const staticRoots = staticDirs.map(dir => path.resolve(config.publicDir, dir));
|
|
@@ -57,11 +57,11 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
57
57
|
];
|
|
58
58
|
const excludeDirs = (_b = config.excludeDirs) !== null && _b !== void 0 ? _b : DEFAULT_EXCLUDE_DIRS;
|
|
59
59
|
if (excludeDirs.length > 0) {
|
|
60
|
-
console.log(
|
|
60
|
+
console.log(`✔️ Using exclude directories: ${excludeDirs.join(', ')}`);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
if (displayFrameworkWarnings) {
|
|
64
|
-
console.log(
|
|
64
|
+
console.log(`✔️ No exclude directories defined.`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
const excludeRoots = excludeDirs.map(dir => path.resolve(config.publicDir, dir));
|
|
@@ -79,11 +79,11 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
79
79
|
];
|
|
80
80
|
const includeDirs = (_d = config.includeDirs) !== null && _d !== void 0 ? _d : DEFAULT_INCLUDE_DIRS;
|
|
81
81
|
if (includeDirs.length > 0) {
|
|
82
|
-
console.log(
|
|
82
|
+
console.log(`✔️ Using include directories: ${includeDirs.join(', ')}`);
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
if (displayFrameworkWarnings) {
|
|
86
|
-
console.log(
|
|
86
|
+
console.log(`✔️ No include directories defined.`);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
const includeRoots = includeDirs.map(dir => path.resolve(config.publicDir, dir));
|
|
@@ -141,7 +141,7 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
141
141
|
const filePath = file.slice(publicDirRoot.length);
|
|
142
142
|
const { contentType: type, isStatic, loadModule } = knownAssets[filePath];
|
|
143
143
|
if (contentDef != null) {
|
|
144
|
-
console.log('
|
|
144
|
+
console.log('✔️ ' + filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
if (displayFrameworkWarnings) {
|
|
@@ -167,7 +167,7 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
167
167
|
fileContents += '};\n';
|
|
168
168
|
let spaFile = (_e = config.spa) !== null && _e !== void 0 ? _e : false;
|
|
169
169
|
if (spaFile) {
|
|
170
|
-
console.log(
|
|
170
|
+
console.log(`✔️ Application SPA file '${spaFile}'.`);
|
|
171
171
|
if (!knownAssets[spaFile] || knownAssets[spaFile].contentType !== 'text/html') {
|
|
172
172
|
if (displayFrameworkWarnings) {
|
|
173
173
|
console.log(`⚠️ Notice: '${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -177,13 +177,13 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
179
|
if (displayFrameworkWarnings) {
|
|
180
|
-
console.log(
|
|
180
|
+
console.log(`✔️ Application is not a SPA.`);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
fileContents += `\nexport const spaFile = ${JSON.stringify(spaFile)};\n`;
|
|
184
184
|
let notFoundPageFile = (_f = config.notFoundPage) !== null && _f !== void 0 ? _f : false;
|
|
185
185
|
if (notFoundPageFile) {
|
|
186
|
-
console.log(
|
|
186
|
+
console.log(`✔️ Application 'not found (404)' file '${notFoundPageFile}'.`);
|
|
187
187
|
if (!knownAssets[notFoundPageFile] || knownAssets[notFoundPageFile].contentType !== 'text/html') {
|
|
188
188
|
if (displayFrameworkWarnings) {
|
|
189
189
|
console.log(`⚠️ Notice: '${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -193,7 +193,7 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
195
|
if (displayFrameworkWarnings) {
|
|
196
|
-
console.log(
|
|
196
|
+
console.log(`✔️ Application specifies no 'not found (404)' page.`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
fileContents += `\nexport const notFoundPageFile = ${JSON.stringify(notFoundPageFile)};\n`;
|
|
@@ -202,5 +202,5 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
202
202
|
let autoExt = (_h = config.autoExt) !== null && _h !== void 0 ? _h : null;
|
|
203
203
|
fileContents += `\nexport const autoExt = ${JSON.stringify(autoExt)};\n`;
|
|
204
204
|
fs.writeFileSync('./src/statics.js', fileContents);
|
|
205
|
-
console.log("✅
|
|
205
|
+
console.log("✅ Wrote static file loader for " + files.length + " file(s).");
|
|
206
206
|
}
|
package/package.json
CHANGED
|
@@ -47,17 +47,17 @@ function mergeContentTypes(contentTypes) {
|
|
|
47
47
|
typeof contentType.test !== 'function' &&
|
|
48
48
|
!(contentType.test instanceof RegExp)
|
|
49
49
|
) {
|
|
50
|
-
console.
|
|
50
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: 'test' must be a function or regular expression.`);
|
|
51
51
|
invalid = true;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if(typeof contentType.type !== 'string' || contentType.type.indexOf('/') === -1) {
|
|
55
|
-
console.
|
|
55
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: 'type' must be a string representing a MIME type.`);
|
|
56
56
|
invalid = true;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if('binary' in contentType && typeof contentType.binary !== 'boolean') {
|
|
60
|
-
console.
|
|
60
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: optional 'binary' must be a boolean value.`);
|
|
61
61
|
invalid = true;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -74,7 +74,7 @@ function mergeContentTypes(contentTypes) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
console.log('Applying ' + finalContentTypes.length + ' custom content type(s).');
|
|
77
|
+
console.log('✔️ Applying ' + finalContentTypes.length + ' custom content type(s).');
|
|
78
78
|
|
|
79
79
|
for (const contentType of defaultContentTypes) {
|
|
80
80
|
finalContentTypes.push(contentType);
|
package/src/build-static.ts
CHANGED
|
@@ -52,14 +52,14 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
52
52
|
|
|
53
53
|
const publicDirRoot = path.resolve(config.publicDir);
|
|
54
54
|
|
|
55
|
-
console.log(
|
|
55
|
+
console.log(`✔️ Public directory '${publicDirRoot}'.`);
|
|
56
56
|
|
|
57
57
|
const staticDirs: string[] = config.staticDirs ?? [];
|
|
58
58
|
if (staticDirs.length > 0) {
|
|
59
|
-
console.log(
|
|
59
|
+
console.log(`✔️ Using static directories: ${staticDirs.join(', ')}`);
|
|
60
60
|
} else {
|
|
61
61
|
if (displayFrameworkWarnings) {
|
|
62
|
-
console.log(
|
|
62
|
+
console.log(`✔️ No static directories defined.`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
const staticRoots = staticDirs.map(
|
|
@@ -72,10 +72,10 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
72
72
|
|
|
73
73
|
const excludeDirs: string[] = config.excludeDirs ?? DEFAULT_EXCLUDE_DIRS;
|
|
74
74
|
if (excludeDirs.length > 0) {
|
|
75
|
-
console.log(
|
|
75
|
+
console.log(`✔️ Using exclude directories: ${excludeDirs.join(', ')}`);
|
|
76
76
|
} else {
|
|
77
77
|
if (displayFrameworkWarnings) {
|
|
78
|
-
console.log(
|
|
78
|
+
console.log(`✔️ No exclude directories defined.`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
const excludeRoots = excludeDirs.map(
|
|
@@ -100,10 +100,10 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
100
100
|
|
|
101
101
|
const includeDirs: string[] = config.includeDirs ?? DEFAULT_INCLUDE_DIRS;
|
|
102
102
|
if (includeDirs.length > 0) {
|
|
103
|
-
console.log(
|
|
103
|
+
console.log(`✔️ Using include directories: ${includeDirs.join(', ')}`);
|
|
104
104
|
} else {
|
|
105
105
|
if (displayFrameworkWarnings) {
|
|
106
|
-
console.log(
|
|
106
|
+
console.log(`✔️ No include directories defined.`);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
const includeRoots = includeDirs.map(
|
|
@@ -172,7 +172,7 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
172
172
|
const { contentType: type, isStatic, loadModule } = knownAssets[filePath];
|
|
173
173
|
|
|
174
174
|
if (contentDef != null) {
|
|
175
|
-
console.log('
|
|
175
|
+
console.log('✔️ ' + filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
|
|
176
176
|
} else {
|
|
177
177
|
if (displayFrameworkWarnings) {
|
|
178
178
|
console.log('⚠️ Notice: Unknown file type ' + filePath + '. Treating as binary file.');
|
|
@@ -200,7 +200,7 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
200
200
|
|
|
201
201
|
let spaFile: string | false = config.spa ?? false;
|
|
202
202
|
if(spaFile) {
|
|
203
|
-
console.log(
|
|
203
|
+
console.log(`✔️ Application SPA file '${spaFile}'.`);
|
|
204
204
|
if(!knownAssets[spaFile] || knownAssets[spaFile].contentType !== 'text/html') {
|
|
205
205
|
if (displayFrameworkWarnings) {
|
|
206
206
|
console.log(`⚠️ Notice: '${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -209,7 +209,7 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
209
209
|
}
|
|
210
210
|
} else {
|
|
211
211
|
if (displayFrameworkWarnings) {
|
|
212
|
-
console.log(
|
|
212
|
+
console.log(`✔️ Application is not a SPA.`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -217,7 +217,7 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
217
217
|
|
|
218
218
|
let notFoundPageFile: string | false = config.notFoundPage ?? false;
|
|
219
219
|
if(notFoundPageFile) {
|
|
220
|
-
console.log(
|
|
220
|
+
console.log(`✔️ Application 'not found (404)' file '${notFoundPageFile}'.`);
|
|
221
221
|
if(!knownAssets[notFoundPageFile] || knownAssets[notFoundPageFile].contentType !== 'text/html') {
|
|
222
222
|
if (displayFrameworkWarnings) {
|
|
223
223
|
console.log(`⚠️ Notice: '${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
|
|
@@ -226,7 +226,7 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
226
226
|
}
|
|
227
227
|
} else {
|
|
228
228
|
if (displayFrameworkWarnings) {
|
|
229
|
-
console.log(
|
|
229
|
+
console.log(`✔️ Application specifies no 'not found (404)' page.`);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
@@ -240,6 +240,6 @@ export async function buildStaticLoader(commandLineValues: commandLineArgs.Comma
|
|
|
240
240
|
|
|
241
241
|
fs.writeFileSync('./src/statics.js', fileContents);
|
|
242
242
|
|
|
243
|
-
console.log("✅
|
|
243
|
+
console.log("✅ Wrote static file loader for " + files.length + " file(s).");
|
|
244
244
|
|
|
245
245
|
}
|