@xnoxs/flux-lang 4.0.8 → 4.1.1

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/src/self/pkg.flux CHANGED
@@ -3,11 +3,11 @@
3
3
  // src/self/pkg.flux — written in Flux, compiled by stage-0
4
4
  //
5
5
  // Commands:
6
- // flux add <pkg[@version]> install a package (npm install --save)
7
- // flux remove <pkg> remove a package (npm uninstall)
8
- // flux install install all from package.json (npm install)
6
+ // flux add <pkg[@version]> install a flux package
7
+ // flux remove <pkg> remove a package
8
+ // flux install install all from flux.json
9
9
  // flux list list installed packages
10
- // flux search <query> search the npm registry
10
+ // flux search <query> search the registry
11
11
  // flux publish publish to registry
12
12
  // flux info <pkg> show package info
13
13
  // ============================================================
@@ -17,9 +17,11 @@ import Path from "path"
17
17
  import Https from "https"
18
18
  import Http from "http"
19
19
  import Os from "os"
20
- import { readPackage } from "./config"
20
+ import { readPackage, writeConfig, loadConfig } from "./config"
21
21
 
22
22
  val REGISTRY_URL = "https://registry.npmjs.org"
23
+ val FLUX_PKG_DIR = "flux_modules"
24
+ val PKG_FILE = "flux.json"
23
25
 
24
26
  // ── ANSI colors ───────────────────────────────────────────────
25
27
  val ESC = "\u001b"
@@ -75,6 +77,36 @@ async fn fetchJson(url):
75
77
  mod.get(url, { headers: { "User-Agent": "flux-pkg/1.0" } }, onRes).on("error", reject)
76
78
  return new Promise(doRequest)
77
79
 
80
+ // ── Ensure flux.json exists ───────────────────────────────────
81
+ fn ensureFluxJson(cwd_):
82
+ val cwd = cwd_ ?? process.cwd()
83
+ val file = Path.join(cwd, PKG_FILE)
84
+ if not Fs.existsSync(file):
85
+ val pkg = {
86
+ name: Path.basename(cwd),
87
+ version: "1.0.0",
88
+ description: "",
89
+ author: "",
90
+ license: "MIT",
91
+ scripts: {
92
+ start: "flux run src/main.flux",
93
+ build: "flux bundle src/main.flux -o dist/bundle.js",
94
+ dev: "flux watch src/main.flux",
95
+ check: "flux check src/main.flux",
96
+ },
97
+ dependencies: {},
98
+ devDependencies: {},
99
+ }
100
+ Fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + "\n", "utf8")
101
+ ok("Created flux.json")
102
+ return JSON.parse(Fs.readFileSync(file, "utf8"))
103
+
104
+ // ── Save flux.json ────────────────────────────────────────────
105
+ fn saveFluxJson(pkg, cwd_):
106
+ val cwd = cwd_ ?? process.cwd()
107
+ val file = Path.join(cwd, PKG_FILE)
108
+ Fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + "\n", "utf8")
109
+
78
110
  // ── Resolve package name@version ─────────────────────────────
79
111
  fn parsePackageSpec(spec):
80
112
  val atIdx = spec.lastIndexOf("@")
@@ -83,63 +115,124 @@ fn parsePackageSpec(spec):
83
115
  return { name: spec, version: "latest" }
84
116
 
85
117
  // ── flux add <pkg[@version]> [--dev] ─────────────────────────
86
- // Equivalent to: npm install <pkg> --save (or --save-dev)
87
118
  export async fn cmdAdd(specs, opts):
88
- import { execSync } from "child_process"
89
119
  val isDev = opts?.dev ?? false
90
120
  val cwd = process.cwd()
121
+ val pkg = ensureFluxJson(cwd)
91
122
 
92
123
  for spec in specs:
93
124
  val { name, version } = parsePackageSpec(spec)
94
- val spinner = startSpinner("Adding " + clr(C.bold, name) + clr(C.gray, "@" + version) + " ...")
125
+ val spinner = startSpinner("Fetching " + clr(C.bold, name) + clr(C.gray, "@" + version) + " ...")
95
126
 
96
127
  try:
97
- val saveFlag = isDev ? "--save-dev" : "--save"
98
- val pkgSpec = version == "latest" ? name : name + "@" + version
128
+ val info_ = await fetchJson(REGISTRY_URL + "/" + name)
129
+ val resolvedVersion = version == "latest" ? (info_["dist-tags"]?.latest ?? "1.0.0") : version
130
+
131
+ val versionInfo = info_.versions?.[resolvedVersion]
99
132
  stopSpinner(spinner)
100
- console.log(clr(C.cyan, " Adding ") + clr(C.bold, pkgSpec) + clr(C.gray, " to node_modules/ and package.json..."))
101
- execSync("npm install " + pkgSpec + " " + saveFlag, { cwd, stdio: "inherit" })
102
- ok("Added " + clr(C.bold, name) + " to node_modules/ and package.json")
133
+ if not versionInfo:
134
+ err("Version " + resolvedVersion + " not found for " + name)
135
+ continue
136
+
137
+ val depKey = isDev ? "devDependencies" : "dependencies"
138
+ if not pkg[depKey]: pkg[depKey] = {}
139
+ pkg[depKey][name] = "^" + resolvedVersion
140
+
141
+ saveFluxJson(pkg, cwd)
142
+
143
+ val desc = versionInfo.description ? clr(C.gray, " — " + versionInfo.description) : ""
144
+ ok(name + clr(C.green, "@" + resolvedVersion) + desc)
145
+ info("Added to " + (isDev ? "devDependencies" : "dependencies"))
146
+
103
147
  catch(e):
104
148
  stopSpinner(spinner)
105
- err("Failed to add " + name + ": " + e.message)
149
+ err("Failed to fetch " + name + ": " + e.message)
106
150
 
107
151
  console.log()
152
+ console.log(clr(C.gray, " Run ") + clr(C.yellow, "flux install") + clr(C.gray, " to install packages"))
153
+ console.log()
108
154
 
109
155
  // ── flux remove <pkg> ─────────────────────────────────────────
110
- // Equivalent to: npm uninstall <pkg>
111
156
  export fn cmdRemove(names, opts):
112
- import { execSync } from "child_process"
113
157
  val cwd = process.cwd()
158
+ val pkg = ensureFluxJson(cwd)
159
+ var removed = 0
114
160
 
115
161
  for name in names:
116
- try:
117
- console.log(clr(C.cyan, " Removing ") + clr(C.bold, name) + " ...")
118
- execSync("npm uninstall " + name, { cwd, stdio: "inherit" })
162
+ var found = false
163
+ if pkg.dependencies and pkg.dependencies[name]:
164
+ delete pkg.dependencies[name]
165
+ found = true
166
+ if pkg.devDependencies and pkg.devDependencies[name]:
167
+ delete pkg.devDependencies[name]
168
+ found = true
169
+
170
+ if found:
119
171
  ok("Removed " + clr(C.bold, name))
120
- catch(e):
121
- err("Failed to remove " + name + ": " + e.message)
172
+ removed = removed + 1
173
+ else:
174
+ err(name + " not found in flux.json")
175
+
176
+ if removed > 0:
177
+ saveFluxJson(pkg, cwd)
122
178
 
123
179
  // ── flux install ──────────────────────────────────────────────
124
- // Equivalent to: npm install (reads package.json)
125
180
  export async fn cmdInstall(opts):
126
181
  import { execSync } from "child_process"
127
- val cwd = process.cwd()
128
182
 
129
- val pkgJsonPath = Path.join(cwd, "package.json")
130
- if not Fs.existsSync(pkgJsonPath):
131
- err("No package.json found. Run: flux init")
183
+ val cwd = process.cwd()
184
+ val pkg = ensureFluxJson(cwd)
185
+ val fluxModDir = Path.join(cwd, "flux_modules")
186
+
187
+ val deps = pkg.dependencies ?? {}
188
+ val devDeps = pkg.devDependencies ?? {}
189
+ val all = { ...deps, ...devDeps }
190
+ val names = Object.keys(all)
191
+
192
+ if names.length == 0:
193
+ info("No dependencies found in flux.json")
132
194
  return
133
195
 
134
- console.log(clr(C.cyan, "\n Installing dependencies from package.json...\n"))
196
+ console.log(clr(C.cyan, "\n Installing ") + names.length + " package(s) into flux_modules/...\n")
197
+
198
+ for name in names:
199
+ val spec = all[name]
200
+ console.log(clr(C.gray, " ○ ") + name + clr(C.gray, "@" + spec))
201
+
202
+ console.log()
203
+
204
+ // Ensure flux_modules/ exists with a minimal package.json
205
+ if not Fs.existsSync(fluxModDir):
206
+ Fs.mkdirSync(fluxModDir, { recursive: true })
207
+
208
+ val fluxPkgFile = Path.join(fluxModDir, "package.json")
209
+ if not Fs.existsSync(fluxPkgFile):
210
+ val fluxPkg = { name: pkg.name + "-flux-modules", version: "1.0.0", private: true }
211
+ Fs.writeFileSync(fluxPkgFile, JSON.stringify(fluxPkg, null, 2) + "\n", "utf8")
212
+
213
+ val prodNames = Object.keys(deps)
214
+ val devNames = Object.keys(devDeps)
215
+
135
216
  try:
136
- execSync("npm install", { cwd, stdio: "inherit" })
217
+ if prodNames.length > 0:
218
+ val prodPkgs = prodNames.map(n -> n + "@" + (deps[n] ?? "latest")).join(" ")
219
+ val installCmd = "npm install --prefix " + fluxModDir + " " + prodPkgs
220
+ info("Running: " + installCmd)
221
+ execSync(installCmd, { cwd: cwd, stdio: "inherit" })
222
+
223
+ if devNames.length > 0:
224
+ val devPkgs = devNames.map(n -> n + "@" + (devDeps[n] ?? "latest")).join(" ")
225
+ val devCmd = "npm install --prefix " + fluxModDir + " --save-dev " + devPkgs
226
+ info("Running: " + devCmd)
227
+ execSync(devCmd, { cwd: cwd, stdio: "inherit" })
228
+
137
229
  console.log()
138
- ok("Dependencies installed into node_modules/")
230
+ ok(names.length + " package(s) installed into flux_modules/node_modules/")
231
+ info("Packages resolve automatically when using: flux run, flux bundle")
139
232
  catch(e):
140
233
  console.log()
141
234
  err("Install failed: " + e.message)
142
- info("Try manually: npm install")
235
+ info("Try manually: npm install --prefix ./flux_modules <package>")
143
236
 
144
237
  console.log()
145
238
 
@@ -149,7 +242,7 @@ export fn cmdList(opts):
149
242
  val pkg = readPackage(cwd)
150
243
 
151
244
  if not pkg:
152
- err("No package.json found. Run: flux init")
245
+ err("No flux.json found. Run: flux init")
153
246
  return
154
247
 
155
248
  console.log()
@@ -232,13 +325,12 @@ export async fn cmdInfo(name, opts):
232
325
 
233
326
  // ── flux upgrade [--check] ────────────────────────────────────
234
327
  export async fn cmdUpgrade(opts):
235
- import { execSync } from "child_process"
236
328
  val isCheck = opts?.check ?? false
237
329
  val cwd = process.cwd()
238
330
  val pkg = readPackage(cwd)
239
331
 
240
332
  if not pkg:
241
- err("No package.json found. Run: flux init")
333
+ err("No flux.json found. Run: flux init")
242
334
  return
243
335
 
244
336
  val deps = pkg.dependencies ?? {}
@@ -279,9 +371,11 @@ export async fn cmdUpgrade(opts):
279
371
  if isCheck:
280
372
  console.log(" " + clr(C.yellow, "↑ ") + clr(C.bold, name) + clr(C.gray, " " + current + " → ") + clr(C.green, "^" + latest))
281
373
  else:
374
+ val isDev = devDeps[name] != null
375
+ val depKey = isDev ? "devDependencies" : "dependencies"
376
+ pkg[depKey][name] = "^" + latest
282
377
  updated = updated + 1
283
378
  console.log(" " + clr(C.green, "✓ ") + clr(C.bold, name) + clr(C.gray, " " + current + " → ") + clr(C.green, "^" + latest))
284
- execSync("npm install " + name + "@" + latest + " --save", { cwd, stdio: "pipe" })
285
379
 
286
380
  catch(e):
287
381
  stopSpinner(spinner)
@@ -299,7 +393,9 @@ export async fn cmdUpgrade(opts):
299
393
  if updated == 0:
300
394
  ok("All packages are already up to date")
301
395
  else:
302
- ok(updated + " package(s) updated in node_modules/ and package.json")
396
+ saveFluxJson(pkg, cwd)
397
+ ok(updated + " package(s) updated in flux.json")
398
+ console.log(clr(C.gray, " Run ") + clr(C.yellow, "flux install") + clr(C.gray, " to install updated versions"))
303
399
 
304
400
  console.log()
305
401
 
@@ -309,20 +405,21 @@ export fn cmdPublish(opts):
309
405
  val pkg = readPackage(cwd)
310
406
 
311
407
  if not pkg:
312
- err("No package.json found. Run: flux init")
408
+ err("No flux.json found. Run: flux init")
313
409
  return
314
410
 
315
411
  console.log()
316
412
  console.log(clr(C.cyan, " Publishing ") + clr(C.bold, pkg.name + "@" + pkg.version) + " ...")
317
413
  console.log()
318
- info("Checking package.json...")
414
+ info("Building package...")
415
+ info("Checking flux.json...")
319
416
 
320
417
  if not pkg.name:
321
- err("package.json must have a name field")
418
+ err("flux.json must have a name field")
322
419
  return
323
420
 
324
421
  if not pkg.version:
325
- err("package.json must have a version field")
422
+ err("flux.json must have a version field")
326
423
  return
327
424
 
328
425
  console.log()
package/src/self/pkg.js CHANGED
@@ -1,6 +1,15 @@
1
- /* compiled from src/self/pkg.flux */
2
- 'use strict';
3
- // Generated by Flux Transpiler v3.5.3 (self-hosted)
1
+ // ── Flux stdlib ──
2
+
3
+ function map(arr, fn) { return arr.map(fn); }
4
+
5
+ function join(arr, sep) { return arr.join(sep != null ? sep : ','); }
6
+
7
+ function keys(obj) { return Object.keys(obj); }
8
+
9
+ function startsWith(s, prefix) { return String(s).startsWith(prefix); }
10
+ // ── end stdlib ──
11
+
12
+ // Generated by Flux Transpiler v3.2.0
4
13
  "use strict";
5
14
 
6
15
  const Fs = require("fs");
@@ -8,9 +17,11 @@ const Path = require("path");
8
17
  const Https = require("https");
9
18
  const Http = require("http");
10
19
  const Os = require("os");
11
- const { readPackage } = require("./config");
20
+ const { readPackage, writeConfig, loadConfig } = require("./config");
12
21
  const REGISTRY_URL = "https://registry.npmjs.org";
13
- const ESC = "\\u001b";
22
+ const FLUX_PKG_DIR = "flux_modules";
23
+ const PKG_FILE = "flux.json";
24
+ const ESC = "\u001b";
14
25
  const C = { reset: (ESC + "[0m"), bold: (ESC + "[1m"), dim: (ESC + "[2m"), red: (ESC + "[31m"), green: (ESC + "[32m"), yellow: (ESC + "[33m"), blue: (ESC + "[34m"), cyan: (ESC + "[36m"), gray: (ESC + "[90m") };
15
26
  function clr(c, s) {
16
27
  return ((c + s) + C.reset);
@@ -32,7 +43,7 @@ function startSpinner(label) {
32
43
  }
33
44
  let frame = 0;
34
45
  function tick() {
35
- stdout.write((((("\\r" + clr(C.cyan, SPIN_FRAMES[(frame % SPIN_FRAMES.length)])) + " ") + label) + " "));
46
+ stdout.write((((("\r" + clr(C.cyan, SPIN_FRAMES[(frame % SPIN_FRAMES.length)])) + " ") + label) + " "));
36
47
  frame = (frame + 1);
37
48
  }
38
49
  const timer = setInterval(tick, 80);
@@ -43,7 +54,7 @@ function stopSpinner(timer) {
43
54
  return;
44
55
  }
45
56
  clearInterval(timer);
46
- stdout.write((("\\r" + ESC) + "[2K"));
57
+ stdout.write((("\r" + ESC) + "[2K"));
47
58
  }
48
59
  async function fetchJson(url) {
49
60
  const mod = (url.startsWith("https") ? Https : Http);
@@ -68,6 +79,21 @@ async function fetchJson(url) {
68
79
  }
69
80
  return new Promise(doRequest);
70
81
  }
82
+ function ensureFluxJson(cwd_) {
83
+ const cwd = (cwd_ ?? process.cwd());
84
+ const file = Path.join(cwd, PKG_FILE);
85
+ if (!Fs.existsSync(file)) {
86
+ const pkg = { name: Path.basename(cwd), version: "1.0.0", description: "", author: "", license: "MIT", scripts: { start: "flux run src/main.flux", build: "flux bundle src/main.flux -o dist/bundle.js", dev: "flux watch src/main.flux", check: "flux check src/main.flux" }, dependencies: { }, devDependencies: { } };
87
+ Fs.writeFileSync(file, (JSON.stringify(pkg, null, 2) + "\n"), "utf8");
88
+ ok("Created flux.json");
89
+ }
90
+ return JSON.parse(Fs.readFileSync(file, "utf8"));
91
+ }
92
+ function saveFluxJson(pkg, cwd_) {
93
+ const cwd = (cwd_ ?? process.cwd());
94
+ const file = Path.join(cwd, PKG_FILE);
95
+ Fs.writeFileSync(file, (JSON.stringify(pkg, null, 2) + "\n"), "utf8");
96
+ }
71
97
  function parsePackageSpec(spec) {
72
98
  const atIdx = spec.lastIndexOf("@");
73
99
  if ((atIdx > 0)) {
@@ -76,61 +102,118 @@ function parsePackageSpec(spec) {
76
102
  return { name: spec, version: "latest" };
77
103
  }
78
104
  async function cmdAdd(specs, opts) {
79
- const { execSync } = require("child_process");
80
105
  const isDev = (opts?.dev ?? false);
81
106
  const cwd = process.cwd();
107
+ const pkg = ensureFluxJson(cwd);
82
108
  for (const spec of specs) {
83
109
  const { name, version } = parsePackageSpec(spec);
84
- const spinner = startSpinner(((("Adding " + clr(C.bold, name)) + clr(C.gray, ("@" + version))) + " ..."));
110
+ const spinner = startSpinner(((("Fetching " + clr(C.bold, name)) + clr(C.gray, ("@" + version))) + " ..."));
85
111
  try {
86
- const saveFlag = (isDev ? "--save-dev" : "--save");
87
- const pkgSpec = ((version == "latest") ? name : ((name + "@") + version));
112
+ const info_ = await fetchJson(((REGISTRY_URL + "/") + name));
113
+ const resolvedVersion = ((version == "latest") ? (info_["dist-tags"]?.latest ?? "1.0.0") : version);
114
+ const versionInfo = info_.versions?.[resolvedVersion];
88
115
  stopSpinner(spinner);
89
- console.log(((clr(C.cyan, " Adding ") + clr(C.bold, pkgSpec)) + clr(C.gray, " to node_modules/ and package.json...")));
90
- execSync(((("npm install " + pkgSpec) + " ") + saveFlag), { cwd, stdio: "inherit" });
91
- ok((("Added " + clr(C.bold, name)) + " to node_modules/ and package.json"));
116
+ if (!versionInfo) {
117
+ err(((("Version " + resolvedVersion) + " not found for ") + name));
118
+ continue;
119
+ }
120
+ const depKey = (isDev ? "devDependencies" : "dependencies");
121
+ if (!pkg[depKey]) {
122
+ pkg[depKey] = { };
123
+ }
124
+ pkg[depKey][name] = ("^" + resolvedVersion);
125
+ saveFluxJson(pkg, cwd);
126
+ const desc = (versionInfo.description ? clr(C.gray, (" — " + versionInfo.description)) : "");
127
+ ok(((name + clr(C.green, ("@" + resolvedVersion))) + desc));
128
+ info(("Added to " + (isDev ? "devDependencies" : "dependencies")));
92
129
  }
93
130
  catch (e) {
94
131
  stopSpinner(spinner);
95
- err(((("Failed to add " + name) + ": ") + e.message));
132
+ err(((("Failed to fetch " + name) + ": ") + e.message));
96
133
  }
97
134
  }
98
135
  console.log();
136
+ console.log(((clr(C.gray, " Run ") + clr(C.yellow, "flux install")) + clr(C.gray, " to install packages")));
137
+ console.log();
99
138
  }
100
139
  module.exports.cmdAdd = cmdAdd;
101
140
  function cmdRemove(names, opts) {
102
- const { execSync } = require("child_process");
103
141
  const cwd = process.cwd();
142
+ const pkg = ensureFluxJson(cwd);
143
+ let removed = 0;
104
144
  for (const name of names) {
105
- try {
106
- console.log(((clr(C.cyan, " Removing ") + clr(C.bold, name)) + " ..."));
107
- execSync(("npm uninstall " + name), { cwd, stdio: "inherit" });
145
+ let found = false;
146
+ if ((pkg.dependencies && pkg.dependencies[name])) {
147
+ delete pkg.dependencies[name];
148
+ found = true;
149
+ }
150
+ if ((pkg.devDependencies && pkg.devDependencies[name])) {
151
+ delete pkg.devDependencies[name];
152
+ found = true;
153
+ }
154
+ if (found) {
108
155
  ok(("Removed " + clr(C.bold, name)));
156
+ removed = (removed + 1);
109
157
  }
110
- catch (e) {
111
- err(((("Failed to remove " + name) + ": ") + e.message));
158
+ else {
159
+ err((name + " not found in flux.json"));
112
160
  }
113
161
  }
162
+ if ((removed > 0)) {
163
+ saveFluxJson(pkg, cwd);
164
+ }
114
165
  }
115
166
  module.exports.cmdRemove = cmdRemove;
116
167
  async function cmdInstall(opts) {
117
168
  const { execSync } = require("child_process");
118
169
  const cwd = process.cwd();
119
- const pkgJsonPath = Path.join(cwd, "package.json");
120
- if (!Fs.existsSync(pkgJsonPath)) {
121
- err("No package.json found. Run: flux init");
170
+ const pkg = ensureFluxJson(cwd);
171
+ const fluxModDir = Path.join(cwd, "flux_modules");
172
+ const deps = (pkg.dependencies ?? { });
173
+ const devDeps = (pkg.devDependencies ?? { });
174
+ const all = { ...deps, ...devDeps };
175
+ const names = Object.keys(all);
176
+ if ((names.length == 0)) {
177
+ info("No dependencies found in flux.json");
122
178
  return;
123
179
  }
124
- console.log(clr(C.cyan, "\n Installing dependencies from package.json...\n"));
180
+ console.log(((clr(C.cyan, "\n Installing ") + names.length) + " package(s) into flux_modules/...\n"));
181
+ for (const name of names) {
182
+ const spec = all[name];
183
+ console.log(((clr(C.gray, " ○ ") + name) + clr(C.gray, ("@" + spec))));
184
+ }
185
+ console.log();
186
+ if (!Fs.existsSync(fluxModDir)) {
187
+ Fs.mkdirSync(fluxModDir, { recursive: true });
188
+ }
189
+ const fluxPkgFile = Path.join(fluxModDir, "package.json");
190
+ if (!Fs.existsSync(fluxPkgFile)) {
191
+ const fluxPkg = { name: (pkg.name + "-flux-modules"), version: "1.0.0", private: true };
192
+ Fs.writeFileSync(fluxPkgFile, (JSON.stringify(fluxPkg, null, 2) + "\n"), "utf8");
193
+ }
194
+ const prodNames = Object.keys(deps);
195
+ const devNames = Object.keys(devDeps);
125
196
  try {
126
- execSync("npm install", { cwd, stdio: "inherit" });
197
+ if ((prodNames.length > 0)) {
198
+ const prodPkgs = prodNames.map((n) => ((n + "@") + (deps[n] ?? "latest"))).join(" ");
199
+ const installCmd = ((("npm install --prefix " + fluxModDir) + " ") + prodPkgs);
200
+ info(("Running: " + installCmd));
201
+ execSync(installCmd, { cwd, stdio: "inherit" });
202
+ }
203
+ if ((devNames.length > 0)) {
204
+ const devPkgs = devNames.map((n) => ((n + "@") + (devDeps[n] ?? "latest"))).join(" ");
205
+ const devCmd = ((("npm install --prefix " + fluxModDir) + " --save-dev ") + devPkgs);
206
+ info(("Running: " + devCmd));
207
+ execSync(devCmd, { cwd, stdio: "inherit" });
208
+ }
127
209
  console.log();
128
- ok("Dependencies installed into node_modules/");
210
+ ok((names.length + " package(s) installed into flux_modules/node_modules/"));
211
+ info("Packages resolve automatically when using: flux run, flux bundle");
129
212
  }
130
213
  catch (e) {
131
214
  console.log();
132
215
  err(("Install failed: " + e.message));
133
- info("Try manually: npm install");
216
+ info("Try manually: npm install --prefix ./flux_modules <package>");
134
217
  }
135
218
  console.log();
136
219
  }
@@ -139,7 +222,7 @@ function cmdList(opts) {
139
222
  const cwd = process.cwd();
140
223
  const pkg = readPackage(cwd);
141
224
  if (!pkg) {
142
- err("No package.json found. Run: flux init");
225
+ err("No flux.json found. Run: flux init");
143
226
  return;
144
227
  }
145
228
  console.log();
@@ -228,12 +311,11 @@ async function cmdInfo(name, opts) {
228
311
  }
229
312
  module.exports.cmdInfo = cmdInfo;
230
313
  async function cmdUpgrade(opts) {
231
- const { execSync } = require("child_process");
232
314
  const isCheck = (opts?.check ?? false);
233
315
  const cwd = process.cwd();
234
316
  const pkg = readPackage(cwd);
235
317
  if (!pkg) {
236
- err("No package.json found. Run: flux init");
318
+ err("No flux.json found. Run: flux init");
237
319
  return;
238
320
  }
239
321
  const deps = (pkg.dependencies ?? { });
@@ -274,9 +356,11 @@ async function cmdUpgrade(opts) {
274
356
  console.log(((((" " + clr(C.yellow, "↑ ")) + clr(C.bold, name)) + clr(C.gray, ((" " + current) + " → "))) + clr(C.green, ("^" + latest))));
275
357
  }
276
358
  else {
359
+ const isDev = (devDeps[name] != null);
360
+ const depKey = (isDev ? "devDependencies" : "dependencies");
361
+ pkg[depKey][name] = ("^" + latest);
277
362
  updated = (updated + 1);
278
363
  console.log(((((" " + clr(C.green, "✓ ")) + clr(C.bold, name)) + clr(C.gray, ((" " + current) + " → "))) + clr(C.green, ("^" + latest))));
279
- execSync((((("npm install " + name) + "@") + latest) + " --save"), { cwd, stdio: "pipe" });
280
364
  }
281
365
  }
282
366
  }
@@ -300,7 +384,9 @@ async function cmdUpgrade(opts) {
300
384
  ok("All packages are already up to date");
301
385
  }
302
386
  else {
303
- ok((updated + " package(s) updated in node_modules/ and package.json"));
387
+ saveFluxJson(pkg, cwd);
388
+ ok((updated + " package(s) updated in flux.json"));
389
+ console.log(((clr(C.gray, " Run ") + clr(C.yellow, "flux install")) + clr(C.gray, " to install updated versions")));
304
390
  }
305
391
  }
306
392
  console.log();
@@ -310,19 +396,20 @@ function cmdPublish(opts) {
310
396
  const cwd = process.cwd();
311
397
  const pkg = readPackage(cwd);
312
398
  if (!pkg) {
313
- err("No package.json found. Run: flux init");
399
+ err("No flux.json found. Run: flux init");
314
400
  return;
315
401
  }
316
402
  console.log();
317
403
  console.log(((clr(C.cyan, " Publishing ") + clr(C.bold, ((pkg.name + "@") + pkg.version))) + " ..."));
318
404
  console.log();
319
- info("Checking package.json...");
405
+ info("Building package...");
406
+ info("Checking flux.json...");
320
407
  if (!pkg.name) {
321
- err("package.json must have a name field");
408
+ err("flux.json must have a name field");
322
409
  return;
323
410
  }
324
411
  if (!pkg.version) {
325
- err("package.json must have a version field");
412
+ err("flux.json must have a version field");
326
413
  return;
327
414
  }
328
415
  console.log();
@@ -24,7 +24,7 @@ fn _readFluxVersion():
24
24
  val pkgPath = Path.resolve(__dirname, "../../package.json")
25
25
  return JSON.parse(Fs.readFileSync(pkgPath, "utf8")).version
26
26
  catch(e):
27
- return "4.0.7"
27
+ return "4.0.1"
28
28
 
29
29
  export val FLUX_VERSION = _readFluxVersion()
30
30
  export val FLUX_STAGE = "self-hosted"
@@ -1,5 +1,3 @@
1
- /* compiled from src/self/transpiler.flux */
2
- 'use strict';
3
1
  // Generated by Flux Transpiler v3.2.0
4
2
  "use strict";
5
3
 
@@ -18,7 +16,7 @@ function _readFluxVersion() {
18
16
  return JSON.parse(Fs.readFileSync(pkgPath, "utf8")).version;
19
17
  }
20
18
  catch (e) {
21
- return "4.0.7";
19
+ return "4.0.1";
22
20
  }
23
21
  }
24
22
  const FLUX_VERSION = _readFluxVersion();