stonyx 0.2.3-beta.59 → 0.2.3-beta.60
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/config/environment copy.ts +16 -0
- package/package.json +1 -1
- package/scripts/postinstall.js +22 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StoynxConfig } from 'stonyx';
|
|
2
|
+
|
|
3
|
+
// project configuration, override-able by listed environment variables
|
|
4
|
+
const {
|
|
5
|
+
DEBUG,
|
|
6
|
+
NODE_ENV,
|
|
7
|
+
} = process.env;
|
|
8
|
+
|
|
9
|
+
const environment = NODE_ENV ?? 'development';
|
|
10
|
+
|
|
11
|
+
const config: StoynxConfig = {
|
|
12
|
+
environment,
|
|
13
|
+
debug: DEBUG ?? environment === 'development',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default config;
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -7,14 +7,31 @@ const { copyFile, createDirectory } = await import('@stonyx/utils/file');
|
|
|
7
7
|
|
|
8
8
|
const projectDir = process.env.INIT_CWD;
|
|
9
9
|
const configDir = `${projectDir}/config`;
|
|
10
|
-
const envFile = 'environment.js';
|
|
11
10
|
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
11
|
+
// Detect consumer project type: presence of `tsconfig.json` in the consumer
|
|
12
|
+
// root signals a TypeScript project (see abofs/stonyx#62). TS consumers can't
|
|
13
|
+
// use the `.js` stub, so we ship both templates and copy the matching one.
|
|
14
|
+
const isTypeScriptConsumer = existsSync(`${projectDir}/tsconfig.json`);
|
|
15
|
+
const extension = isTypeScriptConsumer ? 'ts' : 'js';
|
|
16
|
+
const envFile = `environment.${extension}`;
|
|
17
|
+
const templateFile = `environment copy.${extension}`;
|
|
18
|
+
|
|
19
|
+
// Skip if the consumer ships its own `config/environment copy.{ts,js}` template —
|
|
20
|
+
// they manage their own bootstrap (see abofs/stonyx#54, extended in abofs/stonyx#62
|
|
21
|
+
// to honor either extension).
|
|
22
|
+
if (
|
|
23
|
+
existsSync(`${configDir}/environment copy.ts`) ||
|
|
24
|
+
existsSync(`${configDir}/environment copy.js`)
|
|
25
|
+
) process.exit(0);
|
|
26
|
+
|
|
27
|
+
// Don't overwrite an existing consumer config (either extension).
|
|
28
|
+
if (
|
|
29
|
+
existsSync(`${configDir}/environment.ts`) ||
|
|
30
|
+
existsSync(`${configDir}/environment.js`)
|
|
31
|
+
) process.exit(0);
|
|
15
32
|
|
|
16
33
|
createDirectory(configDir);
|
|
17
34
|
|
|
18
|
-
copyFile(`./config
|
|
35
|
+
copyFile(`./config/${templateFile}`, `${configDir}/${envFile}`).then(result => {
|
|
19
36
|
if (result) console.log(`Stonyx: ${envFile} has been successfully created. Please see README.md for more information.`);
|
|
20
37
|
});
|