@crustjs/crust 0.5.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -85,7 +85,8 @@ type BuildResult = {
85
85
  * options or package.json, a missing or hung compiler, an engines mismatch) leave the
86
86
  * previous `.crust/` stage untouched; later failures leave a wiped stage
87
87
  * without a completion `manifest.json`. Overlapping calls for the same real
88
- * project directory in this process are rejected before staging.
88
+ * project directory are rejected across processes before staging. An interrupted
89
+ * process may leave `.crust.lock`; remove it only when no build is running.
89
90
  */
90
91
  export declare function build(options?: BuildOptions): Promise<BuildResult>;
91
92
  //#endregion
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { accessSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
1
+ import { accessSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
2
2
  import { chmod, copyFile, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep, win32 } from "node:path";
@@ -1577,6 +1577,12 @@ style.link;
1577
1577
  style.fg;
1578
1578
  style.bg;
1579
1579
  //#endregion
1580
+ //#region ../utils/dist/error.js
1581
+ /** Narrows a caught Node.js system error to its stable errno contract. */
1582
+ function isErrnoException(error) {
1583
+ return error instanceof Error && "code" in error && typeof error.code === "string";
1584
+ }
1585
+ //#endregion
1580
1586
  //#region ../utils/dist/json.js
1581
1587
  /** Narrow a JSON document root to an object (not array/scalar/null). */
1582
1588
  function isJsonObject(value) {
@@ -1608,7 +1614,7 @@ const BUILD_OUT_DIR_ENV = "CRUST_INTERNAL_BUILD_OUT_DIR";
1608
1614
  */
1609
1615
  const PACKAGED_BUILD_KEY = "crustjs.packagedBuild";
1610
1616
  //#endregion
1611
- //#region ../core/dist/invocation-ljkrw2dt.js
1617
+ //#region ../core/dist/invocation-CD299Gic.js
1612
1618
  /**
1613
1619
  * A typed error for runtime recipe, Extension, Context, documentation, argv, and validation failures.
1614
1620
  *
@@ -1656,7 +1662,6 @@ var CrustError = class extends Error {
1656
1662
  };
1657
1663
  }
1658
1664
  };
1659
- globalThis.AsyncDisposableStack;
1660
1665
  Object.freeze({ [Symbol("crust.finished")]: true });
1661
1666
  /**
1662
1667
  * Snapshot subprocess protocol used by first-party build tooling.
@@ -1683,12 +1688,6 @@ function defineExtensionId(id) {
1683
1688
  return id;
1684
1689
  }
1685
1690
  //#endregion
1686
- //#region ../utils/dist/error.js
1687
- /** Narrows a caught Node.js system error to its stable errno contract. */
1688
- function isErrnoException(error) {
1689
- return error instanceof Error && "code" in error && typeof error.code === "string";
1690
- }
1691
- //#endregion
1692
1691
  //#region ../utils/dist/process.js
1693
1692
  const WINDOWS_SHELL_UNSAFE = /[\0\r\n"%!^`<>&|]/;
1694
1693
  const WINDOWS_SHELL_META = /([()\][%!^"`<>&|;, *?])/g;
@@ -4593,7 +4592,6 @@ async function prepareEntries(plan, io, runner) {
4593
4592
  }
4594
4593
  return reports;
4595
4594
  }
4596
- const activeBuilds = /* @__PURE__ */ new Set();
4597
4595
  /**
4598
4596
  * Stages the publishable npm tree in `<cwd>/.crust` for one runtime/artifact
4599
4597
  * combination: a root package with one `bin/<command>.js` per package.json
@@ -4611,13 +4609,19 @@ const activeBuilds = /* @__PURE__ */ new Set();
4611
4609
  * options or package.json, a missing or hung compiler, an engines mismatch) leave the
4612
4610
  * previous `.crust/` stage untouched; later failures leave a wiped stage
4613
4611
  * without a completion `manifest.json`. Overlapping calls for the same real
4614
- * project directory in this process are rejected before staging.
4612
+ * project directory are rejected across processes before staging. An interrupted
4613
+ * process may leave `.crust.lock`; remove it only when no build is running.
4615
4614
  */
4616
4615
  async function build(options = {}) {
4617
4616
  const cwd = resolve(options.cwd ?? process.cwd());
4618
4617
  const project = realpathSync(cwd);
4619
- if (activeBuilds.has(project)) throw new Error(`crust build is already building ${project}`);
4620
- activeBuilds.add(project);
4618
+ const lockDir = join(project, `${CRUST_DIR}.lock`);
4619
+ try {
4620
+ mkdirSync(lockDir);
4621
+ } catch (error) {
4622
+ if (!isErrnoException(error) || error.code !== "EEXIST") throw error;
4623
+ throw new Error(`crust build is already building ${project}, or an interrupted build left its lock.\n Remove ${lockDir} only after confirming no build is running.`, { cause: error });
4624
+ }
4621
4625
  try {
4622
4626
  const onLog = options.onLog ?? (() => {});
4623
4627
  const io = {
@@ -4640,7 +4644,7 @@ async function build(options = {}) {
4640
4644
  ...reports ? { reports } : {}
4641
4645
  };
4642
4646
  } finally {
4643
- activeBuilds.delete(project);
4647
+ rmdirSync(lockDir);
4644
4648
  }
4645
4649
  }
4646
4650
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crustjs/crust",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "CLI tooling for the Crust framework",
5
5
  "license": "MIT",
6
6
  "author": "chenxin-yan",
@@ -37,14 +37,14 @@
37
37
  "crust": "bin/crust.js"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@crustjs/crust-linux-x64": "0.5.0",
41
- "@crustjs/crust-linux-arm64": "0.5.0",
42
- "@crustjs/crust-linux-x64-musl": "0.5.0",
43
- "@crustjs/crust-linux-arm64-musl": "0.5.0",
44
- "@crustjs/crust-darwin-x64": "0.5.0",
45
- "@crustjs/crust-darwin-arm64": "0.5.0",
46
- "@crustjs/crust-windows-x64": "0.5.0",
47
- "@crustjs/crust-windows-arm64": "0.5.0",
40
+ "@crustjs/crust-linux-x64": "0.5.1",
41
+ "@crustjs/crust-linux-arm64": "0.5.1",
42
+ "@crustjs/crust-linux-x64-musl": "0.5.1",
43
+ "@crustjs/crust-linux-arm64-musl": "0.5.1",
44
+ "@crustjs/crust-darwin-x64": "0.5.1",
45
+ "@crustjs/crust-darwin-arm64": "0.5.1",
46
+ "@crustjs/crust-windows-x64": "0.5.1",
47
+ "@crustjs/crust-windows-arm64": "0.5.1",
48
48
  "tsdown": "0.23.0",
49
49
  "@tsdown/exe": "0.23.0"
50
50
  },