tungsten 0.1.38 → 0.1.40
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/Framework.d.ts +1 -1
- package/dist/Framework.d.ts.map +1 -1
- package/dist/Framework.js +2 -2
- package/dist/Servers/StaticSiteServer.d.ts +3 -1
- package/dist/Servers/StaticSiteServer.d.ts.map +1 -1
- package/dist/Servers/StaticSiteServer.js +6 -4
- package/dist/bin/commands/static.d.ts.map +1 -1
- package/dist/bin/commands/static.js +2 -1
- package/dist/getAppConfig.d.ts +3 -0
- package/dist/getAppConfig.d.ts.map +1 -0
- package/dist/getAppConfig.js +12 -0
- package/package.json +1 -1
package/dist/Framework.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class Framework {
|
|
|
16
16
|
build(mode: Mode): Promise<void>;
|
|
17
17
|
clean(mode?: Mode | 'staticSite'): Promise<void>;
|
|
18
18
|
staticGen(): Promise<void>;
|
|
19
|
-
private
|
|
19
|
+
private getAppConfig;
|
|
20
20
|
private compileUserApp;
|
|
21
21
|
private copyFrameworkAssets;
|
|
22
22
|
private bundle;
|
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;AAIrC,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;AAuBxD,qBAAa,SAAS;I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wBhC,SAAS;YAGD,YAAY;YAUZ,cAAc;YAOd,mBAAmB;YAYnB,MAAM;IAKd,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC;IAoBrC,aAAa,CAAC,MAAM,EAAE,uBAAuB;IAkG7C,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;CAuChD"}
|
package/dist/Framework.js
CHANGED
|
@@ -41,7 +41,7 @@ export class Framework {
|
|
|
41
41
|
_defineProperty(this, "prodServer", void 0);
|
|
42
42
|
}
|
|
43
43
|
async init() {
|
|
44
|
-
const configOrUndefined = await this.
|
|
44
|
+
const configOrUndefined = await this.getAppConfig();
|
|
45
45
|
if (configOrUndefined === undefined) {
|
|
46
46
|
throwError('Framework.init()', 'config is undefined');
|
|
47
47
|
}
|
|
@@ -88,7 +88,7 @@ export class Framework {
|
|
|
88
88
|
async staticGen() {
|
|
89
89
|
await staticGen(this);
|
|
90
90
|
}
|
|
91
|
-
async
|
|
91
|
+
async getAppConfig() {
|
|
92
92
|
const userConfigOrNull = await findUserConfig(process.cwd());
|
|
93
93
|
if (userConfigOrNull !== null) {
|
|
94
94
|
const userConfig = userConfigOrNull;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Server } from 'http';
|
|
2
2
|
import express from 'express';
|
|
3
|
+
import { FrameworkConfigComplete } from 'tungsten/FrameworkConfig.js';
|
|
3
4
|
export declare class StaticSiteServer {
|
|
5
|
+
config: FrameworkConfigComplete;
|
|
4
6
|
port: number;
|
|
5
7
|
location?: string;
|
|
6
8
|
app: express.Application;
|
|
7
9
|
server?: Server;
|
|
8
10
|
staticSiteLocation: string;
|
|
9
|
-
constructor();
|
|
11
|
+
constructor(config: FrameworkConfigComplete);
|
|
10
12
|
start: () => Promise<string>;
|
|
11
13
|
stop: () => void;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticSiteServer.d.ts","sourceRoot":"","sources":["../../src/Servers/StaticSiteServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"StaticSiteServer.d.ts","sourceRoot":"","sources":["../../src/Servers/StaticSiteServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE,qBAAa,gBAAgB;IACzB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kBAAkB,EAAE,MAAM,CAAA;gBAEd,MAAM,EAAE,uBAAuB;IAQ3C,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAQ3B;IACD,IAAI,aAEH;CACJ"}
|
|
@@ -7,14 +7,15 @@ import { staticSiteFolder } from "../settings.js";
|
|
|
7
7
|
import { cliNews } from "../cliOutput.js";
|
|
8
8
|
export class StaticSiteServer {
|
|
9
9
|
// to do
|
|
10
|
-
constructor() {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
_defineProperty(this, "config", void 0);
|
|
11
12
|
_defineProperty(this, "port", void 0);
|
|
12
13
|
_defineProperty(this, "location", void 0);
|
|
13
14
|
_defineProperty(this, "app", void 0);
|
|
14
15
|
_defineProperty(this, "server", void 0);
|
|
15
16
|
_defineProperty(this, "staticSiteLocation", void 0);
|
|
16
17
|
_defineProperty(this, "start", () => {
|
|
17
|
-
const location = this.location = `http://localhost:${this.port}`;
|
|
18
|
+
const location = this.location = `http://localhost:${this.port}${this.config.siteBasePath}`;
|
|
18
19
|
return new Promise(resolve => {
|
|
19
20
|
this.server = this.app.listen(this.port, () => {
|
|
20
21
|
cliNews(`Static preview ready at ${this.location}`);
|
|
@@ -25,10 +26,11 @@ export class StaticSiteServer {
|
|
|
25
26
|
_defineProperty(this, "stop", () => {
|
|
26
27
|
if (this.server !== undefined) this.server.close();
|
|
27
28
|
});
|
|
29
|
+
this.config = config;
|
|
28
30
|
this.port = 3001;
|
|
29
31
|
this.app = express();
|
|
30
32
|
this.staticSiteLocation = join(process.cwd(), staticSiteFolder);
|
|
31
|
-
this.app.use(express.static(this.staticSiteLocation));
|
|
32
|
-
this.app.use((req, res) => res.send('Not found').end());
|
|
33
|
+
this.app.use(this.config.siteBasePath, express.static(this.staticSiteLocation));
|
|
34
|
+
this.app.use(this.config.siteBasePath, (req, res) => res.send('Not found').end());
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/static.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/static.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import open from 'open';
|
|
2
|
+
import { getAppConfig } from 'tungsten/getAppConfig.js';
|
|
2
3
|
import { StaticSiteServer } from "../../Servers/StaticSiteServer.js";
|
|
3
|
-
const staticServer = new StaticSiteServer();
|
|
4
|
+
const staticServer = new StaticSiteServer(await getAppConfig());
|
|
4
5
|
const staticServerLocation = await staticServer.start();
|
|
5
6
|
open(staticServerLocation);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAppConfig.d.ts","sourceRoot":"","sources":["../src/getAppConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAG9D,wBAAsB,YAAY,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAQrE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defaultConfig } from "./defaultConfig.js";
|
|
2
|
+
import { findUserConfig } from "./findUserConfig.js";
|
|
3
|
+
import { makeFinalConfig } from "./makeFinalConfig.js";
|
|
4
|
+
export async function getAppConfig() {
|
|
5
|
+
const userConfigOrNull = await findUserConfig(process.cwd());
|
|
6
|
+
if (userConfigOrNull !== null) {
|
|
7
|
+
const userConfig = userConfigOrNull;
|
|
8
|
+
return makeFinalConfig(userConfig.data);
|
|
9
|
+
} else {
|
|
10
|
+
return defaultConfig;
|
|
11
|
+
}
|
|
12
|
+
}
|