tungsten 0.4.3 → 0.4.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/.build-complete +1 -1
- package/dist/Framework.d.ts +1 -0
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +15 -10
- package/dist/bin/commands/build.d.ts.map +1 -1
- package/dist/bin/commands/build.js +9 -6
- package/dist/bin/commands/buildHelp.d.ts +2 -0
- package/dist/bin/commands/buildHelp.d.ts.map +1 -0
- package/dist/bin/commands/buildHelp.js +7 -0
- package/dist/bin/commands/help.js +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +6 -1
- package/dist/build/bundle.d.ts +1 -1
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +6 -4
- package/dist/componentCss/tungsten.css +2 -2
- package/dist/staticGen/getAppRoutes.d.ts +1 -1
- package/dist/staticGen/getAppRoutes.d.ts.map +1 -1
- package/dist/staticGen/getAppRoutes.js +10 -7
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +6 -5
- package/package.json +1 -1
- package/dist/.tsbuildinfo +0 -1
package/dist/.build-complete
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1788304961722
|
package/dist/Framework.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class Framework {
|
|
|
14
14
|
devServer?: DevServer;
|
|
15
15
|
prodServer?: ProdServer;
|
|
16
16
|
profiler: TimeProfiler;
|
|
17
|
+
quiet: boolean;
|
|
17
18
|
init(): Promise<FrameworkConfigComplete>;
|
|
18
19
|
build(mode: Mode): Promise<void>;
|
|
19
20
|
clean(mode?: Mode | 'staticSite'): Promise<void>;
|
package/dist/Framework.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAKrC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAA+B,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AA8BxD,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIzE,qBAAa,SAAS;IAClB,MAAM,CAAC,EAAE,uBAAuB,CAAA;IAChC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,gBAAgB,CAAC,EAAE,qBAAqB,CAAA;IACxC,mBAAmB,CAAC,EAAE,aAAa,CAAA;IACnC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,UAAU,CAAA;IAIvB,QAAQ,EAAE,YAAY,CAA4B;
|
|
1
|
+
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAKrC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAA+B,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AA8BxD,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIzE,qBAAa,SAAS;IAClB,MAAM,CAAC,EAAE,uBAAuB,CAAA;IAChC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,gBAAgB,CAAC,EAAE,qBAAqB,CAAA;IACxC,mBAAmB,CAAC,EAAE,aAAa,CAAA;IACnC,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,UAAU,CAAC,EAAE,UAAU,CAAA;IAIvB,QAAQ,EAAE,YAAY,CAA4B;IAElD,KAAK,UAAQ;IAEP,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAQxC,KAAK,CAAC,IAAI,EAAE,IAAI;IAsBhB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,YAAY;IA0BhC,SAAS;YAID,aAAa;YAab,cAAc;YASd,mBAAmB;YAcnB,MAAM;IAcd,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC;IA2BrC,aAAa,CAAC,MAAM,EAAE,uBAAuB;IAiI7C,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;CA+DhD"}
|
package/dist/Framework.js
CHANGED
|
@@ -47,6 +47,8 @@ export class Framework {
|
|
|
47
47
|
// timeProfiler.ts. Public so those commands can also profile their own top-level phases
|
|
48
48
|
// (createDevServer, devServer.start) with the same instance.
|
|
49
49
|
_defineProperty(this, "profiler", createTimeProfiler(false));
|
|
50
|
+
// tungsten build --quiet: drop progress messages, keep warnings and errors
|
|
51
|
+
_defineProperty(this, "quiet", false);
|
|
50
52
|
}
|
|
51
53
|
async init() {
|
|
52
54
|
// const configOrUndefined = await this.getUserConfig()
|
|
@@ -62,7 +64,8 @@ export class Framework {
|
|
|
62
64
|
const proms = [this.profiler.timeProfileAsync('compile user app', () => this.compileUserApp('dev')), this.profiler.timeProfileAsync('copy framework assets', () => this.copyFrameworkAssets('dev'))];
|
|
63
65
|
await Promise.all(proms);
|
|
64
66
|
//await devBundle()
|
|
65
|
-
|
|
67
|
+
// dev branch: only tungsten build sets quiet, so this check cannot fire yet
|
|
68
|
+
if (!this.quiet) cliNews(`Build complete`);
|
|
66
69
|
} else {
|
|
67
70
|
const proms = [this.profiler.timeProfileAsync('compile user app', () => this.compileUserApp('prod')), this.profiler.timeProfileAsync('copy framework assets', () => this.copyFrameworkAssets('prod'))];
|
|
68
71
|
await Promise.all(proms);
|
|
@@ -125,17 +128,17 @@ export class Framework {
|
|
|
125
128
|
if (this.config === undefined) {
|
|
126
129
|
throw new TungstenError(`SxyFramework.copyFrameworkAssets() error: config is undefined`);
|
|
127
130
|
}
|
|
128
|
-
cliOut(`Getting framework modules`);
|
|
131
|
+
if (!this.quiet) cliOut(`Getting framework modules`);
|
|
129
132
|
this.frameworkModules = getAllTungstenClientModules();
|
|
130
|
-
cliOut(`Getting framework client aliases`);
|
|
133
|
+
if (!this.quiet) cliOut(`Getting framework client aliases`);
|
|
131
134
|
this.clientImportAliases = getTungstenClientPackageAliases();
|
|
132
|
-
cliOut(`Creating app files`);
|
|
135
|
+
if (!this.quiet) cliOut(`Creating app files`);
|
|
133
136
|
await Promise.all([createInstanceConfigFile(this.config, mode), createClientFiles(this.config, mode)]);
|
|
134
137
|
}
|
|
135
138
|
async bundle() {
|
|
136
139
|
const projectDir = process.cwd();
|
|
137
140
|
if (this.config === undefined) throw new TungstenError(`SxyFramework.bundle() error, this.config is undefined`);
|
|
138
|
-
await bundle(projectDir);
|
|
141
|
+
await bundle(projectDir, this.quiet);
|
|
139
142
|
// rollup extracts the framework component css in its own process, so the manifest only
|
|
140
143
|
// exists once bundling has finished
|
|
141
144
|
if (this.compilationInfo !== undefined) {
|
|
@@ -148,7 +151,8 @@ export class Framework {
|
|
|
148
151
|
}
|
|
149
152
|
async createDevServer() {
|
|
150
153
|
return this.profiler.timeProfileAsync('create dev server', async () => {
|
|
151
|
-
|
|
154
|
+
// dev only: only tungsten build sets quiet, so this check cannot fire yet
|
|
155
|
+
if (!this.quiet) cliOut(`Creating dev server`);
|
|
152
156
|
// TS define requires a var to exist or not, so we will initialize it to undefined to satisfy this expectation
|
|
153
157
|
global.tungstenPublicEnv = {};
|
|
154
158
|
// should we default the debug value? we'd have issues if they set DEBUG to undef
|
|
@@ -194,10 +198,11 @@ export class Framework {
|
|
|
194
198
|
...process.env
|
|
195
199
|
};
|
|
196
200
|
//const envsLoadedMessages: string[] = []
|
|
201
|
+
const quiet = this.quiet;
|
|
197
202
|
function loadEnv(fileName, filePath, prefix = '') {
|
|
198
203
|
const env = dotenv.parse(readFileSync(filePath, 'utf-8'));
|
|
199
204
|
someEnvLoaded = true;
|
|
200
|
-
cliOut(`${fileName} loaded from ${filePath}`);
|
|
205
|
+
if (!quiet) cliOut(`${fileName} loaded from ${filePath}`);
|
|
201
206
|
addToEnv(env, process.env, prefix, trueEnv, config.suppressEnvOverwriteWarnings);
|
|
202
207
|
//console.log('process.env after injecting ' + fileName, process.env)
|
|
203
208
|
}
|
|
@@ -224,7 +229,7 @@ export class Framework {
|
|
|
224
229
|
if (publicEnvExists) {
|
|
225
230
|
await loadEnv('.env.public', publicEnvLocation, 'TUNGSTEN_PUBLIC_');
|
|
226
231
|
}
|
|
227
|
-
if (!someEnvLoaded) cliOut('No env files were loaded');
|
|
232
|
+
if (!someEnvLoaded && !this.quiet) cliOut('No env files were loaded');
|
|
228
233
|
// If there are env schemas, load the relevant env and parse with schemas
|
|
229
234
|
if ('privateEnvSchema' in envSchemas) {
|
|
230
235
|
// parse process.env
|
|
@@ -237,7 +242,7 @@ export class Framework {
|
|
|
237
242
|
// is set to alter data
|
|
238
243
|
const withCorePrivateEnv = tungstenCorePrivateEnvSchema.parse(privateEnv);
|
|
239
244
|
global.tungstenPrivateEnv = withCorePrivateEnv;
|
|
240
|
-
cliOut('tungsten private env loaded and passed schema validation'); // save this so that we can show all messages about loading .env files first
|
|
245
|
+
if (!this.quiet) cliOut('tungsten private env loaded and passed schema validation'); // save this so that we can show all messages about loading .env files first
|
|
241
246
|
}
|
|
242
247
|
if ('publicEnvSchema' in envSchemas) {
|
|
243
248
|
// const filteredEnv = objectMap(
|
|
@@ -258,7 +263,7 @@ export class Framework {
|
|
|
258
263
|
writeFileSync(clientWithEnvHandle, publicEnvContent);
|
|
259
264
|
writeFileSync(clientWithEnvHandle, clientContents);
|
|
260
265
|
closeSync(clientWithEnvHandle);
|
|
261
|
-
cliOut('tungsten public env loaded and passed schema validation'); // save this so that we can show all messages about loading .env files first
|
|
266
|
+
if (!this.quiet) cliOut('tungsten public env loaded and passed schema validation'); // save this so that we can show all messages about loading .env files first
|
|
262
267
|
} else {
|
|
263
268
|
//cliOut('copy client to clientWithEnv.js')
|
|
264
269
|
copyFileSync(join(projectDir, bundleFolder, 'client.js'), join(projectDir, bundleFolder, 'clientWithEnv.js'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/build.ts"],"names":[],"mappings":"AA2DA,OAAO,EAAE,CAAA"}
|
|
@@ -4,14 +4,17 @@ import { Framework } from "../../Framework.js";
|
|
|
4
4
|
import { cliOut, cliNews, cliWarn } from "../../cliOutput.js";
|
|
5
5
|
import { staticSiteFolder } from "../../settings.js";
|
|
6
6
|
import { createTimeProfiler } from "../../timeProfiler.js";
|
|
7
|
-
const
|
|
7
|
+
const args = process.argv.slice(3);
|
|
8
|
+
const profile = args.includes('--profile');
|
|
9
|
+
const quiet = args.includes('--quiet');
|
|
8
10
|
//// prep the app
|
|
9
11
|
const sxyFramework = new Framework();
|
|
10
12
|
sxyFramework.profiler = createTimeProfiler(profile);
|
|
13
|
+
sxyFramework.quiet = quiet;
|
|
11
14
|
await sxyFramework.init();
|
|
12
|
-
cliOut('Removing old builds');
|
|
15
|
+
if (!quiet) cliOut('Removing old builds');
|
|
13
16
|
await sxyFramework.clean('prod');
|
|
14
|
-
cliOut('Building');
|
|
17
|
+
if (!quiet) cliOut('Building');
|
|
15
18
|
await sxyFramework.build('prod');
|
|
16
19
|
// //// dev
|
|
17
20
|
// import { prodBuildFolder } from '../../settings.js'
|
|
@@ -22,11 +25,11 @@ await sxyFramework.build('prod');
|
|
|
22
25
|
// //// end dev
|
|
23
26
|
if (sxyFramework.config.staticSite) {
|
|
24
27
|
// eslint-disable-line @typescript-eslint/no-non-null-assertion, no-type-assertion/no-type-assertion -- config better be set
|
|
25
|
-
cliOut(`Building static site`);
|
|
28
|
+
if (!quiet) cliOut(`Building static site`);
|
|
26
29
|
await sxyFramework.clean('staticSite');
|
|
27
30
|
await sxyFramework.staticGen();
|
|
28
|
-
cliNews(`Static site generation complete. Your site is in ${staticSiteFolder}.` + ` View it with ${chalk.brightblue('npx tungsten static')}` + ` or add ${chalk.brightblue('"static": "tungsten static"')} to your package.json scripts` + ` and run ${chalk.brightblue('pnpm static')}`);
|
|
29
|
-
} else {
|
|
31
|
+
if (!quiet) cliNews(`Static site generation complete. Your site is in ${staticSiteFolder}.` + ` View it with ${chalk.brightblue('npx tungsten static')}` + ` or add ${chalk.brightblue('"static": "tungsten static"')} to your package.json scripts` + ` and run ${chalk.brightblue('pnpm static')}`);
|
|
32
|
+
} else if (!quiet) {
|
|
30
33
|
cliNews(`Production build complete`);
|
|
31
34
|
}
|
|
32
35
|
// The build no longer holds anything open, so it ends by draining the event loop - hard-exiting
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildHelp.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/buildHelp.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// kept out of build.ts so --help does not pay for resolving the build's import tree
|
|
2
|
+
import { cliOut } from "../../cliOutput.js";
|
|
3
|
+
cliOut(`Usage: tungsten build [--profile] [--quiet]
|
|
4
|
+
|
|
5
|
+
Options:
|
|
6
|
+
--profile report the time taken by each build phase
|
|
7
|
+
--quiet suppress progress output; warnings and errors still print`);
|
|
@@ -5,7 +5,7 @@ cliOut(`Usage: tungsten <command> [options]
|
|
|
5
5
|
Commands:
|
|
6
6
|
dev Start dev mode [--no-boot] [--profile]
|
|
7
7
|
devmon Dev mode, auto-restarts on framework rebuilds (same options as dev)
|
|
8
|
-
build Production build [--profile]
|
|
8
|
+
build Production build [--profile] [--quiet]
|
|
9
9
|
start Start production server
|
|
10
10
|
static Preview a static site build
|
|
11
11
|
clean Delete build assets
|
package/dist/bin/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAuEA,OAAO,EAAE,CAAA"}
|
package/dist/bin/index.js
CHANGED
|
@@ -29,7 +29,12 @@ switch (command) {
|
|
|
29
29
|
}
|
|
30
30
|
case 'build':
|
|
31
31
|
{
|
|
32
|
-
|
|
32
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
33
|
+
await import("./commands/buildHelp.js");
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
// announce before the import: resolving the build's dependencies is a long silent wait
|
|
37
|
+
if (!args.includes('--quiet')) cliOut(`Starting Tungsten production build`);
|
|
33
38
|
process.env.__TUNGSTEN_ENV = 'production';
|
|
34
39
|
process.env.__TUNGSTEN_DEBUG = 'true';
|
|
35
40
|
await import("./commands/build.js");
|
package/dist/build/bundle.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function bundle(projectDir: string): Promise<unknown>;
|
|
1
|
+
export declare function bundle(projectDir: string, quiet?: boolean): Promise<unknown>;
|
|
2
2
|
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAUA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/build/bundle.ts"],"names":[],"mappings":"AAUA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,UAAQ,oBAyC7D"}
|
package/dist/build/bundle.js
CHANGED
|
@@ -5,9 +5,9 @@ import { spawnShellCommand } from "../spawnShellCommand.js";
|
|
|
5
5
|
import { prodBuildFolder, bundleFolder, frameworkDistFolder, clientFolder } from "../settings.js";
|
|
6
6
|
import { errorOut } from "../output.js";
|
|
7
7
|
import { cliLog, cliOut } from "../cliOutput.js";
|
|
8
|
-
export async function bundle(projectDir /*, appConfig: FrameworkConfigComplete*/) {
|
|
8
|
+
export async function bundle(projectDir, quiet = false /*, appConfig: FrameworkConfigComplete*/) {
|
|
9
9
|
return new Promise((resolve, reject) => {
|
|
10
|
-
cliOut('Bundling application');
|
|
10
|
+
if (!quiet) cliOut('Bundling application');
|
|
11
11
|
const frameworkDir = findProjectDir(import.meta.url);
|
|
12
12
|
// if (appConfig.useRootComponent) {
|
|
13
13
|
// let rootComponent = appConfig.rootComponent as string
|
|
@@ -17,11 +17,13 @@ export async function bundle(projectDir /*, appConfig: FrameworkConfigComplete*/
|
|
|
17
17
|
//'node-fetch'
|
|
18
18
|
];
|
|
19
19
|
const command = `cd ${frameworkDir} && npx rollup` + ` --input "${join(projectDir, prodBuildFolder, clientFolder, 'client.js')}"` + ` --file "${join(projectDir, bundleFolder, 'client.js')}"` + ` --config "${join(frameworkDir, frameworkDistFolder, 'build/rollup.user.prod.config.js')}"` + (externalModules.length > 0 ? ` --external ${externalModules.join(',')}` : ``) + ` --inlineDynamicImports --format iife`;
|
|
20
|
-
cliLog('bundle command:', command);
|
|
20
|
+
if (!quiet) cliLog('bundle command:', command);
|
|
21
21
|
const subProcess = spawnShellCommand(command, {
|
|
22
22
|
cwd: frameworkDir /*cwd: projectDir*/ /*, stdio: 'inherit'*/
|
|
23
23
|
});
|
|
24
|
-
subProcess.on('data', data =>
|
|
24
|
+
subProcess.on('data', data => {
|
|
25
|
+
if (!quiet) cliLog(data);
|
|
26
|
+
});
|
|
25
27
|
subProcess.on('close', (code, message) => {
|
|
26
28
|
if (code === 0) resolve(null);else {
|
|
27
29
|
// can we show teh error message? Only getting err code now I think
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@import "i/T-components-library-
|
|
2
|
-
@import "i/T-components-library-
|
|
1
|
+
@import "i/T-components-library-__StatefulMessage-StatefulMessage.css";
|
|
2
|
+
@import "i/T-components-library-RichTextEditor-RichTextEditor.css";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FrameworkConfigComplete } from '../FrameworkConfig.js';
|
|
2
2
|
import type { CompilationInfo } from '../build/CompilationInfo.js';
|
|
3
3
|
import { AppRoutes } from 'tungsten/routing/AppRoutes.js';
|
|
4
|
-
export declare function getAppRoutes(compilationInfo: CompilationInfo, config: FrameworkConfigComplete): Promise<AppRoutes>;
|
|
4
|
+
export declare function getAppRoutes(compilationInfo: CompilationInfo, config: FrameworkConfigComplete, quiet?: boolean): Promise<AppRoutes>;
|
|
5
5
|
//# sourceMappingURL=getAppRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAppRoutes.d.ts","sourceRoot":"","sources":["../../src/staticGen/getAppRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"getAppRoutes.d.ts","sourceRoot":"","sources":["../../src/staticGen/getAppRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAGlE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAOzD,wBAAsB,YAAY,CAC9B,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,uBAAuB,EAAE,KAAK,UAAQ,GACjF,OAAO,CAAC,SAAS,CAAC,CAiCpB"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
import { fixExtension } from "../fixExtension.js";
|
|
3
3
|
import { TungstenError } from "../TungstenError.js";
|
|
4
|
+
import { cliLog } from "../cliOutput.js";
|
|
4
5
|
// prod: const appRoutes: AppRoutes = await getRoutes(this.compilationInfo, this.config)
|
|
5
6
|
// this file is outdated and may not work correctly
|
|
6
7
|
// should compare this to the functions used by Servers
|
|
7
|
-
export async function getAppRoutes(compilationInfo, config) {
|
|
8
|
+
export async function getAppRoutes(compilationInfo, config, quiet = false) {
|
|
8
9
|
//const fullBuildLocation = 'file://' + compilationInfo.location
|
|
9
10
|
const routesLocation = config.routesLocation;
|
|
10
11
|
//if (routesLocation === null) return routesLocation // hopefully we are validating
|
|
11
12
|
try {
|
|
12
13
|
if (Array.isArray(routesLocation)) {
|
|
13
14
|
const routesFile = fixExtension(join(compilationInfo.buildCodeLocation, routesLocation[0]));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (!quiet) {
|
|
16
|
+
cliLog('[1] fullBuildLocation', compilationInfo.location);
|
|
17
|
+
cliLog('[1] routesLocation[0]', routesLocation[0]);
|
|
18
|
+
cliLog('joined', join(compilationInfo.location, routesLocation[0]));
|
|
19
|
+
cliLog('[1] routesFile', routesFile);
|
|
20
|
+
}
|
|
18
21
|
const target = 'file://' + routesFile;
|
|
19
|
-
|
|
22
|
+
if (!quiet) cliLog('[1] target', target);
|
|
20
23
|
return (await import(target))[routesLocation[1]];
|
|
21
24
|
} else {
|
|
22
25
|
const target = 'file://' + join(compilationInfo.buildCodeLocation, routesLocation);
|
|
23
|
-
|
|
26
|
+
if (!quiet) cliLog('[2] location', target);
|
|
24
27
|
const module = await import(target);
|
|
25
28
|
if ('routes' in module) return module.routes;else if ('default' in module) return module.default;else throw new TungstenError(`Err, no 'routes' or 'default' export found in routes file ${routesLocation}`);
|
|
26
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,iBA+MnD"}
|
|
@@ -4,7 +4,7 @@ import fsExtra from 'fs-extra';
|
|
|
4
4
|
//import type { SxyFrameworkConfigComplete } from '../FrameworkConfig.js'
|
|
5
5
|
import { staticSiteFolder, staticFolder, assetsFolder, publicFolder, bundleFolder, componentCssFolder, frameworkCssFolder } from "../settings.js";
|
|
6
6
|
import { getAppRoutes } from "./getAppRoutes.js";
|
|
7
|
-
import { cliError, cliWarn } from "../cliOutput.js";
|
|
7
|
+
import { cliError, cliLog, cliWarn } from "../cliOutput.js";
|
|
8
8
|
import { matchPath } from "../routing/matchPath.js";
|
|
9
9
|
import { throwError } from "../throwError.js";
|
|
10
10
|
import { RouteKeyIsPath, StringIsPath } from "../routing/RouteTypes.js";
|
|
@@ -18,11 +18,12 @@ export async function staticGen(framework) {
|
|
|
18
18
|
if (config === undefined) {
|
|
19
19
|
throwError('staticGen()', `expected framework.config to be set: ${framework.config}`);
|
|
20
20
|
}
|
|
21
|
+
const quiet = framework.quiet;
|
|
21
22
|
const siteBasePath = config.siteBasePath;
|
|
22
|
-
|
|
23
|
+
if (!quiet) cliLog('siteBasePath', siteBasePath);
|
|
23
24
|
const projectDir = process.cwd();
|
|
24
25
|
//let appRoutes: RouteDefinition[] | Record<RouteKey, RouteDefinition> = await getAppRoutes(framework.compilationInfo, config)
|
|
25
|
-
const getRoutes = await getAppRoutes(framework.compilationInfo, config);
|
|
26
|
+
const getRoutes = await getAppRoutes(framework.compilationInfo, config, quiet);
|
|
26
27
|
// ! unsure about this
|
|
27
28
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
28
29
|
const appRoutes = getRoutes === null ? {
|
|
@@ -89,7 +90,7 @@ export async function staticGen(framework) {
|
|
|
89
90
|
const url = serverLocation + path;
|
|
90
91
|
let links;
|
|
91
92
|
try {
|
|
92
|
-
|
|
93
|
+
if (!quiet) cliLog('get URL', url);
|
|
93
94
|
const response = await fetch(url);
|
|
94
95
|
// fetch, unlike axios, resolves on non-2xx - so check explicitly, or we'd
|
|
95
96
|
// write error pages out as static HTML
|
|
@@ -145,7 +146,7 @@ export async function staticGen(framework) {
|
|
|
145
146
|
for (const [path, route] of Object.entries(finalRoutes)) {
|
|
146
147
|
await renderPath(path, siteBasePath);
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
+
if (!quiet) cliLog('rewriteMap', rewriteMap);
|
|
149
150
|
const copyPromises = [fsExtra.copy(join(buildLocation, staticFolder), join(projectDir, staticSiteFolder)),
|
|
150
151
|
// assets folder
|
|
151
152
|
existsSync(join(buildLocation, assetsFolder)) ? fsExtra.copy(join(buildLocation, assetsFolder), join(projectDir, staticSiteFolder, 'assets')) : null,
|