@prestack/thread 0.1.3 → 0.1.5
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/CHANGELOG.md +563 -0
- package/dist/core/actor.d.ts +1 -1
- package/dist/core/actor.js +5 -4
- package/dist/core/actor.ts +5 -4
- package/dist/core/attach.d.ts +0 -7
- package/dist/core/attach.js +38 -67
- package/dist/core/attach.ts +34 -80
- package/dist/core/chain.js +13 -17
- package/dist/core/chain.ts +11 -15
- package/dist/core/condition.d.ts +4 -4
- package/dist/core/condition.js +2 -2
- package/dist/core/descend.d.ts +4 -2
- package/dist/core/descend.js +91 -23
- package/dist/core/descend.ts +90 -21
- package/dist/core/errors/catalogue.d.ts +52 -0
- package/dist/{operations/errors/errors.js → core/errors/catalogue.js} +1 -1
- package/dist/{operations/errors/errors.ts → core/errors/catalogue.ts} +1 -1
- package/dist/{operations/errors/catalog.d.ts → core/errors/error.d.ts} +2 -3
- package/dist/{operations/errors/catalog.js → core/errors/error.js} +1 -16
- package/dist/{operations/errors/catalog.ts → core/errors/error.ts} +3 -19
- package/dist/core/errors/namespaces.d.ts +3 -0
- package/dist/core/errors/namespaces.js +15 -0
- package/dist/core/errors/namespaces.ts +19 -0
- package/dist/core/finding.js +2 -2
- package/dist/core/finding.ts +1 -2
- package/dist/core/init.d.ts +1 -1
- package/dist/core/init.js +51 -5
- package/dist/core/init.ts +58 -5
- package/dist/core/invoked.d.ts +1 -1
- package/dist/core/invoked.js +3 -1
- package/dist/core/invoked.ts +5 -2
- package/dist/core/round.js +36 -22
- package/dist/core/round.ts +26 -9
- package/dist/core/rows.d.ts +4 -0
- package/dist/core/rows.js +31 -2
- package/dist/core/rows.ts +33 -1
- package/dist/core/scope.d.ts +1 -0
- package/dist/core/scope.js +1 -0
- package/dist/core/scope.ts +2 -0
- package/dist/core/thread.d.ts +3 -3
- package/dist/core/tree.d.ts +4 -1
- package/dist/core/tree.js +26 -6
- package/dist/core/tree.ts +29 -6
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +3 -1
- package/dist/core/types.ts +2 -1
- package/dist/derivation/attach.js +3 -2
- package/dist/derivation/attach.ts +2 -1
- package/dist/derivation/generators/build.js +6 -6
- package/dist/derivation/generators/build.ts +1 -1
- package/dist/derivation/generators/check.js +1 -1
- package/dist/derivation/generators/determinism.js +1 -1
- package/dist/derivation/generators/release.js +60 -47
- package/dist/derivation/generators/release.ts +66 -43
- package/dist/derivation/release.d.ts +7 -3
- package/dist/derivation/release.js +14 -1
- package/dist/derivation/release.ts +22 -2
- package/dist/integrations/attach.d.ts +4 -0
- package/dist/integrations/attach.js +37 -56
- package/dist/integrations/attach.ts +54 -60
- package/dist/integrations/cli.d.ts +37 -0
- package/dist/integrations/cli.js +440 -0
- package/dist/integrations/cli.ts +543 -0
- package/dist/{core/files.d.ts → integrations/disk.d.ts} +16 -24
- package/dist/integrations/disk.js +435 -0
- package/dist/integrations/disk.ts +465 -0
- package/dist/integrations/generators/read.js +6 -6
- package/dist/integrations/generators/read.ts +4 -4
- package/dist/integrations/generators/vault.js +10 -11
- package/dist/integrations/generators/vault.ts +4 -5
- package/dist/{operations/http.d.ts → integrations/https.d.ts} +10 -6
- package/dist/integrations/https.js +170 -0
- package/dist/integrations/https.ts +216 -0
- package/dist/integrations/pglite.d.ts +26 -0
- package/dist/integrations/pglite.js +143 -0
- package/dist/integrations/pglite.ts +206 -0
- package/dist/integrations/secret.d.ts +8 -2
- package/dist/integrations/secret.js +3 -5
- package/dist/integrations/secret.ts +10 -6
- package/dist/integrations/target.d.ts +155 -14
- package/dist/integrations/target.js +171 -50
- package/dist/integrations/target.ts +377 -61
- package/dist/integrations/vault.d.ts +1 -0
- package/dist/integrations/vault.js +20 -5
- package/dist/integrations/vault.ts +17 -5
- package/dist/integrity/attach.js +8 -77
- package/dist/integrity/attach.ts +7 -76
- package/dist/integrity/check-threads.js +5 -5
- package/dist/integrity/check-threads.ts +2 -2
- package/dist/integrity/constraint.d.ts +0 -1
- package/dist/integrity/constraint.js +267 -366
- package/dist/integrity/constraint.ts +267 -375
- package/dist/integrity/generators/compiler.js +14 -17
- package/dist/integrity/generators/compiler.ts +10 -15
- package/dist/integrity/generators/gate.js +15 -15
- package/dist/integrity/generators/gate.ts +10 -10
- package/dist/integrity/generators/issues.js +7 -7
- package/dist/integrity/generators/publish.js +39 -57
- package/dist/integrity/generators/publish.ts +44 -55
- package/dist/integrity/generators/trial.d.ts +3 -3
- package/dist/integrity/generators/trial.js +133 -165
- package/dist/integrity/generators/trial.ts +145 -169
- package/dist/integrity/lint.js +9 -13
- package/dist/integrity/lint.ts +7 -10
- package/dist/integrity/lsp/bin.js +5 -4
- package/dist/integrity/lsp/bin.ts +3 -1
- package/dist/integrity/lsp/diagnostics.js +3 -3
- package/dist/integrity/lsp/diagnostics.ts +1 -1
- package/dist/integrity/lsp/lint.js +19 -30
- package/dist/integrity/lsp/lint.ts +16 -32
- package/dist/integrity/lsp/server.js +3 -3
- package/dist/integrity/slopnator.d.ts +3 -13
- package/dist/integrity/slopnator.js +59 -38
- package/dist/integrity/slopnator.ts +54 -38
- package/dist/integrity/slopnators/sl_broken_lineage.js +2 -2
- package/dist/integrity/slopnators/sl_declared_elsewhere.js +1 -1
- package/dist/integrity/slopnators/sl_derived_drift.js +4 -4
- package/dist/integrity/slopnators/sl_derived_drift.ts +1 -1
- package/dist/integrity/slopnators/sl_door_in_a_node.js +220 -0
- package/dist/integrity/slopnators/sl_door_in_a_node.ts +250 -0
- package/dist/integrity/slopnators/sl_inert_island.js +10 -8
- package/dist/integrity/slopnators/sl_inert_island.ts +8 -6
- package/dist/integrity/slopnators/sl_missing_row.js +6 -51
- package/dist/integrity/slopnators/sl_missing_row.ts +4 -50
- package/dist/integrity/slopnators/sl_no_barrel.js +1 -1
- package/dist/integrity/slopnators/sl_no_child_process.js +36 -18
- package/dist/integrity/slopnators/sl_no_child_process.ts +44 -18
- package/dist/integrity/slopnators/sl_no_dispatch_bypass.js +80 -149
- package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +95 -147
- package/dist/integrity/slopnators/sl_no_import_cycle.js +15 -4
- package/dist/integrity/slopnators/sl_no_import_cycle.ts +20 -4
- package/dist/integrity/slopnators/sl_no_such_command.js +2 -2
- package/dist/integrity/slopnators/sl_no_such_command.ts +1 -1
- package/dist/integrity/slopnators/sl_outside_an_operation.js +20 -0
- package/dist/integrity/slopnators/sl_outside_an_operation.ts +25 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.d.ts +2 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.js +61 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.ts +70 -0
- package/dist/integrity/slopnators/sl_secret_literal.js +1 -33
- package/dist/integrity/slopnators/sl_secret_literal.ts +1 -33
- package/dist/integrity/slopnators/sl_stale_path.js +5 -22
- package/dist/integrity/slopnators/sl_stale_path.ts +4 -20
- package/dist/integrity/slopnators/sl_twice_meant.js +1 -1
- package/dist/integrity/slopnators/sl_twice_parented.js +29 -5
- package/dist/integrity/slopnators/sl_twice_parented.ts +28 -4
- package/dist/integrity/slopnators/sl_undeclared_crossing.d.ts +4 -1
- package/dist/integrity/slopnators/sl_undeclared_crossing.js +426 -62
- package/dist/integrity/slopnators/sl_undeclared_crossing.ts +454 -70
- package/dist/integrity/slopnators/sl_undeclared_destination.js +59 -25
- package/dist/integrity/slopnators/sl_undeclared_destination.ts +69 -21
- package/dist/integrity/slopnators/sl_undeclared_list.d.ts +2 -0
- package/dist/integrity/slopnators/sl_undeclared_list.js +363 -0
- package/dist/integrity/slopnators/sl_undeclared_list.ts +358 -0
- package/dist/integrity/slopnators/sl_undeclared_node.js +1 -11
- package/dist/integrity/slopnators/sl_undeclared_node.ts +0 -10
- package/dist/integrity/slopnators/sl_undeclared_operation.js +111 -29
- package/dist/integrity/slopnators/sl_undeclared_operation.ts +134 -26
- package/dist/integrity/slopnators/sl_undeclared_variant.js +2 -2
- package/dist/integrity/slopnators/sl_undeclared_webhook.d.ts +2 -0
- package/dist/integrity/slopnators/sl_undeclared_webhook.js +90 -0
- package/dist/integrity/slopnators/sl_undeclared_webhook.ts +108 -0
- package/dist/integrity/slopnators/sl_underived_route.d.ts +2 -0
- package/dist/integrity/slopnators/sl_underived_route.js +61 -0
- package/dist/integrity/slopnators/sl_underived_route.ts +72 -0
- package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -3
- package/dist/integrity/slopnators/sl_ungoverned_island.ts +1 -1
- package/dist/integrity/slopnators/sl_unlisted_program.d.ts +2 -0
- package/dist/integrity/slopnators/sl_unlisted_program.js +39 -0
- package/dist/integrity/slopnators/sl_unlisted_program.ts +40 -0
- package/dist/integrity/slopnators/sl_unnamed_island.js +1 -1
- package/dist/integrity/slopnators/sl_unpaired_member.js +3 -3
- package/dist/integrity/slopnators/sl_unpaired_member.ts +1 -1
- package/dist/integrity/slopnators/sl_unpaired_slopnator.js +4 -4
- package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +1 -1
- package/dist/integrity/slopnators/sl_unprefixed_member.js +5 -31
- package/dist/integrity/slopnators/sl_unprefixed_member.ts +2 -28
- package/dist/integrity/slopnators/sl_unthreaded.js +11 -7
- package/dist/integrity/slopnators/sl_unthreaded.ts +6 -7
- package/dist/integrity/slopnators/sl_untranslated_key.js +2 -25
- package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -25
- package/dist/integrity/slopnators/sl_unvaulted_secret.d.ts +2 -0
- package/dist/integrity/slopnators/sl_unvaulted_secret.js +107 -0
- package/dist/integrity/slopnators/sl_unvaulted_secret.ts +132 -0
- package/dist/integrity/slopnators/sl_unversioned.js +6 -4
- package/dist/integrity/slopnators/sl_unversioned.ts +5 -3
- package/dist/integrity/sweep.d.ts +1 -0
- package/dist/integrity/sweep.js +105 -42
- package/dist/integrity/sweep.ts +115 -42
- package/dist/knowledge/attach.js +4 -3
- package/dist/knowledge/attach.ts +3 -2
- package/dist/knowledge/generators/docsgen.js +8 -6
- package/dist/knowledge/generators/docsgen.ts +4 -2
- package/dist/knowledge/generators/glossary.js +4 -4
- package/dist/knowledge/generators/glossary.ts +1 -1
- package/dist/operations/access.d.ts +23 -0
- package/dist/operations/access.js +28 -1
- package/dist/operations/access.ts +43 -0
- package/dist/operations/attach.js +33 -113
- package/dist/operations/attach.ts +51 -117
- package/dist/operations/capabilities.d.ts +14 -5
- package/dist/operations/capabilities.js +13 -4
- package/dist/operations/capabilities.ts +27 -8
- package/dist/operations/dispatch.d.ts +8 -2
- package/dist/operations/dispatch.js +128 -185
- package/dist/operations/dispatch.ts +138 -191
- package/dist/operations/error-results.d.ts +1 -1
- package/dist/operations/error-results.js +2 -2
- package/dist/operations/error-results.ts +2 -2
- package/dist/operations/generators/capability.d.ts +11 -1
- package/dist/operations/generators/capability.js +481 -224
- package/dist/operations/generators/capability.ts +562 -233
- package/dist/operations/generators/compile.js +66 -39
- package/dist/operations/generators/compile.ts +78 -39
- package/dist/operations/generators/permits.js +11 -12
- package/dist/operations/generators/permits.ts +3 -4
- package/dist/operations/generators/seed.d.ts +1 -0
- package/dist/operations/generators/seed.js +19 -17
- package/dist/operations/generators/seed.ts +22 -14
- package/dist/operations/generators/trial.d.ts +6 -8
- package/dist/operations/generators/trial.js +200 -70
- package/dist/operations/generators/trial.ts +230 -93
- package/dist/operations/nodes.d.ts +15 -16
- package/dist/operations/nodes.ts +16 -17
- package/dist/operations/operations.d.ts +40 -4
- package/dist/operations/operations.js +1 -0
- package/dist/operations/operations.ts +61 -4
- package/dist/operations/result.d.ts +2 -2
- package/dist/operations/result.ts +2 -2
- package/package.json +1 -4
- package/dist/core/answers.d.ts +0 -171
- package/dist/core/answers.js +0 -789
- package/dist/core/answers.ts +0 -999
- package/dist/core/client.d.ts +0 -63
- package/dist/core/client.js +0 -249
- package/dist/core/client.ts +0 -289
- package/dist/core/files.js +0 -171
- package/dist/core/files.ts +0 -222
- package/dist/integrations/module.d.ts +0 -6
- package/dist/integrations/module.js +0 -153
- package/dist/integrations/module.ts +0 -191
- package/dist/integrity/slopnators/sl_unkept_rows.js +0 -104
- package/dist/integrity/slopnators/sl_unkept_rows.ts +0 -111
- package/dist/integrity/slopnators/sl_unseamed_reach.js +0 -73
- package/dist/integrity/slopnators/sl_unseamed_reach.ts +0 -79
- package/dist/operations/cost.d.ts +0 -14
- package/dist/operations/cost.js +0 -37
- package/dist/operations/cost.ts +0 -58
- package/dist/operations/errors/errors.d.ts +0 -52
- package/dist/operations/http.js +0 -124
- package/dist/operations/http.ts +0 -169
- package/dist/operations/memory.d.ts +0 -104
- package/dist/operations/memory.js +0 -365
- package/dist/operations/memory.ts +0 -470
- package/dist/operations/metering.d.ts +0 -55
- package/dist/operations/metering.js +0 -247
- package/dist/operations/metering.ts +0 -328
- package/dist/operations/queue-policy.d.ts +0 -3
- package/dist/operations/queue-policy.js +0 -8
- package/dist/operations/queue-policy.ts +0 -10
- package/dist/operations/seams.d.ts +0 -239
- package/dist/operations/seams.js +0 -45
- package/dist/operations/seams.ts +0 -364
- package/dist/operations/store.d.ts +0 -14
- package/dist/operations/store.js +0 -1
- package/dist/operations/store.ts +0 -29
- /package/dist/{operations → core}/errors/classes.d.ts +0 -0
- /package/dist/{operations → core}/errors/classes.js +0 -0
- /package/dist/{operations → core}/errors/classes.ts +0 -0
- /package/dist/integrity/slopnators/{sl_unkept_rows.d.ts → sl_door_in_a_node.d.ts} +0 -0
- /package/dist/integrity/slopnators/{sl_unseamed_reach.d.ts → sl_outside_an_operation.d.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { attached, readdirSync, readFileSync, writeFileSync } from
|
|
1
|
+
import { starts } from '../../integrations/cli.js';
|
|
2
|
+
import { attached, readdirSync, readFileSync, writeFileSync } from '../../integrations/disk.js';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { argv, execPath, stderr, stdout } from 'node:process';
|
|
6
|
-
import { exit } from
|
|
7
|
-
import { ROOT, THREAD_AT, descend } from
|
|
8
|
-
import { MANIFEST } from
|
|
9
|
-
import { forbids, runChecker } from
|
|
6
|
+
import { exit } from '../../core/invoked.js';
|
|
7
|
+
import { ROOT, THREAD_AT, descend } from '../../core/descend.js';
|
|
8
|
+
import { MANIFEST } from '../../core/init.js';
|
|
9
|
+
import { forbids, runChecker } from '../../core/finding.js';
|
|
10
10
|
function refuse(why) {
|
|
11
11
|
stderr.write(`compiler: ${why}\n`);
|
|
12
12
|
exit(1);
|
|
@@ -77,7 +77,8 @@ if (!held.declares) {
|
|
|
77
77
|
refuse('no TypeScript file in this tree is declared by anything, so every one of them would be left out ' +
|
|
78
78
|
'and the compiler would pass by reading nothing. Declare something with `thread create` first.');
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const NEXT = '.next';
|
|
81
|
+
const leave = [...new Set([...held.out, NEXT])].sort();
|
|
81
82
|
let current;
|
|
82
83
|
try {
|
|
83
84
|
current = JSON.parse(readFileSync(PATH, 'utf8'));
|
|
@@ -92,9 +93,7 @@ if (argv.includes('--check')) {
|
|
|
92
93
|
if (!has) {
|
|
93
94
|
findings.push({
|
|
94
95
|
file: AT,
|
|
95
|
-
detail: leave.length
|
|
96
|
-
? 'leaves out paths this tree declares something under, so the compiler is not reading all of this app'
|
|
97
|
-
: `does not leave out ${String(leave.length)} path(s) nothing in this tree declares, so the compiler is holding this app to code it never wrote`,
|
|
96
|
+
detail: `does not leave out ${String(leave.length)} path(s) nothing in this tree declares, so the compiler is holding this app to code it never wrote`,
|
|
98
97
|
instead: 'run `thread compiler`. What the compiler reads is derived from what the tree declares — an edit here is a declaration somebody skipped, and a path put here by hand is taken back out on the next settle',
|
|
99
98
|
});
|
|
100
99
|
}
|
|
@@ -120,17 +119,15 @@ if (argv.includes('--check')) {
|
|
|
120
119
|
'passed against the wrong machine says nothing about this one.\n');
|
|
121
120
|
exit(1);
|
|
122
121
|
}
|
|
123
|
-
const built =
|
|
124
|
-
if (built.
|
|
125
|
-
refuse(`the compiler could not be started — ${built.
|
|
126
|
-
exit(built.
|
|
122
|
+
const built = starts(execPath, [cli, '--noEmit'], { at: ROOT, shows: true });
|
|
123
|
+
if (!built.there)
|
|
124
|
+
refuse(`the compiler could not be started — ${built.why}.`);
|
|
125
|
+
exit(built.code);
|
|
127
126
|
}
|
|
128
127
|
if (has) {
|
|
129
128
|
stdout.write(`compiler: ${AT} already leaves out exactly what this tree declares nothing under.\n`);
|
|
130
129
|
exit(0);
|
|
131
130
|
}
|
|
132
131
|
writeFileSync(PATH, `${wanted}\n`);
|
|
133
|
-
stdout.write(leave.length
|
|
134
|
-
? `compiler: wrote ${AT} — every path here has something declared under it, so none is left out.\n`
|
|
135
|
-
: `compiler: wrote ${AT} — ${String(leave.length)} path(s) left out, declared by nobody: ${leave.join(', ')}.\n`);
|
|
132
|
+
stdout.write(`compiler: wrote ${AT} — ${String(leave.length)} path(s) left out, declared by nobody: ${leave.join(', ')}.\n`);
|
|
136
133
|
exit(0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { attached, readdirSync, readFileSync, writeFileSync } from '../../
|
|
1
|
+
import { starts } from '../../integrations/cli.ts'
|
|
2
|
+
import { attached, readdirSync, readFileSync, writeFileSync } from '../../integrations/disk.ts'
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import { dirname, join, resolve } from 'node:path'
|
|
5
5
|
import { argv, execPath, stderr, stdout } from 'node:process'
|
|
@@ -99,7 +99,9 @@ if (!held.declares) {
|
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const
|
|
102
|
+
const NEXT = '.next'
|
|
103
|
+
|
|
104
|
+
const leave = [...new Set([...held.out, NEXT])].sort()
|
|
103
105
|
|
|
104
106
|
let current: Record<string, unknown>
|
|
105
107
|
try {
|
|
@@ -116,10 +118,7 @@ if (argv.includes('--check')) {
|
|
|
116
118
|
if (!has) {
|
|
117
119
|
findings.push({
|
|
118
120
|
file: AT,
|
|
119
|
-
detail:
|
|
120
|
-
leave.length === 0
|
|
121
|
-
? 'leaves out paths this tree declares something under, so the compiler is not reading all of this app'
|
|
122
|
-
: `does not leave out ${String(leave.length)} path(s) nothing in this tree declares, so the compiler is holding this app to code it never wrote`,
|
|
121
|
+
detail: `does not leave out ${String(leave.length)} path(s) nothing in this tree declares, so the compiler is holding this app to code it never wrote`,
|
|
123
122
|
instead:
|
|
124
123
|
'run `thread compiler`. What the compiler reads is derived from what the tree declares — an edit here is a declaration somebody skipped, and a path put here by hand is taken back out on the next settle',
|
|
125
124
|
})
|
|
@@ -151,9 +150,9 @@ if (argv.includes('--check')) {
|
|
|
151
150
|
exit(1)
|
|
152
151
|
}
|
|
153
152
|
|
|
154
|
-
const built =
|
|
155
|
-
if (built.
|
|
156
|
-
exit(built.
|
|
153
|
+
const built = starts(execPath, [cli, '--noEmit'], { at: ROOT, shows: true })
|
|
154
|
+
if (!built.there) refuse(`the compiler could not be started — ${built.why}.`)
|
|
155
|
+
exit(built.code)
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
if (has) {
|
|
@@ -162,9 +161,5 @@ if (has) {
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
writeFileSync(PATH, `${wanted}\n`)
|
|
165
|
-
stdout.write(
|
|
166
|
-
leave.length === 0
|
|
167
|
-
? `compiler: wrote ${AT} — every path here has something declared under it, so none is left out.\n`
|
|
168
|
-
: `compiler: wrote ${AT} — ${String(leave.length)} path(s) left out, declared by nobody: ${leave.join(', ')}.\n`,
|
|
169
|
-
)
|
|
164
|
+
stdout.write(`compiler: wrote ${AT} — ${String(leave.length)} path(s) left out, declared by nobody: ${leave.join(', ')}.\n`)
|
|
170
165
|
exit(0)
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { starts } from '../../integrations/cli.js';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import { readFileSync as bytesAt } from 'node:fs';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
4
|
import { argv, execPath, stderr, stdout } from 'node:process';
|
|
6
|
-
import { descend } from
|
|
7
|
-
import { attached, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from
|
|
8
|
-
import { LOADER, exit } from
|
|
9
|
-
import { valuesIn } from
|
|
10
|
-
import { ORGANISATION, ours } from
|
|
11
|
-
import { findTree, inTree } from
|
|
5
|
+
import { descend } from '../../core/descend.js';
|
|
6
|
+
import { attached, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from '../../integrations/disk.js';
|
|
7
|
+
import { LOADER, exit } from '../../core/invoked.js';
|
|
8
|
+
import { valuesIn } from '../../core/rows.js';
|
|
9
|
+
import { ORGANISATION, ours } from '../../core/scope.js';
|
|
10
|
+
import { findTree, inTree } from '../../core/tree.js';
|
|
12
11
|
const TREE = findTree();
|
|
13
12
|
const ROOT = TREE.at;
|
|
14
13
|
const STEP_TIMEOUT = 600_000;
|
|
@@ -56,10 +55,10 @@ for (const row of writers) {
|
|
|
56
55
|
}
|
|
57
56
|
function ran(runs) {
|
|
58
57
|
const said = runs.trim().split(/\s+/);
|
|
59
|
-
const spent = {
|
|
58
|
+
const spent = { at: ROOT, shows: true, within: STEP_TIMEOUT };
|
|
60
59
|
if (said[0] !== 'thread') {
|
|
61
|
-
const
|
|
62
|
-
return
|
|
60
|
+
const other = starts(said[0] ?? '', said.slice(1), spent);
|
|
61
|
+
return other.there ? other.code : 1;
|
|
63
62
|
}
|
|
64
63
|
const of = `thread ${said[1] ?? ''}`;
|
|
65
64
|
const at = written.get(of);
|
|
@@ -67,8 +66,8 @@ function ran(runs) {
|
|
|
67
66
|
stderr.write(`gate: nothing in this tree is written by \`${of}\`, so this step names a command that does not exist here\n`);
|
|
68
67
|
return 1;
|
|
69
68
|
}
|
|
70
|
-
const spun =
|
|
71
|
-
return spun.
|
|
69
|
+
const spun = starts(execPath, [...LOADER, join(ROOT, at), ...said.slice(2)], spent);
|
|
70
|
+
return spun.there ? spun.code : 1;
|
|
72
71
|
}
|
|
73
72
|
function named(flag) {
|
|
74
73
|
const at = argv.indexOf(flag);
|
|
@@ -111,8 +110,9 @@ for (const [index, step] of chosen.entries()) {
|
|
|
111
110
|
`passed against the wrong machine says nothing about this one.\n`);
|
|
112
111
|
continue;
|
|
113
112
|
}
|
|
113
|
+
const began = Date.now();
|
|
114
114
|
const code = ran(step.runs);
|
|
115
|
-
stdout.write(`gate: ${at} — exited ${String(code)}\n`);
|
|
115
|
+
stdout.write(`gate: ${at} — exited ${String(code)} in ${String(Date.now() - began)} ms\n`);
|
|
116
116
|
if (code === 0)
|
|
117
117
|
passed += 1;
|
|
118
118
|
else
|
|
@@ -128,7 +128,7 @@ function fingerprint() {
|
|
|
128
128
|
const hash = (at) => {
|
|
129
129
|
if (!existsSync(join(ROOT, at)))
|
|
130
130
|
return;
|
|
131
|
-
of[at] = createHash('sha256').update(
|
|
131
|
+
of[at] = createHash('sha256').update(readFileSync(join(ROOT, at))).digest('hex').slice(0, 16);
|
|
132
132
|
};
|
|
133
133
|
const sheets = join(ROOT, '_threads');
|
|
134
134
|
if (existsSync(sheets)) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { starts } from '../../integrations/cli.ts'
|
|
2
2
|
import { createHash } from 'node:crypto'
|
|
3
|
-
import { readFileSync as bytesAt } from 'node:fs'
|
|
4
3
|
import { dirname, join } from 'node:path'
|
|
5
4
|
import { argv, execPath, stderr, stdout } from 'node:process'
|
|
6
5
|
import { fileURLToPath } from 'node:url'
|
|
7
6
|
import { descend } from '../../core/descend.ts'
|
|
8
|
-
import { attached, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from '../../
|
|
7
|
+
import { attached, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from '../../integrations/disk.ts'
|
|
9
8
|
import { LOADER, exit } from '../../core/invoked.ts'
|
|
10
9
|
import { valuesIn } from '../../core/rows.ts'
|
|
11
10
|
import { ORGANISATION, ours } from '../../core/scope.ts'
|
|
@@ -82,11 +81,11 @@ for (const row of writers) {
|
|
|
82
81
|
|
|
83
82
|
function ran(runs: string): number {
|
|
84
83
|
const said = runs.trim().split(/\s+/)
|
|
85
|
-
const spent = {
|
|
84
|
+
const spent = { at: ROOT, shows: true, within: STEP_TIMEOUT } as const
|
|
86
85
|
|
|
87
86
|
if (said[0] !== 'thread') {
|
|
88
|
-
const
|
|
89
|
-
return
|
|
87
|
+
const other = starts(said[0] ?? '', said.slice(1), spent)
|
|
88
|
+
return other.there ? other.code : 1
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
const of = `thread ${said[1] ?? ''}`
|
|
@@ -96,8 +95,8 @@ function ran(runs: string): number {
|
|
|
96
95
|
return 1
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
const spun =
|
|
100
|
-
return spun.
|
|
98
|
+
const spun = starts(execPath, [...LOADER, join(ROOT, at), ...said.slice(2)], spent)
|
|
99
|
+
return spun.there ? spun.code : 1
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
function named(flag: string): readonly string[] | undefined {
|
|
@@ -151,9 +150,10 @@ for (const [index, step] of chosen.entries()) {
|
|
|
151
150
|
continue
|
|
152
151
|
}
|
|
153
152
|
|
|
153
|
+
const began = Date.now()
|
|
154
154
|
const code = ran(step.runs)
|
|
155
155
|
|
|
156
|
-
stdout.write(`gate: ${at} — exited ${String(code)}\n`)
|
|
156
|
+
stdout.write(`gate: ${at} — exited ${String(code)} in ${String(Date.now() - began)} ms\n`)
|
|
157
157
|
if (code === 0) passed += 1
|
|
158
158
|
else failed.push(step)
|
|
159
159
|
}
|
|
@@ -169,7 +169,7 @@ function fingerprint(): { readonly of: Record<string, string>; readonly versions
|
|
|
169
169
|
const of: Record<string, string> = {}
|
|
170
170
|
const hash = (at: string): void => {
|
|
171
171
|
if (!existsSync(join(ROOT, at))) return
|
|
172
|
-
of[at] = createHash('sha256').update(
|
|
172
|
+
of[at] = createHash('sha256').update(readFileSync(join(ROOT, at))).digest('hex').slice(0, 16)
|
|
173
173
|
}
|
|
174
174
|
const sheets = join(ROOT, '_threads')
|
|
175
175
|
if (existsSync(sheets)) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { argv, stderr, stdout } from 'node:process';
|
|
2
|
-
import { exit } from
|
|
3
|
-
import { uncompiled } from
|
|
4
|
-
import { THREAD_AT, descend, refusals, trackedFiles, unthreaded } from
|
|
5
|
-
import { CONSTRAINTS } from
|
|
6
|
-
import { ruleMessage } from
|
|
7
|
-
import { ROOT, load, rules } from
|
|
8
|
-
import { sweep, tracked as governed } from
|
|
2
|
+
import { exit } from '../../core/invoked.js';
|
|
3
|
+
import { uncompiled } from '../../core/descend.js';
|
|
4
|
+
import { THREAD_AT, descend, refusals, trackedFiles, unthreaded } from '../check-threads.js';
|
|
5
|
+
import { CONSTRAINTS } from '../constraint.js';
|
|
6
|
+
import { ruleMessage } from '../lint.js';
|
|
7
|
+
import { ROOT, load, rules } from '../slopnator.js';
|
|
8
|
+
import { sweep, tracked as governed } from '../sweep.js';
|
|
9
9
|
const WITHIN = '--in';
|
|
10
10
|
const CHECK = '--check';
|
|
11
11
|
const checking = argv.includes(CHECK);
|
|
@@ -1,53 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync, readFileSync } from
|
|
3
|
-
import { valuesIn } from
|
|
1
|
+
import { calls, starts } from '../../integrations/cli.js';
|
|
2
|
+
import { existsSync, readFileSync } from '../../integrations/disk.js';
|
|
3
|
+
import { valuesIn } from '../../core/rows.js';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { argv, env, execPath, stderr, stdout } from 'node:process';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { opened, sealedIn } from
|
|
6
|
+
import { CLI, exit } from '../../core/invoked.js';
|
|
7
|
+
import { THING as TYPED, named } from '../../core/scope.js';
|
|
8
|
+
import { findTree, inTree } from '../../core/tree.js';
|
|
9
|
+
import { placedAt } from '../../integrations/target.js';
|
|
10
|
+
import { opened, sealedIn } from '../../integrations/vault.js';
|
|
11
11
|
const TREE = findTree();
|
|
12
12
|
const ROOT = TREE.at;
|
|
13
13
|
const STEP_TIMEOUT = 900_000;
|
|
14
|
-
const REGISTRY = '
|
|
15
|
-
const DEFAULT = 'https://registry.npmjs.org';
|
|
14
|
+
const REGISTRY = 'ht_registry';
|
|
16
15
|
const CHECKS = [
|
|
17
16
|
{
|
|
18
17
|
id: 'gate',
|
|
19
18
|
runs: 'thread gate',
|
|
20
19
|
because: 'every step this tree declares, in the order it declares them, which is where the descent and the sweep are',
|
|
21
20
|
},
|
|
22
|
-
{
|
|
23
|
-
id: 'lint',
|
|
24
|
-
runs: 'pnpm exec eslint .',
|
|
25
|
-
because: 'the rules that live on the lint surface, which is the only one carrying a fixer the sweep can report but not repair',
|
|
26
|
-
},
|
|
27
21
|
];
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
stdio: 'inherit',
|
|
36
|
-
timeout: STEP_TIMEOUT,
|
|
37
|
-
killSignal: 'SIGKILL',
|
|
38
|
-
env: extra === undefined ? env : { ...env, ...extra },
|
|
39
|
-
});
|
|
40
|
-
return ran.error !== undefined ? 1 : (ran.status ?? 1);
|
|
41
|
-
}
|
|
42
|
-
const result = spawnSync(what, {
|
|
43
|
-
shell: true,
|
|
44
|
-
cwd: ROOT,
|
|
45
|
-
stdio: 'inherit',
|
|
46
|
-
timeout: STEP_TIMEOUT,
|
|
47
|
-
killSignal: 'SIGKILL',
|
|
48
|
-
env: extra === undefined ? env : { ...env, ...extra },
|
|
49
|
-
});
|
|
50
|
-
return result.error !== undefined ? 1 : (result.status ?? 1);
|
|
22
|
+
const PREFIX = /^(?:npx|pnpm)$/;
|
|
23
|
+
const words = (said) => said.split(/\s+/).filter((one) => one !== '');
|
|
24
|
+
function run(given, extra) {
|
|
25
|
+
const mine = given[0] === 'thread' ? 1 : PREFIX.test(given[0] ?? '') && given[1] === 'thread' ? 2 : 0;
|
|
26
|
+
const how = { at: ROOT, shows: true, within: STEP_TIMEOUT, holds: extra === undefined ? env : { ...env, ...extra } };
|
|
27
|
+
const went = mine === 0 ? starts(given[0] ?? '', given.slice(1), how) : starts(execPath, [...CLI, ...given.slice(mine)], how);
|
|
28
|
+
return went.there ? went.code : 1;
|
|
51
29
|
}
|
|
52
30
|
function refuse(id, code, because, runs) {
|
|
53
31
|
stderr.write(`\npublish: REFUSED — \`${id}\` exited ${String(code)}. NOTHING was published.\n`);
|
|
@@ -56,10 +34,9 @@ function refuse(id, code, because, runs) {
|
|
|
56
34
|
stderr.write(`publish: second copy of a refusal drifts from the first. Run \`${runs}\` alone to work on it.\n`);
|
|
57
35
|
exit(1);
|
|
58
36
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
stderr.write(`thread publish ${REGISTRY} <url> where the packages go. Leave it off for ${DEFAULT}.\n`);
|
|
37
|
+
const given = argv.indexOf('--registry');
|
|
38
|
+
if (given !== -1) {
|
|
39
|
+
stderr.write('thread publish takes no url. Where the packages go is the address on the ht_registry row in _threads/targets.ts.\n');
|
|
63
40
|
stderr.write('\nit builds, then runs every check, then publishes. A check that fails publishes nothing.\n');
|
|
64
41
|
exit(1);
|
|
65
42
|
}
|
|
@@ -70,6 +47,12 @@ const declared = existsSync(secrets)
|
|
|
70
47
|
? (valuesIn(readFileSync(secrets)).SECRETS ?? [])
|
|
71
48
|
: [];
|
|
72
49
|
const vaulted = declared.some((one) => one.id === TOKEN);
|
|
50
|
+
const targets = inTree(TREE, 'targets.ts');
|
|
51
|
+
const registry = placedAt(existsSync(targets) ? (valuesIn(readFileSync(targets)).TARGETS ?? []) : [], REGISTRY).replace(/[/]$/, '');
|
|
52
|
+
if (registry === '') {
|
|
53
|
+
stderr.write('\npublish: no target row says where the registry is, so there is nowhere for these packages to go. Give ' + REGISTRY + ' an address in _threads/targets.ts, the absolute url of the registry. NOTHING was published.\n');
|
|
54
|
+
exit(1);
|
|
55
|
+
}
|
|
73
56
|
if (vaulted && !sealedIn(ROOT, PRODUCTION).includes(TOKEN)) {
|
|
74
57
|
stderr.write(`\npublish: ${TOKEN} is declared in _threads/secrets.ts and has no value sealed for ${PRODUCTION}, so nothing was checked and NOTHING was published.\n`);
|
|
75
58
|
stderr.write(`publish: run \`thread create secret set ${TOKEN}\` at a terminal and paste the registry token, or take the row out to publish with the login this machine holds.\n`);
|
|
@@ -96,7 +79,7 @@ stdout.write(vaulted
|
|
|
96
79
|
? `publish: ${TOKEN} is declared and sealed for ${PRODUCTION}. It is opened only after every check passes, and handed to pnpm as its auth setting for ${registry}.\n`
|
|
97
80
|
: `publish: no row declares ${TOKEN}, so this publish uses ${signedAs}. Declare it with \`thread create secret\` to publish with a token sealed in this repository instead.\n`);
|
|
98
81
|
stdout.write('publish: deriving and building what the packaging rows state first, so every check below reads the files this release ships rather than the source they were written from.\n');
|
|
99
|
-
const made = run(`${TYPED} packaged --build`);
|
|
82
|
+
const made = run(words(`${TYPED} packaged --build`));
|
|
100
83
|
stdout.write(`publish: packaged exited ${String(made)}\n`);
|
|
101
84
|
if (made !== 0) {
|
|
102
85
|
refuse('packaged', made, 'a package whose manifest and release note are not what its rows state would go out describing itself as something nobody declared, and one that did not compile would go out promising files it does not have', `${TYPED} packaged --build`);
|
|
@@ -107,28 +90,28 @@ for (const check of CHECKS)
|
|
|
107
90
|
for (const [index, check] of CHECKS.entries()) {
|
|
108
91
|
const at = `check ${String(index + 1)} of ${String(CHECKS.length)}`;
|
|
109
92
|
stdout.write(`\npublish: ${at} — ${check.runs} (${check.id})\n`);
|
|
110
|
-
const code = run(check.runs);
|
|
93
|
+
const code = run(words(check.runs));
|
|
111
94
|
stdout.write(`publish: ${at} — exited ${String(code)}\n`);
|
|
112
95
|
if (code !== 0)
|
|
113
96
|
refuse(check.id, code, check.because, check.runs);
|
|
114
97
|
}
|
|
115
|
-
const numbered = run(`${TYPED} packaged --release`);
|
|
98
|
+
const numbered = run(words(`${TYPED} packaged --release`));
|
|
116
99
|
stdout.write(`publish: packaged --release exited ${String(numbered)}\n`);
|
|
117
100
|
if (numbered !== 0) {
|
|
118
101
|
refuse('packaged', numbered, 'the next release number is written onto the manifests only once every check has passed, and writing it refused, so nothing here carries a number to go out under', `${TYPED} packaged --release`);
|
|
119
102
|
}
|
|
120
103
|
const handed = vaulted ? { [setting()]: await tokened() } : undefined;
|
|
121
104
|
stdout.write(`\npublish: every check passed. Publishing to ${registry} with ${vaulted ? `${TOKEN} from this repository's vault` : signedAs}.\n`);
|
|
122
|
-
const sent = run(`pnpm -r publish --registry ${registry} --no-git-checks --access public
|
|
105
|
+
const sent = run(words(`pnpm -r publish --registry ${registry} --no-git-checks --access public`), handed);
|
|
123
106
|
if (sent !== 0) {
|
|
124
107
|
stderr.write(`\npublish: the checks passed and the publish itself exited ${String(sent)}.\n`);
|
|
125
|
-
const back = run(`${TYPED} packaged`);
|
|
108
|
+
const back = run(words(`${TYPED} packaged`));
|
|
126
109
|
stderr.write(back === 0
|
|
127
110
|
? 'publish: the manifests carry the last recorded release again and no note was written, so the next `thread publish` numbers this release once more.\n'
|
|
128
111
|
: `publish: the manifests still carry the number that did not go out. Run \`${TYPED} packaged\` to put the last recorded release back.\n`);
|
|
129
112
|
exit(1);
|
|
130
113
|
}
|
|
131
|
-
const recorded = run(`${TYPED} packaged --record`);
|
|
114
|
+
const recorded = run(words(`${TYPED} packaged --record`));
|
|
132
115
|
stdout.write(`publish: packaged --record exited ${String(recorded)}\n`);
|
|
133
116
|
if (recorded !== 0) {
|
|
134
117
|
stderr.write(`\npublish: the packages went out and the note recording them refused to be written, so the next publish would number this release again. Run \`${TYPED} packaged --record\` and read what it says.\n`);
|
|
@@ -151,10 +134,9 @@ function versionAt(folder) {
|
|
|
151
134
|
return 'no version';
|
|
152
135
|
}
|
|
153
136
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (asked(['rev-parse', '--is-inside-work-tree']) !== 'true') {
|
|
137
|
+
const git = calls('cli_git', ROOT);
|
|
138
|
+
const asked = async (what) => (await git.rev_parse(what)).out.trim();
|
|
139
|
+
if ((await asked(['--is-inside-work-tree'])) !== 'true') {
|
|
158
140
|
stdout.write("\npublish: it's not a repo, so nothing was committed.\n");
|
|
159
141
|
}
|
|
160
142
|
else if (shipped.length === 0) {
|
|
@@ -162,14 +144,14 @@ else if (shipped.length === 0) {
|
|
|
162
144
|
}
|
|
163
145
|
else {
|
|
164
146
|
const going = shipped.map((one) => `${named(one.id ?? '')} ${versionAt(one.folder ?? '')}`).join(', ');
|
|
165
|
-
const branch = asked(['
|
|
147
|
+
const branch = await asked(['--abbrev-ref', 'HEAD']);
|
|
166
148
|
for (const one of shipped)
|
|
167
|
-
|
|
168
|
-
if (
|
|
149
|
+
await git.stage([one.folder ?? ''], true, STEP_TIMEOUT);
|
|
150
|
+
if ((await git.diff(['--cached', '--quiet'])).ok) {
|
|
169
151
|
stdout.write(`\npublish: ${going} — what is on disk is already what is committed, so this release added no artifact.\n`);
|
|
170
152
|
}
|
|
171
153
|
else {
|
|
172
|
-
const wrote =
|
|
154
|
+
const wrote = (await git.commit(['-m', `thread publish — ${going}`], true, STEP_TIMEOUT)).code;
|
|
173
155
|
stdout.write(`publish: commit exited ${String(wrote)}\n`);
|
|
174
156
|
if (wrote !== 0) {
|
|
175
157
|
stderr.write('\npublish: the packages went out and the files that describe them are not committed, so this release has no record in git.\n');
|
|
@@ -179,5 +161,5 @@ else {
|
|
|
179
161
|
stdout.write(`publish: committed the derived artifacts to ${branch} — ${going}.\n`);
|
|
180
162
|
}
|
|
181
163
|
}
|
|
182
|
-
stdout.write(`\npublish: done. What went out was derived, then built, then passed the gate
|
|
164
|
+
stdout.write(`\npublish: done. What went out was derived, then built, then passed the gate, in that order. The compile inside \`thread packaged --build\` is the typecheck.\n`);
|
|
183
165
|
exit(0);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync, readFileSync } from '../../
|
|
1
|
+
import { calls, starts } from '../../integrations/cli.ts'
|
|
2
|
+
import { existsSync, readFileSync } from '../../integrations/disk.ts'
|
|
3
3
|
import { valuesIn } from '../../core/rows.ts'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { argv, env, execPath, stderr, stdout } from 'node:process'
|
|
6
6
|
import { pathToFileURL } from 'node:url'
|
|
7
|
-
import { TYPED } from '../../core/answers.ts'
|
|
8
7
|
import { CLI, exit } from '../../core/invoked.ts'
|
|
9
|
-
import { named } from '../../core/scope.ts'
|
|
8
|
+
import { THING as TYPED, named } from '../../core/scope.ts'
|
|
10
9
|
import { findTree, inTree } from '../../core/tree.ts'
|
|
11
10
|
|
|
12
11
|
import type { Secret } from '../../integrations/secret.ts'
|
|
12
|
+
import { placedAt, type Target } from '../../integrations/target.ts'
|
|
13
13
|
import { opened, sealedIn } from '../../integrations/vault.ts'
|
|
14
14
|
|
|
15
15
|
const TREE = findTree()
|
|
@@ -17,9 +17,7 @@ const ROOT = TREE.at
|
|
|
17
17
|
|
|
18
18
|
const STEP_TIMEOUT = 900_000
|
|
19
19
|
|
|
20
|
-
const REGISTRY = '
|
|
21
|
-
|
|
22
|
-
const DEFAULT = 'https://registry.npmjs.org'
|
|
20
|
+
const REGISTRY = 'ht_registry'
|
|
23
21
|
|
|
24
22
|
interface Check {
|
|
25
23
|
readonly id: string
|
|
@@ -33,37 +31,17 @@ const CHECKS: readonly Check[] = [
|
|
|
33
31
|
runs: 'thread gate',
|
|
34
32
|
because: 'every step this tree declares, in the order it declares them, which is where the descent and the sweep are',
|
|
35
33
|
},
|
|
36
|
-
{
|
|
37
|
-
id: 'lint',
|
|
38
|
-
runs: 'pnpm exec eslint .',
|
|
39
|
-
because: 'the rules that live on the lint surface, which is the only one carrying a fixer the sweep can report but not repair',
|
|
40
|
-
},
|
|
41
34
|
]
|
|
42
35
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
timeout: STEP_TIMEOUT,
|
|
53
|
-
killSignal: 'SIGKILL',
|
|
54
|
-
env: extra === undefined ? env : { ...env, ...extra },
|
|
55
|
-
})
|
|
56
|
-
return ran.error !== undefined ? 1 : (ran.status ?? 1)
|
|
57
|
-
}
|
|
58
|
-
const result = spawnSync(what, {
|
|
59
|
-
shell: true,
|
|
60
|
-
cwd: ROOT,
|
|
61
|
-
stdio: 'inherit',
|
|
62
|
-
timeout: STEP_TIMEOUT,
|
|
63
|
-
killSignal: 'SIGKILL',
|
|
64
|
-
env: extra === undefined ? env : { ...env, ...extra },
|
|
65
|
-
})
|
|
66
|
-
return result.error !== undefined ? 1 : (result.status ?? 1)
|
|
36
|
+
const PREFIX = /^(?:npx|pnpm)$/
|
|
37
|
+
|
|
38
|
+
const words = (said: string): readonly string[] => said.split(/\s+/).filter((one) => one !== '')
|
|
39
|
+
|
|
40
|
+
function run(given: readonly string[], extra?: Record<string, string>): number {
|
|
41
|
+
const mine = given[0] === 'thread' ? 1 : PREFIX.test(given[0] ?? '') && given[1] === 'thread' ? 2 : 0
|
|
42
|
+
const how = { at: ROOT, shows: true, within: STEP_TIMEOUT, holds: extra === undefined ? env : { ...env, ...extra } }
|
|
43
|
+
const went = mine === 0 ? starts(given[0] ?? '', given.slice(1), how) : starts(execPath, [...CLI, ...given.slice(mine)], how)
|
|
44
|
+
return went.there ? went.code : 1
|
|
67
45
|
}
|
|
68
46
|
|
|
69
47
|
function refuse(id: string, code: number, because: string, runs: string): never {
|
|
@@ -74,11 +52,10 @@ function refuse(id: string, code: number, because: string, runs: string): never
|
|
|
74
52
|
exit(1)
|
|
75
53
|
}
|
|
76
54
|
|
|
77
|
-
const
|
|
78
|
-
const registry = flag === -1 ? DEFAULT : (argv[flag + 1] ?? '')
|
|
55
|
+
const given = argv.indexOf('--registry')
|
|
79
56
|
|
|
80
|
-
if (
|
|
81
|
-
stderr.write(
|
|
57
|
+
if (given !== -1) {
|
|
58
|
+
stderr.write('thread publish takes no url. Where the packages go is the address on the ht_registry row in _threads/targets.ts.\n')
|
|
82
59
|
stderr.write('\nit builds, then runs every check, then publishes. A check that fails publishes nothing.\n')
|
|
83
60
|
exit(1)
|
|
84
61
|
}
|
|
@@ -95,6 +72,18 @@ const declared = existsSync(secrets)
|
|
|
95
72
|
|
|
96
73
|
const vaulted = declared.some((one) => one.id === TOKEN)
|
|
97
74
|
|
|
75
|
+
const targets = inTree(TREE, 'targets.ts')
|
|
76
|
+
|
|
77
|
+
const registry = placedAt(
|
|
78
|
+
existsSync(targets) ? ((valuesIn(readFileSync(targets)) as { TARGETS?: readonly Target[] }).TARGETS ?? []) : [],
|
|
79
|
+
REGISTRY,
|
|
80
|
+
).replace(/[/]$/, '')
|
|
81
|
+
|
|
82
|
+
if (registry === '') {
|
|
83
|
+
stderr.write('\npublish: no target row says where the registry is, so there is nowhere for these packages to go. Give ' + REGISTRY + ' an address in _threads/targets.ts, the absolute url of the registry. NOTHING was published.\n')
|
|
84
|
+
exit(1)
|
|
85
|
+
}
|
|
86
|
+
|
|
98
87
|
if (vaulted && !sealedIn(ROOT, PRODUCTION).includes(TOKEN)) {
|
|
99
88
|
stderr.write(`\npublish: ${TOKEN} is declared in _threads/secrets.ts and has no value sealed for ${PRODUCTION}, so nothing was checked and NOTHING was published.\n`)
|
|
100
89
|
stderr.write(`publish: run \`thread create secret set ${TOKEN}\` at a terminal and paste the registry token, or take the row out to publish with the login this machine holds.\n`)
|
|
@@ -129,7 +118,7 @@ stdout.write(
|
|
|
129
118
|
|
|
130
119
|
stdout.write('publish: deriving and building what the packaging rows state first, so every check below reads the files this release ships rather than the source they were written from.\n')
|
|
131
120
|
|
|
132
|
-
const made = run(`${TYPED} packaged --build`)
|
|
121
|
+
const made = run(words(`${TYPED} packaged --build`))
|
|
133
122
|
stdout.write(`publish: packaged exited ${String(made)}\n`)
|
|
134
123
|
if (made !== 0) {
|
|
135
124
|
refuse(
|
|
@@ -147,12 +136,12 @@ for (const [index, check] of CHECKS.entries()) {
|
|
|
147
136
|
const at = `check ${String(index + 1)} of ${String(CHECKS.length)}`
|
|
148
137
|
stdout.write(`\npublish: ${at} — ${check.runs} (${check.id})\n`)
|
|
149
138
|
|
|
150
|
-
const code = run(check.runs)
|
|
139
|
+
const code = run(words(check.runs))
|
|
151
140
|
stdout.write(`publish: ${at} — exited ${String(code)}\n`)
|
|
152
141
|
if (code !== 0) refuse(check.id, code, check.because, check.runs)
|
|
153
142
|
}
|
|
154
143
|
|
|
155
|
-
const numbered = run(`${TYPED} packaged --release`)
|
|
144
|
+
const numbered = run(words(`${TYPED} packaged --release`))
|
|
156
145
|
stdout.write(`publish: packaged --release exited ${String(numbered)}\n`)
|
|
157
146
|
if (numbered !== 0) {
|
|
158
147
|
refuse(
|
|
@@ -167,11 +156,11 @@ const handed = vaulted ? { [setting()]: await tokened() } : undefined
|
|
|
167
156
|
|
|
168
157
|
stdout.write(`\npublish: every check passed. Publishing to ${registry} with ${vaulted ? `${TOKEN} from this repository's vault` : signedAs}.\n`)
|
|
169
158
|
|
|
170
|
-
const sent = run(`pnpm -r publish --registry ${registry} --no-git-checks --access public
|
|
159
|
+
const sent = run(words(`pnpm -r publish --registry ${registry} --no-git-checks --access public`), handed)
|
|
171
160
|
|
|
172
161
|
if (sent !== 0) {
|
|
173
162
|
stderr.write(`\npublish: the checks passed and the publish itself exited ${String(sent)}.\n`)
|
|
174
|
-
const back = run(`${TYPED} packaged`)
|
|
163
|
+
const back = run(words(`${TYPED} packaged`))
|
|
175
164
|
stderr.write(
|
|
176
165
|
back === 0
|
|
177
166
|
? 'publish: the manifests carry the last recorded release again and no note was written, so the next `thread publish` numbers this release once more.\n'
|
|
@@ -180,7 +169,7 @@ if (sent !== 0) {
|
|
|
180
169
|
exit(1)
|
|
181
170
|
}
|
|
182
171
|
|
|
183
|
-
const recorded = run(`${TYPED} packaged --record`)
|
|
172
|
+
const recorded = run(words(`${TYPED} packaged --record`))
|
|
184
173
|
stdout.write(`publish: packaged --record exited ${String(recorded)}\n`)
|
|
185
174
|
if (recorded !== 0) {
|
|
186
175
|
stderr.write(`\npublish: the packages went out and the note recording them refused to be written, so the next publish would number this release again. Run \`${TYPED} packaged --record\` and read what it says.\n`)
|
|
@@ -212,24 +201,24 @@ function versionAt(folder: string): string {
|
|
|
212
201
|
}
|
|
213
202
|
}
|
|
214
203
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
204
|
+
const git = calls('cli_git', ROOT)
|
|
205
|
+
|
|
206
|
+
const asked = async (what: readonly string[]): Promise<string> => (await git.rev_parse(what)).out.trim()
|
|
218
207
|
|
|
219
|
-
if (asked(['
|
|
208
|
+
if ((await asked(['--is-inside-work-tree'])) !== 'true') {
|
|
220
209
|
stdout.write("\npublish: it's not a repo, so nothing was committed.\n")
|
|
221
210
|
} else if (shipped.length === 0) {
|
|
222
211
|
stdout.write('\npublish: no packaging row names a folder, so there is nothing derived here to commit.\n')
|
|
223
212
|
} else {
|
|
224
213
|
const going = shipped.map((one) => `${named(one.id ?? '')} ${versionAt(one.folder ?? '')}`).join(', ')
|
|
225
|
-
const branch = asked(['
|
|
214
|
+
const branch = await asked(['--abbrev-ref', 'HEAD'])
|
|
226
215
|
|
|
227
|
-
for (const one of shipped)
|
|
216
|
+
for (const one of shipped) await git.stage([one.folder ?? ''], true, STEP_TIMEOUT)
|
|
228
217
|
|
|
229
|
-
if (
|
|
218
|
+
if ((await git.diff(['--cached', '--quiet'])).ok) {
|
|
230
219
|
stdout.write(`\npublish: ${going} — what is on disk is already what is committed, so this release added no artifact.\n`)
|
|
231
220
|
} else {
|
|
232
|
-
const wrote =
|
|
221
|
+
const wrote = (await git.commit(['-m', `thread publish — ${going}`], true, STEP_TIMEOUT)).code
|
|
233
222
|
stdout.write(`publish: commit exited ${String(wrote)}\n`)
|
|
234
223
|
if (wrote !== 0) {
|
|
235
224
|
stderr.write('\npublish: the packages went out and the files that describe them are not committed, so this release has no record in git.\n')
|
|
@@ -240,5 +229,5 @@ if (asked(['rev-parse', '--is-inside-work-tree']) !== 'true') {
|
|
|
240
229
|
}
|
|
241
230
|
}
|
|
242
231
|
|
|
243
|
-
stdout.write(`\npublish: done. What went out was derived, then built, then passed the gate
|
|
232
|
+
stdout.write(`\npublish: done. What went out was derived, then built, then passed the gate, in that order. The compile inside \`thread packaged --build\` is the typecheck.\n`)
|
|
244
233
|
exit(0)
|