@xnoxs/flux-lang 4.0.8 → 4.0.9

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