stonyx 0.2.3-alpha.77 → 0.2.3-alpha.78

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stonyx",
3
- "version": "0.2.3-alpha.77",
3
+ "version": "0.2.3-alpha.78",
4
4
  "description": "Base stonyx framework module",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,16 @@
1
+ // Install-time contract of `scripts/postinstall.js`, kept as data so the publish-surface
2
+ // guard (`test/unit/publish/pack-surface-test.ts`) checks the same names the postinstall
3
+ // uses instead of reading them out of its source (abofs/stonyx#123).
4
+ //
5
+ // Pure data: no imports and no side effects. It ships in the tarball with the postinstall,
6
+ // which imports it at install time.
7
+
8
+ // Package-relative directory the templates are copied from.
9
+ export const templateDir = 'config';
10
+
11
+ // Per consumer type: the template copied out of the package, and the file it becomes
12
+ // in the consumer's `config/` directory. A `tsconfig.json` in the consumer root selects `ts`.
13
+ export const consumers = {
14
+ ts: { template: 'environment copy.ts', destination: 'environment.ts' },
15
+ js: { template: 'environment copy.js', destination: 'environment.js' },
16
+ };
@@ -4,6 +4,7 @@ if (isGlobal) process.exit(0);
4
4
 
5
5
  const { existsSync } = await import('node:fs');
6
6
  const { copyFile, createDirectory } = await import('@stonyx/utils/file');
7
+ const { templateDir, consumers } = await import('./postinstall-manifest.js');
7
8
 
8
9
  const projectDir = process.env.INIT_CWD;
9
10
  const configDir = `${projectDir}/config`;
@@ -12,26 +13,18 @@ const configDir = `${projectDir}/config`;
12
13
  // root signals a TypeScript project (see abofs/stonyx#62). TS consumers can't
13
14
  // use the `.js` stub, so we ship both templates and copy the matching one.
14
15
  const isTypeScriptConsumer = existsSync(`${projectDir}/tsconfig.json`);
15
- const extension = isTypeScriptConsumer ? 'ts' : 'js';
16
- const envFile = `environment.${extension}`;
17
- const templateFile = `environment copy.${extension}`;
16
+ const { template: templateFile, destination: envFile } = consumers[isTypeScriptConsumer ? 'ts' : 'js'];
18
17
 
19
18
  // Skip if the consumer ships its own `config/environment copy.{ts,js}` template —
20
19
  // they manage their own bootstrap (see abofs/stonyx#54, extended in abofs/stonyx#62
21
20
  // to honor either extension).
22
- if (
23
- existsSync(`${configDir}/environment copy.ts`) ||
24
- existsSync(`${configDir}/environment copy.js`)
25
- ) process.exit(0);
21
+ if (Object.values(consumers).some(({ template }) => existsSync(`${configDir}/${template}`))) process.exit(0);
26
22
 
27
23
  // 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);
24
+ if (Object.values(consumers).some(({ destination }) => existsSync(`${configDir}/${destination}`))) process.exit(0);
32
25
 
33
26
  createDirectory(configDir);
34
27
 
35
- copyFile(`./config/${templateFile}`, `${configDir}/${envFile}`).then(result => {
28
+ copyFile(`./${templateDir}/${templateFile}`, `${configDir}/${envFile}`).then(result => {
36
29
  if (result) console.log(`Stonyx: ${envFile} has been successfully created. Please see README.md for more information.`);
37
30
  });