tungsten 0.4.3 → 0.4.5

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.
Files changed (37) hide show
  1. package/dist/.build-complete +1 -1
  2. package/dist/Framework.d.ts +1 -0
  3. package/dist/Framework.d.ts.map +1 -1
  4. package/dist/Framework.js +17 -12
  5. package/dist/bin/commands/build.d.ts.map +1 -1
  6. package/dist/bin/commands/build.js +9 -6
  7. package/dist/bin/commands/buildHelp.d.ts +2 -0
  8. package/dist/bin/commands/buildHelp.d.ts.map +1 -0
  9. package/dist/bin/commands/buildHelp.js +7 -0
  10. package/dist/bin/commands/help.js +1 -1
  11. package/dist/bin/index.d.ts.map +1 -1
  12. package/dist/bin/index.js +6 -1
  13. package/dist/build/bundle.d.ts +1 -1
  14. package/dist/build/bundle.d.ts.map +1 -1
  15. package/dist/build/bundle.js +6 -4
  16. package/dist/build/compileJavascript.js +1 -1
  17. package/dist/build/compileStyles.d.ts +1 -1
  18. package/dist/build/compileStyles.d.ts.map +1 -1
  19. package/dist/build/compileStyles.js +2 -2
  20. package/dist/build/compileUserApp.d.ts +1 -1
  21. package/dist/build/compileUserApp.d.ts.map +1 -1
  22. package/dist/build/compileUserApp.js +8 -5
  23. package/dist/build/copyAssets.d.ts +1 -1
  24. package/dist/build/copyAssets.d.ts.map +1 -1
  25. package/dist/build/copyAssets.js +2 -2
  26. package/dist/build/copyPublicFiles.d.ts +1 -1
  27. package/dist/build/copyPublicFiles.d.ts.map +1 -1
  28. package/dist/build/copyPublicFiles.js +2 -2
  29. package/dist/spawnShellCommand.d.ts.map +1 -1
  30. package/dist/spawnShellCommand.js +11 -4
  31. package/dist/staticGen/getAppRoutes.d.ts +1 -1
  32. package/dist/staticGen/getAppRoutes.d.ts.map +1 -1
  33. package/dist/staticGen/getAppRoutes.js +10 -7
  34. package/dist/staticGen/staticGen.d.ts.map +1 -1
  35. package/dist/staticGen/staticGen.js +6 -5
  36. package/package.json +1 -1
  37. package/dist/.tsbuildinfo +0 -1
@@ -1 +1 @@
1
- 1788299975003
1
+ 1788306927004
@@ -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>;
@@ -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;IAE5C,IAAI,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAQxC,KAAK,CAAC,IAAI,EAAE,IAAI;IAqBhB,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;IA0BrC,aAAa,CAAC,MAAM,EAAE,uBAAuB;IAgI7C,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;CA+DhD"}
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
- cliNews(`Build complete`);
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);
@@ -102,7 +105,7 @@ export class Framework {
102
105
  await this.profiler.timeProfileAsync('static gen', () => staticGen(this));
103
106
  }
104
107
  async getUserConfig() {
105
- return this.config = await getUserConfig();
108
+ return this.config = await getUserConfig(null, this.quiet ? 'silent' : 'noisy');
106
109
  // const userConfigOrNull = await findUserConfig(process.cwd())
107
110
  // if (userConfigOrNull !== null) {
108
111
  // const userConfig = userConfigOrNull
@@ -117,7 +120,7 @@ export class Framework {
117
120
  throw new TungstenError(`SxyFramework.compileUserApp() error: config is undefined`);
118
121
  }
119
122
  const projectDir = process.cwd();
120
- const compilationInfo = await compileUserApp(projectDir, this.config, mode, this.profiler);
123
+ const compilationInfo = await compileUserApp(projectDir, this.config, mode, this.profiler, this.quiet);
121
124
  this.compilationInfo = compilationInfo;
122
125
  return compilationInfo;
123
126
  }
@@ -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
- cliOut(`Creating dev server`);
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":"AAwDA,OAAO,EAAE,CAAA"}
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 profile = process.argv.slice(3).includes('--profile');
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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=buildHelp.d.ts.map
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAkEA,OAAO,EAAE,CAAA"}
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
- cliOut(`Starting Tungsten production build`);
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");
@@ -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,oBAyC9C"}
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"}
@@ -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 => cliLog(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
@@ -14,7 +14,7 @@ import { getFrameworkDir } from "../getFrameworkDir.js";
14
14
  ///// needs work to work in prod mode
15
15
  ///// see babel config
16
16
  export async function compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch = true, options = {}) {
17
- cliOut(`Compiling app code`);
17
+ if (options.quiet !== true) cliOut(`Compiling app code`);
18
18
  let dependencyGraphDir = '';
19
19
  let dependencyGraphLocation = '';
20
20
  let oldDependencyGraph = {};
@@ -1,3 +1,3 @@
1
1
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
2
- export declare function compileStyles(projectDir: string, config: FrameworkConfigComplete, styleImportBase: string, buildLocation: string, watch?: boolean, onChange?: () => void): Promise<unknown>;
2
+ export declare function compileStyles(projectDir: string, config: FrameworkConfigComplete, styleImportBase: string, buildLocation: string, watch?: boolean, onChange?: () => void, quiet?: boolean): Promise<unknown>;
3
3
  //# sourceMappingURL=compileStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileStyles.d.ts","sourceRoot":"","sources":["../../src/build/compileStyles.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAgOpE,wBAAsB,aAAa,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,EACZ,QAAQ,CAAC,EAAE,MAAM,IAAI,oBAiGxB"}
1
+ {"version":3,"file":"compileStyles.d.ts","sourceRoot":"","sources":["../../src/build/compileStyles.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAgOpE,wBAAsB,aAAa,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,EACZ,QAAQ,CAAC,EAAE,MAAM,IAAI,EACrB,KAAK,UAAQ,oBAiGhB"}
@@ -183,8 +183,8 @@ async function processAndCopyFile(sourceLocation, targetLocation, filePathFull,
183
183
  }
184
184
  cssFiles[targetRelFile] = relFile;
185
185
  }
186
- export async function compileStyles(projectDir, config, styleImportBase, buildLocation, watch = true, onChange) {
187
- cliOut(`Compiling app stylesheets`);
186
+ export async function compileStyles(projectDir, config, styleImportBase, buildLocation, watch = true, onChange, quiet = false) {
187
+ if (!quiet) cliOut(`Compiling app stylesheets`);
188
188
  // we need to create and maintain a dependency tree for correct updating
189
189
  // we are going to save the dependencies of each file
190
190
  const cssDependencies = {};
@@ -2,5 +2,5 @@ import type { CompilationInfo } from './CompilationInfo.js';
2
2
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
3
3
  import type { Mode } from '../Mode.js';
4
4
  import { type TimeProfiler } from '../timeProfiler.js';
5
- export declare function compileUserApp(projectDir: string, appConfig: FrameworkConfigComplete, mode: Mode, profiler?: TimeProfiler): Promise<CompilationInfo>;
5
+ export declare function compileUserApp(projectDir: string, appConfig: FrameworkConfigComplete, mode: Mode, profiler?: TimeProfiler, quiet?: boolean): Promise<CompilationInfo>;
6
6
  //# sourceMappingURL=compileUserApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileUserApp.d.ts","sourceRoot":"","sources":["../../src/build/compileUserApp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAWtC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAI1E,wBAAsB,cAAc,CAChC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,EAClE,QAAQ,GAAE,YAAwC,GACnD,OAAO,CAAC,eAAe,CAAC,CAyE1B"}
1
+ {"version":3,"file":"compileUserApp.d.ts","sourceRoot":"","sources":["../../src/build/compileUserApp.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAWtC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAI1E,wBAAsB,cAAc,CAChC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,EAClE,QAAQ,GAAE,YAAwC,EAAE,KAAK,UAAQ,GAClE,OAAO,CAAC,eAAe,CAAC,CA2E1B"}
@@ -9,7 +9,7 @@ import { writeFrameworkCss } from "./frameworkStylesheets.js";
9
9
  import { emitReloadEvent } from "../hmr/liveReloadHub.js";
10
10
  import { createTimeProfiler } from "../timeProfiler.js";
11
11
  //import { compileEnv } from './compileEnv.js'
12
- export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false)) {
12
+ export async function compileUserApp(projectDir, appConfig, mode, profiler = createTimeProfiler(false), quiet = false) {
13
13
  const codeLocation = join(projectDir, appConfig.codeDir);
14
14
  const relSourceDir = appConfig.sourceDir !== undefined && appConfig.sourceDir !== '' ? appConfig.sourceDir : appConfig.codeDir;
15
15
  const sourceLocation = join(projectDir, relSourceDir);
@@ -21,15 +21,18 @@ export async function compileUserApp(projectDir, appConfig, mode, profiler = cre
21
21
  // open, so the command could only ever end by hard-exiting
22
22
  const watch = mode === 'dev';
23
23
  const compileJavascriptPromise = profiler.timeProfileAsync('compile javascript', () => compileJavascript(projectDir, appConfig, codeLocation, sourceLocation, styleImportBase, buildLocation, buildCodeLocation, mode, watch, mode === 'dev' ? {
24
+ quiet,
24
25
  hmr: appConfig.hmr === true,
25
26
  onCycleComplete: cycle => {
26
27
  if (cycle.success) emitReloadEvent('js', cycle.file);
27
28
  }
28
- } : {}));
29
+ } : {
30
+ quiet
31
+ }));
29
32
  //const compileEnvPromise = compileEnv(projectDir, appConfig, codeLocation, buildLocation, mode)
30
- const compileStylesPromise = profiler.timeProfileAsync('compile styles', () => compileStyles(projectDir, appConfig, styleImportBase, buildLocation, watch, mode === 'dev' ? () => emitReloadEvent('css') : undefined));
31
- const copyAssetsPromise = profiler.timeProfileAsync('copy assets', () => copyAssets(projectDir, appConfig, buildLocation, watch));
32
- const copyPublicFilesPromise = profiler.timeProfileAsync('copy public files', () => copyPublicFiles(projectDir, appConfig, buildLocation, watch));
33
+ const compileStylesPromise = profiler.timeProfileAsync('compile styles', () => compileStyles(projectDir, appConfig, styleImportBase, buildLocation, watch, mode === 'dev' ? () => emitReloadEvent('css') : undefined, quiet));
34
+ const copyAssetsPromise = profiler.timeProfileAsync('copy assets', () => copyAssets(projectDir, appConfig, buildLocation, watch, quiet));
35
+ const copyPublicFilesPromise = profiler.timeProfileAsync('copy public files', () => copyPublicFiles(projectDir, appConfig, buildLocation, watch, quiet));
33
36
  const {
34
37
  importAliases
35
38
  } = await compileJavascriptPromise;
@@ -1,3 +1,3 @@
1
1
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
2
- export declare function copyAssets(projectDir: string, config: FrameworkConfigComplete, buildLocation: string, watch?: boolean): Promise<unknown>;
2
+ export declare function copyAssets(projectDir: string, config: FrameworkConfigComplete, buildLocation: string, watch?: boolean, quiet?: boolean): Promise<unknown>;
3
3
  //# sourceMappingURL=copyAssets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copyAssets.d.ts","sourceRoot":"","sources":["../../src/build/copyAssets.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAiBpE,wBAAsB,UAAU,CAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,oBA2Df"}
1
+ {"version":3,"file":"copyAssets.d.ts","sourceRoot":"","sources":["../../src/build/copyAssets.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAiBpE,wBAAsB,UAAU,CAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,EACZ,KAAK,UAAQ,oBA2DhB"}
@@ -14,9 +14,9 @@ async function copyFile(assetsLocation, targetLocation, filePathFull, event) {
14
14
  });
15
15
  return fsPromises.copyFile(filePathFull, target);
16
16
  }
17
- export async function copyAssets(projectDir, config, buildLocation, watch = true) {
17
+ export async function copyAssets(projectDir, config, buildLocation, watch = true, quiet = false) {
18
18
  if (config.assetsDir !== undefined) {
19
- cliOut(`Copying assets`);
19
+ if (!quiet) cliOut(`Copying assets`);
20
20
  const assetsLocation = join(projectDir, config.assetsDir);
21
21
  const targetLocation = join(buildLocation, '.assets' /*, config.assetsDir*/);
22
22
  //console.log('copy assets from', assetsLocation, 'to', targetLocation)
@@ -1,3 +1,3 @@
1
1
  import type { FrameworkConfigComplete } from '../FrameworkConfig.js';
2
- export declare function copyPublicFiles(projectDir: string, config: FrameworkConfigComplete, buildLocation: string, watch?: boolean): Promise<unknown>;
2
+ export declare function copyPublicFiles(projectDir: string, config: FrameworkConfigComplete, buildLocation: string, watch?: boolean, quiet?: boolean): Promise<unknown>;
3
3
  //# sourceMappingURL=copyPublicFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copyPublicFiles.d.ts","sourceRoot":"","sources":["../../src/build/copyPublicFiles.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAiBpE,wBAAsB,eAAe,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,oBA4Df"}
1
+ {"version":3,"file":"copyPublicFiles.d.ts","sourceRoot":"","sources":["../../src/build/copyPublicFiles.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAiBpE,wBAAsB,eAAe,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,EACZ,KAAK,UAAQ,oBA4DhB"}
@@ -14,9 +14,9 @@ async function copyFile(assetsLocation, targetLocation, filePathFull, event) {
14
14
  });
15
15
  return fsPromises.copyFile(filePathFull, target);
16
16
  }
17
- export async function copyPublicFiles(projectDir, config, buildLocation, watch = true) {
17
+ export async function copyPublicFiles(projectDir, config, buildLocation, watch = true, quiet = false) {
18
18
  //if ( config.publicDir !== undefined ) {
19
- cliOut(`Copying public files`);
19
+ if (!quiet) cliOut(`Copying public files`);
20
20
  const publicLocation = config.publicDir !== undefined ? join(projectDir, config.publicDir) : join(projectDir, 'public');
21
21
  //const targetLocation = buildLocation // to segregate or not to segregate?
22
22
  const targetLocation = join(buildLocation, '.public');
@@ -1 +1 @@
1
- {"version":3,"file":"spawnShellCommand.d.ts","sourceRoot":"","sources":["../src/spawnShellCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAG/D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,0DAUlF"}
1
+ {"version":3,"file":"spawnShellCommand.d.ts","sourceRoot":"","sources":["../src/spawnShellCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAU/D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,0DAalF"}
@@ -1,12 +1,19 @@
1
1
  import { spawn } from 'child_process';
2
+ // Two routes to the same shell command line - flip this to fall back.
3
+ // 'whole-command' hands the string straight to the shell, which is what node wants: an args array
4
+ // alongside shell: true is deprecated (DEP0190) because the args are concatenated unescaped.
5
+ // 'split-args' is the original - splitting on spaces cuts quoted paths in half, and they only
6
+ // survive because the shell re-parses the string it rejoins.
7
+ const route = 'whole-command';
2
8
  export function spawnShellCommand(command, extras) {
3
- const parts = command.split(' '); // eslint-disable-line no-type-assertion/no-type-assertion -- split returns an array of length at least 1
4
- // if (process.platform === 'win32') {
5
- // parts[0] += '.cmd'
6
- // }
7
9
  const options = {
8
10
  shell: true,
9
11
  ...extras
10
12
  };
13
+ if (route === 'whole-command') return spawn(command, options);
14
+ const parts = command.split(' '); // eslint-disable-line no-type-assertion/no-type-assertion -- split returns an array of length at least 1
15
+ // if (process.platform === 'win32') {
16
+ // parts[0] += '.cmd'
17
+ // }
11
18
  return spawn(parts[0], parts.slice(1), options);
12
19
  }
@@ -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;AAMzD,wBAAsB,YAAY,CAAC,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,uBAAuB,GAC9F,OAAO,CAAC,SAAS,CAAC,CA+BvB"}
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
- console.log('[1] fullBuildLocation', compilationInfo.location);
15
- console.log('[1] routesLocation[0]', routesLocation[0]);
16
- console.log('joined', join(compilationInfo.location, routesLocation[0]));
17
- console.log('[1] routesFile', routesFile);
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
- console.log('[1] target', target);
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
- console.log('[2] location', target);
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,iBA6MnD"}
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
- console.log('siteBasePath', siteBasePath);
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
- console.log('get URL', url);
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
- console.log('rewriteMap', rewriteMap);
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tungsten",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {