tungsten 0.2.11 → 0.2.12

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.js CHANGED
@@ -20,7 +20,7 @@ import { staticGen } from "./staticGen/staticGen.js";
20
20
  import { throwError } from "./throwError.js";
21
21
  //import { devBundle } from './build/devBundle.jsx'
22
22
  import { existsSync, readFileSync, openSync, closeSync, writeFileSync, copyFileSync } from 'fs';
23
- import { parseIni } from "./parseIni.js";
23
+ import dotenv from 'dotenv';
24
24
  import { getEnvSchemas } from "./env/getEnvSchemas.js";
25
25
  import { injectEnv } from "./env/injectEnv.js";
26
26
  //import { ValueOf } from 'sxy-lib'
@@ -167,7 +167,7 @@ export class Framework {
167
167
  let someEnvLoaded = false; // eslint-disable-line no-type-assertion/no-type-assertion -- widening
168
168
  //const envsLoadedMessages: string[] = []
169
169
  function loadEnv(fileName, filePath, prefix = '') {
170
- const env = parseIni(readFileSync(filePath, 'utf-8'));
170
+ const env = dotenv.parse(readFileSync(filePath, 'utf-8'));
171
171
  someEnvLoaded = true;
172
172
  cliOut(`${fileName} loaded from ${filePath}`);
173
173
  injectEnv(env, process.env, prefix);
@@ -1 +1 @@
1
- {"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAQpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAE/B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,EACnB,eAAe,UAAQ,iBAuH1B"}
1
+ {"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAQpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAE/B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,EACnB,eAAe,UAAQ,iBAsH1B"}
@@ -2,7 +2,7 @@ import { join } from 'path';
2
2
  import { readFile as readFilePromise, access as accessPromise } from 'fs/promises';
3
3
  import { remap as objectRemap, filter as objectFilter } from 'sxy-lib/objects.js';
4
4
  import { getEnvSchemasDev } from "../env/getEnvSchemas.js";
5
- import { parseIni } from "../parseIni.js";
5
+ import dotenv from 'dotenv';
6
6
  import { cliLog, cliOut } from "../cliOutput.js";
7
7
  import { injectEnv } from "../env/injectEnv.js";
8
8
  import { throwError } from 'tungsten/throwError.js';
@@ -38,7 +38,7 @@ iteration, initialProcessEnv, _firstLoad, useTestEnvFiles = false) {
38
38
  const tryLoadEnvFile = async (fileName, filePath, prefix = '') => {
39
39
  try {
40
40
  //cliOut(`try to load env from ${filePath}`)
41
- const env = parseIni(await readFilePromise(filePath, 'utf-8'));
41
+ const env = dotenv.parse(await readFilePromise(filePath, 'utf-8'));
42
42
  someEnvLoaded = true;
43
43
  if (_firstLoad) cliOut(`${fileName} loaded from ${filePath}`);
44
44
  //cliOut(fileName, JSON.stringify(env, null, 4))
@@ -53,7 +53,10 @@ iteration, initialProcessEnv, _firstLoad, useTestEnvFiles = false) {
53
53
  }
54
54
  };
55
55
  const [envPath, privateEnvPath, publicEnvPath] = await Promise.all([resolveEnvFile(envLocation, testEnvLocation), resolveEnvFile(privateEnvLocation, testPrivateEnvLocation), resolveEnvFile(publicEnvLocation, testPublicEnvLocation)]);
56
- await Promise.all([tryLoadEnvFile('.env', envPath), tryLoadEnvFile('.env.private', privateEnvPath), tryLoadEnvFile('.env.public', publicEnvPath, 'TUNGSTEN_PUBLIC_')]);
56
+ // sequential, so later files override earlier ones consistently with prod (Framework.ts)
57
+ await tryLoadEnvFile('.env', envPath);
58
+ await tryLoadEnvFile('.env.private', privateEnvPath);
59
+ await tryLoadEnvFile('.env.public', publicEnvPath, 'TUNGSTEN_PUBLIC_');
57
60
  if (_firstLoad && !someEnvLoaded) cliOut('No env files were loaded');
58
61
  //console.log('check for schemas')
59
62
  // If there are env schemas, load the relevant env and parse with schemas
@@ -62,14 +65,18 @@ iteration, initialProcessEnv, _firstLoad, useTestEnvFiles = false) {
62
65
  // global.tungstenPrivateEnv = envSchemas.privateEnvSchema.parse(process.env)
63
66
  const result = envSchemas.privateEnvSchema.safeParse(tempEnv);
64
67
  if (!result.success) {
65
- throwError('Your environment variables failed your privateEnvSchema validation', '\n' + JSON.stringify(result.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed env ' + JSON.stringify(tempEnv, null, 4));
68
+ throwError('Your environment variables failed your privateEnvSchema validation', '\n' + JSON.stringify(result.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4)
69
+ //+ '\nparsed env ' + JSON.stringify(tempEnv, null, 4)
70
+ );
66
71
  }
67
72
  const coreResult = tungstenCorePrivateEnvSchema.safeParse(result.data);
68
73
  //console.log('coreResult', coreResult)
69
74
  if (!coreResult.success) {
70
75
  throwError('Your private environment variables don\'t meet the Tungsten requirements. Ensure your .env and privateEnvSchema provide an output meeting these requirements. You may need to coerce data to the correct type.',
71
76
  // eslint-disable-line max-len
72
- '\n' + JSON.stringify(coreResult.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed env ' + JSON.stringify(tempEnv, null, 4));
77
+ '\n' + JSON.stringify(coreResult.error.format(), null, 4) + '\nenv: ' + JSON.stringify(tempEnv, null, 4)
78
+ //+ '\nparsed env ' + JSON.stringify(tempEnv, null, 4)
79
+ );
73
80
  }
74
81
  global.tungstenPrivateEnv = result.data;
75
82
  //console.log('global.tungstenPrivateEnv', global.tungstenPrivateEnv)
@@ -1,3 +1,3 @@
1
1
  export function portError(port) {
2
- return `Invalid port: '${port}'. Did you specify 'TUNGSTEN_SERVER_PORT' in .env, .private.env or .public.env?`;
2
+ return `Invalid port: '${port}'. Did you specify 'TUNGSTEN_SERVER_PORT' in .env, .env.private or .env.public?`;
3
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/dev.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/dev.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAE,CAAA"}
@@ -1,10 +1,8 @@
1
1
  import open from 'open';
2
2
  import { cliOut } from "../../cliOutput.js";
3
3
  import { Framework } from "../../Framework.js";
4
- import dotenv from 'dotenv';
5
- dotenv.config({
6
- path: '.private.env'
7
- });
4
+ //import dotenv from 'dotenv'
5
+ //dotenv.config({ path: '.private.env' })
8
6
  cliOut(`Starting dev mode`);
9
7
  //// prep the app
10
8
  const sxyFramework = new Framework();
@@ -1,8 +1,6 @@
1
1
  import { Framework } from "../../Framework.js";
2
- import dotenv from 'dotenv';
3
- dotenv.config({
4
- path: '.private.env'
5
- });
2
+ //import dotenv from 'dotenv'
3
+ //dotenv.config({ path: '.private.env' })
6
4
  console.log('tungsten start');
7
5
  //// prep the framework
8
6
  const framework = new Framework();
@@ -4,7 +4,7 @@ export function privateEnv(key) {
4
4
  if (isClient) throw new Error('Error, tried to access privateEnv from client');
5
5
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
6
6
  if (tungstenPrivateEnv === undefined) {
7
- throwError('publicEnv', 'Tungsten Private Env is undefined - do you have a .env or .private.env file?');
7
+ throwError('publicEnv', 'Tungsten Private Env is undefined - do you have a .env or .env.private file?');
8
8
  }
9
9
  return tungstenPrivateEnv[key];
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import { privateEnv } from "./privateEnv.js";
2
2
  export function privateEnvOrThrow(key) {
3
3
  const v = privateEnv(key);
4
- if (v === undefined) throw new Error(`${String(key)} is missing from .public.env`);
4
+ if (v === undefined) throw new Error(`${String(key)} is missing from .env.private`);
5
5
  return v;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import { throwError } from "../throwError.js";
2
2
  export function publicEnv(key) {
3
- if (tungstenPublicEnv === undefined) throwError('publicEnv', 'Tungsten Public Env is undefined - do you have a .public.env file?');
3
+ if (tungstenPublicEnv === undefined) throwError('publicEnv', 'Tungsten Public Env is undefined - do you have a .env.public file?');
4
4
  return tungstenPublicEnv[key];
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import { publicEnv } from "./publicEnv.js";
2
2
  export function publicEnvOrThrow(key) {
3
3
  const v = publicEnv(key);
4
- if (v === undefined) throw new Error(`${String(key)} is missing from .public.env`);
4
+ if (v === undefined) throw new Error(`${String(key)} is missing from .env.public`);
5
5
  return v;
6
6
  }
@@ -1,2 +1,2 @@
1
- export declare const possibleEnvFiles: string[];
1
+ export {};
2
2
  //# sourceMappingURL=possibleEnvFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"possibleEnvFiles.d.ts","sourceRoot":"","sources":["../src/possibleEnvFiles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,UAAmD,CAAA"}
1
+ {"version":3,"file":"possibleEnvFiles.d.ts","sourceRoot":"","sources":["../src/possibleEnvFiles.ts"],"names":[],"mappings":""}
@@ -1 +1,2 @@
1
- export const possibleEnvFiles = ['.env.js', '.private.env.js', '.public.env.js'];
1
+ export {};
2
+ //export const possibleEnvFiles = ['.env.js', '.private.env.js', '.public.env.js']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tungsten",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +0,0 @@
1
- export declare function parseIni(content: string): Record<string, string>;
2
- export declare function parseIniFile(file: string): Promise<Record<string, string>>;
3
- export declare function parseIniFileSync(file: string): Record<string, string>;
4
- //# sourceMappingURL=parseIni.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseIni.d.ts","sourceRoot":"","sources":["../src/parseIni.ts"],"names":[],"mappings":"AAIA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEhE;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEhF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAErE"}
package/dist/parseIni.js DELETED
@@ -1,11 +0,0 @@
1
- import { promises as fsPromises, readFileSync } from 'fs';
2
- import ini from 'ini';
3
- export function parseIni(content) {
4
- return ini.parse(content);
5
- }
6
- export async function parseIniFile(file) {
7
- return parseIni(await fsPromises.readFile(file, 'utf-8'));
8
- }
9
- export function parseIniFileSync(file) {
10
- return parseIni(readFileSync(file, 'utf-8'));
11
- }