fullstacked 1.0.0-alpha.1808 → 1.0.0-alpha.1809

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 (2) hide show
  1. package/index.js +47 -4
  2. package/package.json +11 -10
package/index.js CHANGED
@@ -8228,7 +8228,7 @@ var Exit = 5;
8228
8228
  init_isWorker();
8229
8229
 
8230
8230
  // ../../core/internal/bundle/lib/process/version.json
8231
- var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1808", hash: "0b60696bc01cacf5ddd4b54df2c35fb2aaf716c8" };
8231
+ var version_default = { major: "1", minor: "0", patch: "0-alpha", branch: "v1", build: "1809", hash: "ca6ffb93b40c36088e8f76c5e53b1927db21829c" };
8232
8232
 
8233
8233
  // ../../core/internal/bundle/lib/timers/index.ts
8234
8234
  var setTimeout2 = globalThis.setTimeout.bind(globalThis);
@@ -9695,6 +9695,39 @@ function getExtraArgs(args2) {
9695
9695
  }
9696
9696
  return extraArgs;
9697
9697
  }
9698
+ function parseEnv(src) {
9699
+ const obj = {};
9700
+ const text = src.replace(/\r\n?/gm, "\n");
9701
+ const lineRegex = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
9702
+ let match;
9703
+ while ((match = lineRegex.exec(text)) !== null) {
9704
+ const key = match[1];
9705
+ let val = (match[2] || "").trim();
9706
+ const firstChar = val[0];
9707
+ val = val.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
9708
+ if (firstChar === '"') {
9709
+ val = val.replace(/\\n/g, "\n").replace(/\\r/g, "\r");
9710
+ }
9711
+ obj[key] = val;
9712
+ }
9713
+ return obj;
9714
+ }
9715
+ async function loadEnvFile(envPath) {
9716
+ try {
9717
+ const stats = await fs_default.promises.stat(envPath);
9718
+ if (typeof stats.isDirectory === "function" && stats.isDirectory()) {
9719
+ return {};
9720
+ }
9721
+ const content = await fs_default.promises.readFile(envPath, {
9722
+ encoding: "utf-8"
9723
+ });
9724
+ return parseEnv(
9725
+ typeof content === "string" ? content : new TextDecoder().decode(content)
9726
+ );
9727
+ } catch {
9728
+ return {};
9729
+ }
9730
+ }
9698
9731
  async function bundleAndImportFile(file, startDir, writeErr, extraArgs) {
9699
9732
  if (!file || file.trim() === "") {
9700
9733
  writeErr(formatMessage("Error: no file specified.", false));
@@ -9964,19 +9997,29 @@ Directory:
9964
9997
  const pluginsArgs = findArgValues(["-p", "--plugin"], args2);
9965
9998
  const safe = hasArgFlag(["-s", "--safe"], args2);
9966
9999
  const positionals = getPositionalArgs(args2);
9967
- const env2 = {};
10000
+ const cliEnv = {};
9968
10001
  for (const val of envArgs) {
9969
10002
  const index = val.indexOf("=");
9970
10003
  if (index !== -1) {
9971
- env2[val.slice(0, index)] = val.slice(index + 1);
10004
+ cliEnv[val.slice(0, index)] = val.slice(index + 1);
9972
10005
  } else if (val) {
9973
- env2[val] = "";
10006
+ cliEnv[val] = "";
9974
10007
  }
9975
10008
  }
9976
10009
  if (file) {
10010
+ const envPath2 = path_default.resolve(".env");
10011
+ const fileEnv2 = await loadEnvFile(envPath2);
10012
+ const env3 = { ...fileEnv2, ...cliEnv };
10013
+ for (const [key, value] of Object.entries(env3)) {
10014
+ process.env[key] = value;
10015
+ }
9977
10016
  const extraArgs = getExtraArgs(args2);
9978
10017
  return runFile(file, extraArgs, writeOut, writeErr);
9979
10018
  }
10019
+ const targetDirectory = path_default.resolve(positionals.at(-1) || ".");
10020
+ const envPath = path_default.resolve(targetDirectory, ".env");
10021
+ const fileEnv = await loadEnvFile(envPath);
10022
+ const env2 = { ...fileEnv, ...cliEnv };
9980
10023
  return runDirectory(
9981
10024
  positionals,
9982
10025
  pluginsArgs,
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "fullstacked",
3
- "version": "1.0.0-alpha.1808",
3
+ "version": "1.0.0-alpha.1809",
4
4
  "bin": {
5
5
  "fullstacked": "index.js"
6
6
  },
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "build": "node build.ts",
10
- "prepack": "npm run build"
10
+ "prepack": "node prepare-package.ts --inject",
11
+ "postpack": "node prepare-package.ts --clean"
11
12
  },
12
13
  "dependencies": {
13
14
  "open": "^11.0.4",
@@ -18,14 +19,6 @@
18
19
  "esbuild": "^0.28.2",
19
20
  "node-addon-api": "^8.9.2"
20
21
  },
21
- "optionalDependencies": {
22
- "@fullstacked/darwin-arm64": "1.0.0-alpha.1808",
23
- "@fullstacked/darwin-x64": "1.0.0-alpha.1808",
24
- "@fullstacked/linux-arm64": "1.0.0-alpha.1808",
25
- "@fullstacked/linux-x64": "1.0.0-alpha.1808",
26
- "@fullstacked/win32-arm64": "1.0.0-alpha.1808",
27
- "@fullstacked/win32-x64": "1.0.0-alpha.1808"
28
- },
29
22
  "author": "FullStacked",
30
23
  "license": "MIT",
31
24
  "description": "The Portable JavaScript Runtime",
@@ -65,5 +58,13 @@
65
58
  "./tunnel": {
66
59
  "types": "./types/tunnel/index.d.ts"
67
60
  }
61
+ },
62
+ "optionalDependencies": {
63
+ "@fullstacked/darwin-arm64": "1.0.0-alpha.1809",
64
+ "@fullstacked/darwin-x64": "1.0.0-alpha.1809",
65
+ "@fullstacked/linux-arm64": "1.0.0-alpha.1809",
66
+ "@fullstacked/linux-x64": "1.0.0-alpha.1809",
67
+ "@fullstacked/win32-arm64": "1.0.0-alpha.1809",
68
+ "@fullstacked/win32-x64": "1.0.0-alpha.1809"
68
69
  }
69
70
  }