@orkestrel/scaffold 0.0.88 → 0.0.89

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.
@@ -6,7 +6,9 @@
6
6
  // --whoami reads `npm whoami` once, or polls it every 5 seconds until it answers or the wait ends.
7
7
  // --login prints the command the operator runs in a real terminal (npm offers its approval only to a
8
8
  // TTY, so no child of this script can hold it), then polls `npm whoami` until it answers or the wait
9
- // ends. --publish re-reads `npm whoami` immediately before the first upload and refuses when it
9
+ // ends. --publish refuses linked worktrees and submodules found at a package or its ancestors,
10
+ // and names a linked worktree's primary clone.
11
+ // It then re-reads `npm whoami` immediately before the first upload and refuses when it
10
12
  // answers nothing, then runs `npm publish --ignore-scripts --browser=false --otp=CODE` in each
11
13
  // directory back to back under captured pipes (npm's non-TTY guard turns a refused code into
12
14
  // EOTP with no prompt, so the path needs no TTY), journals each upload to tmp/units/publish-<name>.log, reads the `+ name@version`
@@ -14,14 +16,14 @@
14
16
  // each accepted version against the registry. --confirm re-reads the registry for each name@version every 5
15
17
  // seconds until it serves the version or the wait (default 120 seconds) ends. Exit 0 when the mode
16
18
  // succeeded, 3 when it did not, 64 on usage.
17
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
18
- import { join } from 'node:path';
19
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
20
+ import { dirname, join, resolve } from 'node:path';
19
21
  import { readList, readMissingFlags, readOption, readString, runNpm, } from "../../orkestrel-dispatch/scripts/helpers.js";
20
22
  const POLL_MS = 5_000;
21
23
  const ACCEPTED = /^\+ (\S+)@(\S+)\s*$/mu;
22
24
  function waitFor(ms) {
23
- return new Promise((resolve) => {
24
- setTimeout(resolve, ms);
25
+ return new Promise((settle) => {
26
+ setTimeout(settle, ms);
25
27
  });
26
28
  }
27
29
  function readWhoami() {
@@ -148,6 +150,31 @@ async function main(argv) {
148
150
  console.error("usage: window.ts --publish DIR... --otp CODE [--wait SECONDS] [--json]; every DIR carries a package.json and CODE is the account's one-time code");
149
151
  return 64;
150
152
  }
153
+ for (const directory of directories) {
154
+ let root = resolve(directory);
155
+ while (!existsSync(join(root, '.git')) && dirname(root) !== root)
156
+ root = dirname(root);
157
+ const entry = join(root, '.git');
158
+ if (!existsSync(entry) || !statSync(entry).isFile())
159
+ continue;
160
+ const line = readFileSync(entry, 'utf8')
161
+ .split(/\r\n|\n/u)
162
+ .find((value) => value.startsWith('gitdir:'));
163
+ const target = line?.slice('gitdir:'.length).trim();
164
+ if (target === undefined || target === '') {
165
+ console.error(`window: ${directory} has a .git file without a gitdir: path; cannot identify its primary clone`);
166
+ return 3;
167
+ }
168
+ const gitdir = resolve(root, target);
169
+ const common = join(gitdir, 'commondir');
170
+ if (!existsSync(common)) {
171
+ console.error(`window: ${directory} is a submodule; publish from a standalone clone`);
172
+ return 3;
173
+ }
174
+ const primary = dirname(resolve(gitdir, readFileSync(common, 'utf8').trim()));
175
+ console.error(`window: ${directory} is a linked worktree; publish from its primary clone at ${primary} so npm records gitHead`);
176
+ return 3;
177
+ }
151
178
  // A stored credential expires mid-session, so the session-start answer does not hold here.
152
179
  if (readWhoami() === undefined) {
153
180
  console.error('window: npm whoami answers nothing immediately before the upload; run --login first');
package/dist/bin/main.js CHANGED
@@ -10,7 +10,7 @@ import { normalize } from "node:path";
10
10
  import { parseArgs } from "node:util";
11
11
  var package_default = {
12
12
  name: "@orkestrel/scaffold",
13
- version: "0.0.88",
13
+ version: "0.0.89",
14
14
  description: "Scaffold workspaces with commands: new, audit, repair, catalog, and overwrite.",
15
15
  keywords: [
16
16
  "audit",
@@ -84,6 +84,7 @@ var package_default = {
84
84
  "test:config": "vitest run --config vite.config.ts --no-cache --reporter=dot --project config",
85
85
  "test:guides": "node --experimental-strip-types tests/guides.test.ts",
86
86
  "test:skills": "vitest run --config vite.config.ts --no-cache --reporter=dot --project skills",
87
+ "test:templates": "vitest run --config vite.config.ts --no-cache --reporter=dot --project templates",
87
88
  "test:distribution": "vitest run --config vite.config.ts --no-cache --reporter=dot --project distribution",
88
89
  "test:probe": "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe",
89
90
  "test:bench": "vitest bench --config vite.config.ts --no-cache --project probe",
@@ -97,7 +98,7 @@ var package_default = {
97
98
  "build:inventory": "node -e \"import('./dist/src/server/index.js').then((m)=>{const p=process.argv[1]??'host.json',n=m.stageInventory(process.cwd(),p).entries.length;console.log('build-inventory: staged '+n+' file(s) into '+p)})\"",
98
99
  "build:skills": "tsc -p configs/agents/tsconfig.skills.json --noEmit false --allowImportingTsExtensions false --rewriteRelativeImportExtensions --declaration false --sourceMap false --rootDir .agents/skills --outDir dist/agents/skills && npm run copy .agents/templates/brief.md dist/agents/templates/brief.md",
99
100
  "prepack": "npm run build",
100
- "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:distribution -- --mode release"
101
+ "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:templates && npm run test:distribution -- --mode release"
101
102
  },
102
103
  dependencies: {
103
104
  "@orkestrel/console": "^0.0.15",