@notis_ai/cli 0.2.30 → 0.2.32
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/README.md +15 -0
- package/config/notis_app_design_rules.json +22 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +38244 -10823
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/references/query.md +6 -4
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +12 -4
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
- package/dist/base-skills/notis-spaces/references/design.md +7 -1
- package/dist/base-skills/notis-spaces/references/fixtures.md +29 -2
- package/dist/base-skills/notis-spaces/references/reading.md +3 -1
- package/dist/base-skills/notis-spaces/references/release.md +3 -1
- package/dist/base-skills/notis-spaces/references/sdk.md +112 -33
- package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
- package/dist/base-skills/notis-spaces/references/views.md +20 -0
- package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
- package/dist/sdk/src/index.ts +1 -1
- package/dist/sdk/src/space.ts +3 -1
- package/dist/sdk/src/tailwind.ts +53 -3
- package/dist/sdk/src/ui/icons.tsx +18 -1
- package/dist/sdk/src/words/types.ts +28 -0
- package/dist/skill-sync/index.js +10 -90
- package/dist/skill-sync-worker.mjs +50 -93
- package/dist/space-harness/host.js +155 -82
- package/dist/space-sdk/dist/chunk-I4Z4UFGB.js +3 -0
- package/dist/space-sdk/dist/index.js +2 -2
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
- package/dist/space-sdk/src/index.d.ts +1 -1
- package/dist/space-sdk/src/space.ts +3 -1
- package/dist/space-sdk/src/tailwind-candidates.d.ts +315 -2
- package/dist/space-sdk/src/tailwind.ts +53 -3
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
- package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
- package/dist/space-sdk/src/ui/blocks/blocks.d.ts +18 -0
- package/dist/space-sdk/src/ui/blocks/index.d.ts +3 -3
- package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
- package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
- package/dist/space-sdk/src/ui/icons.d.ts +6 -0
- package/dist/space-sdk/src/ui/index.d.ts +5 -3
- package/dist/space-sdk/src/ui/list/ListReader.d.ts +8 -0
- package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
- package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
- package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
- package/dist/space-sdk/src/words/types.ts +28 -0
- package/dist/view-renderer/dist/host.js +224 -151
- package/dist/view-renderer/src/dom.js +3 -2
- package/dist/view-renderer/src/errors.js +9 -0
- package/dist/view-renderer/src/host.tsx +12 -5
- package/dist/view-renderer/src/remote-broker.js +3 -1
- package/dist/view-renderer/src/renderer.js +63 -16
- package/dist/view-renderer/src/skeleton.js +70 -18
- package/package.json +5 -4
- package/skills/notis-query/cli.md +3 -0
- package/skills/notis-spaces/cli.md +14 -0
- package/src/command-specs/spaces.js +138 -15
- package/src/command-specs/tools.js +3 -0
- package/src/runtime/api-hosts.generated.js +35 -0
- package/src/runtime/api-hosts.js +27 -10
- package/src/runtime/app-boundary-validator.js +248 -3
- package/src/runtime/app-data-literals.js +32 -23
- package/src/runtime/app-platform.js +68 -24
- package/src/runtime/http-agent.js +53 -0
- package/src/runtime/native-record-files.js +11 -0
- package/src/runtime/oauth.js +2 -1
- package/src/runtime/skill-sync/cloud-client.ts +0 -10
- package/src/runtime/skill-sync/index.ts +13 -15
- package/src/runtime/skill-sync/local-scanner.ts +0 -67
- package/src/runtime/skill-sync/types.ts +1 -0
- package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
- package/src/runtime/space-dependencies.js +66 -0
- package/src/runtime/space-fixture-broker.js +23 -8
- package/src/runtime/space-platform.js +47 -3
- package/src/runtime/space-source.js +10 -1
- package/src/runtime/space-test-server.js +124 -6
- package/src/runtime/space-verification.js +103 -43
- package/src/runtime/space-view-manifest.js +38 -5
- package/src/runtime/transport.js +19 -4
- package/src/runtime/view-render.js +4 -1
- package/template/tailwind.config.ts +2 -35
- package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
|
@@ -10,22 +10,19 @@ function isJsonParse(node) {
|
|
|
10
10
|
&& callee.property?.type === 'Identifier' && callee.property.name === 'parse';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (node.type === 'ExpressionStatement') return false;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
13
|
+
const NOT_DATA = new Set(['JSXAttribute', 'ImportDeclaration', 'ImportExpression', 'TSImportType',
|
|
14
|
+
'ExportAllDeclaration', 'ExportNamedDeclaration', 'NewExpression', 'TaggedTemplateExpression',
|
|
15
|
+
'MemberExpression', 'OptionalMemberExpression']);
|
|
16
|
+
const DATA = new Set(['VariableDeclarator', 'ExportDefaultDeclaration', 'ReturnStatement']);
|
|
17
|
+
|
|
18
|
+
// What this ancestor says about a literal below it: true or false, or null to ask its parent.
|
|
19
|
+
// The nearest ancestor that answers decides, as climbing from the literal would.
|
|
20
|
+
function decides(node) {
|
|
21
|
+
if (NOT_DATA.has(node.type)) return false;
|
|
22
|
+
if ((node.type === 'CallExpression' || node.type === 'OptionalCallExpression') && !isJsonParse(node)) return false;
|
|
23
|
+
if (DATA.has(node.type)) return true;
|
|
24
|
+
if (node.type === 'ExpressionStatement') return false;
|
|
25
|
+
return null;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
/**
|
|
@@ -37,6 +34,15 @@ function dataContext(ancestors) {
|
|
|
37
34
|
* Source/archive bytes are never rewritten; offsets and line breaks survive.
|
|
38
35
|
*/
|
|
39
36
|
export function maskSerializedJsonData(content, extension = '.js') {
|
|
37
|
+
return maskSerializedJsonDataOrNull(content, extension) ?? content;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The same mask, or null when the file nests too deep for the parser (Babel
|
|
42
|
+
* runs out of stack at about 200 levels): the caller then leaves the file to
|
|
43
|
+
* the server's check, which reads any depth.
|
|
44
|
+
*/
|
|
45
|
+
export function maskSerializedJsonDataOrNull(content, extension = '.js') {
|
|
40
46
|
let ast;
|
|
41
47
|
try {
|
|
42
48
|
babelParse ||= require('@babel/parser').parse;
|
|
@@ -46,15 +52,17 @@ export function maskSerializedJsonData(content, extension = '.js') {
|
|
|
46
52
|
plugins: [...(['.ts', '.tsx'].includes(extension) ? ['typescript'] : []),
|
|
47
53
|
...(extension !== '.ts' ? ['jsx'] : [])],
|
|
48
54
|
});
|
|
49
|
-
} catch { return content; }
|
|
55
|
+
} catch (error) { return error instanceof RangeError ? null : content; }
|
|
50
56
|
const ranges = [];
|
|
51
|
-
|
|
57
|
+
// Each node carries what its ancestors decided, so no literal looks back up the tree and no
|
|
58
|
+
// ancestor list is copied per node: deep data (objects nested a thousand levels) stays linear.
|
|
59
|
+
const pending = [[ast, false, null]];
|
|
52
60
|
while (pending.length) {
|
|
53
|
-
const [node,
|
|
61
|
+
const [node, underAttribute, decided] = pending.pop();
|
|
54
62
|
if (!node || typeof node !== 'object') continue;
|
|
55
63
|
const literal = node.type === 'StringLiteral' ? node.value
|
|
56
64
|
: node.type === 'TemplateLiteral' && node.expressions.length === 0 ? node.quasis[0]?.value.cooked : null;
|
|
57
|
-
if (typeof literal === 'string' &&
|
|
65
|
+
if (typeof literal === 'string' && !underAttribute && decided === true) {
|
|
58
66
|
try {
|
|
59
67
|
const value = JSON.parse(literal);
|
|
60
68
|
if (value !== null && typeof value === 'object') {
|
|
@@ -63,12 +71,13 @@ export function maskSerializedJsonData(content, extension = '.js') {
|
|
|
63
71
|
}
|
|
64
72
|
} catch { /* Ordinary/non-JSON strings keep their original checks. */ }
|
|
65
73
|
}
|
|
66
|
-
const
|
|
74
|
+
const own = node.type ? decides(node) : null;
|
|
75
|
+
const below = [underAttribute || node.type === 'JSXAttribute', own ?? decided];
|
|
67
76
|
for (const [key, value] of Object.entries(node)) {
|
|
68
77
|
if (['loc', 'extra', 'tokens', 'comments', 'errors'].includes(key)) continue;
|
|
69
78
|
if (Array.isArray(value)) {
|
|
70
|
-
for (const child of value) if (child?.type) pending.push([child,
|
|
71
|
-
} else if (value?.type) pending.push([value,
|
|
79
|
+
for (const child of value) if (child?.type) pending.push([child, ...below]);
|
|
80
|
+
} else if (value?.type) pending.push([value, ...below]);
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
let cursor = 0;
|
|
@@ -2039,15 +2039,45 @@ function replaceVerifyImage(name, png) {
|
|
|
2039
2039
|
if (png) writeFileSync(name, png, { flag: 'wx', mode: 0o600 });
|
|
2040
2040
|
}
|
|
2041
2041
|
|
|
2042
|
-
const VERIFY_WIDTHS = [390, 1440], VERIFY_LOCALES = ['en', 'fr'];
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2042
|
+
export const VERIFY_WIDTHS = [390, 1440], VERIFY_LOCALES = ['en', 'fr'];
|
|
2043
|
+
// A fixture context's name (space-test-server.js checks fixtures with it): it joins the image name only when the
|
|
2044
|
+
// fixtures declare several, after a dot, which no Space key has, so `view-a.b-...` is never Space `a-b`'s image.
|
|
2045
|
+
export const VERIFY_CONTEXT_NAME = /^[a-z0-9][a-z0-9_-]{0,31}$/;
|
|
2046
|
+
function contextPart(context, message) {
|
|
2047
|
+
if (context === undefined) return '';
|
|
2048
|
+
if (typeof context !== 'string' || !VERIFY_CONTEXT_NAME.test(context)) throw usageError(message);
|
|
2049
|
+
return `.${context}`;
|
|
2047
2050
|
}
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
+
/**
|
|
2052
|
+
* Each Space's verify images carry its key, so two Spaces verified from one folder never share a file:
|
|
2053
|
+
* `view-<key>[.<context>]-<width>-<locale>.png`.
|
|
2054
|
+
*/
|
|
2055
|
+
function viewImageName(key, width, locale, context) {
|
|
2056
|
+
if (!VERIFY_WIDTHS.includes(width) || !VERIFY_LOCALES.includes(locale)) throw usageError('Unsafe screenshot name.');
|
|
2057
|
+
return `view-${assertSpaceKey(key, 'Unsafe screenshot name.')}${contextPart(context, 'Unsafe screenshot name.')}-${width}-${locale}.png`;
|
|
2058
|
+
}
|
|
2059
|
+
/** `pending-<key>[.<context>][.reader]-<width>-<locale>.png`; `reader` is an opened item's loading state. */
|
|
2060
|
+
function pendingImageName(key, width, locale, { context, state } = {}) {
|
|
2061
|
+
if (!VERIFY_WIDTHS.includes(width) || !VERIFY_LOCALES.includes(locale) || (state !== undefined && state !== 'reader')) {
|
|
2062
|
+
throw usageError('Unsafe pending screenshot name.');
|
|
2063
|
+
}
|
|
2064
|
+
return `pending-${assertSpaceKey(key, 'Unsafe pending screenshot name.')}${contextPart(context, 'Unsafe pending screenshot name.')}${state ? `.${state}` : ''}-${width}-${locale}.png`;
|
|
2065
|
+
}
|
|
2066
|
+
// The names of the images the last verify of a Space wrote: names carrying a context cannot be listed in advance, and
|
|
2067
|
+
// matching them by pattern could take another Space's images whose key starts with this one's.
|
|
2068
|
+
const imageIndexName = key => `verify-images-${key}.json`;
|
|
2069
|
+
function readImageIndex(key) {
|
|
2070
|
+
const name = imageIndexName(key), stat = lstatSync(name, { throwIfNoEntry: false });
|
|
2071
|
+
if (!stat?.isFile() || stat.size > 64 * 1024) return [];
|
|
2072
|
+
try {
|
|
2073
|
+
const names = JSON.parse(readFileSync(name, 'utf8'));
|
|
2074
|
+
const own = new RegExp(`^(?:view|pending)-${key}(?:\\.[a-z0-9_-]+){0,2}-(?:390|1440)-(?:en|fr)\\.png$`);
|
|
2075
|
+
return Array.isArray(names) ? names.filter(value => typeof value === 'string' && own.test(value)) : [];
|
|
2076
|
+
} catch { return []; }
|
|
2077
|
+
}
|
|
2078
|
+
function recordImages(key, names) {
|
|
2079
|
+
const known = [...new Set([...readImageIndex(key), ...names])];
|
|
2080
|
+
replaceVerifyImage(imageIndexName(key), Buffer.from(JSON.stringify(known)));
|
|
2051
2081
|
}
|
|
2052
2082
|
|
|
2053
2083
|
/**
|
|
@@ -2063,39 +2093,53 @@ export function clearSpaceScreenshots(projectDir, key) {
|
|
|
2063
2093
|
|
|
2064
2094
|
/** Remove one Space's verify images, and the unnamed ones, from the pinned .notis directory (the working directory). */
|
|
2065
2095
|
function removeSpaceImages(key) {
|
|
2096
|
+
for (const name of readImageIndex(key)) replaceVerifyImage(name);
|
|
2097
|
+
replaceVerifyImage(imageIndexName(key));
|
|
2066
2098
|
for (const width of VERIFY_WIDTHS) {
|
|
2067
|
-
|
|
2099
|
+
// Names of older CLIs: one view image per width, with and without the key.
|
|
2100
|
+
replaceVerifyImage(`view-${key}-${width}.png`);
|
|
2068
2101
|
replaceVerifyImage(`view-${width}.png`);
|
|
2069
2102
|
for (const locale of VERIFY_LOCALES) {
|
|
2103
|
+
replaceVerifyImage(viewImageName(key, width, locale));
|
|
2070
2104
|
replaceVerifyImage(pendingImageName(key, width, locale));
|
|
2105
|
+
replaceVerifyImage(pendingImageName(key, width, locale, { state: 'reader' }));
|
|
2071
2106
|
replaceVerifyImage(`pending-${width}-${locale}.png`);
|
|
2072
2107
|
}
|
|
2073
2108
|
}
|
|
2074
2109
|
}
|
|
2075
2110
|
|
|
2076
|
-
/**
|
|
2111
|
+
/**
|
|
2112
|
+
* The loading-state screenshots of the last verify, `pending-<key>[.<context>][.reader]-<width>-<locale>.png` beside
|
|
2113
|
+
* the diagnostic.
|
|
2114
|
+
*/
|
|
2077
2115
|
export function saveSpacePendingScreenshots(projectDir, key, screenshots) {
|
|
2078
2116
|
if (!screenshots?.length) return [];
|
|
2079
2117
|
// Every name is checked before any file is written.
|
|
2080
|
-
const names = screenshots.map(({ width, locale }) => pendingImageName(key, width, locale));
|
|
2081
|
-
return withAppReleaseWorkspace(projectDir, (workspace) =>
|
|
2082
|
-
|
|
2083
|
-
return
|
|
2084
|
-
|
|
2118
|
+
const names = screenshots.map(({ width, locale, context, state }) => pendingImageName(key, width, locale, { context, state }));
|
|
2119
|
+
return withAppReleaseWorkspace(projectDir, (workspace) => {
|
|
2120
|
+
recordImages(key, names);
|
|
2121
|
+
return screenshots.map(({ png }, index) => {
|
|
2122
|
+
replaceVerifyImage(names[index], png);
|
|
2123
|
+
return join(workspace.projectDir, NOTIS_DIR, names[index]);
|
|
2124
|
+
});
|
|
2125
|
+
});
|
|
2085
2126
|
}
|
|
2086
2127
|
|
|
2087
2128
|
/**
|
|
2088
|
-
* The screenshots of the last verify, `view-<key>-<
|
|
2089
|
-
* its data (or of what it showed when it had not).
|
|
2129
|
+
* The screenshots of the last verify, `view-<key>[.<context>]-<width>-<locale>.png` beside the diagnostic, taken once
|
|
2130
|
+
* the view had loaded its data (or of what it showed when it had not). Each comes back with its width, locale and
|
|
2131
|
+
* context and the path it was saved at.
|
|
2090
2132
|
*/
|
|
2091
2133
|
export function saveSpaceScreenshots(projectDir, key, screenshots) {
|
|
2092
|
-
// One image per width, every name checked before any file is written.
|
|
2093
|
-
const kept = new Map((screenshots || []).map(value => [value.width, value]));
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2134
|
+
// One image per width, locale and context, every name checked before any file is written.
|
|
2135
|
+
const kept = new Map((screenshots || []).map(value => [viewImageName(key, value.width, value.locale || 'en', value.context), value]));
|
|
2136
|
+
return withAppReleaseWorkspace(projectDir, (workspace) => {
|
|
2137
|
+
recordImages(key, [...kept.keys()]);
|
|
2138
|
+
return [...kept].map(([name, { width, locale = 'en', context, png }]) => {
|
|
2139
|
+
replaceVerifyImage(name, png);
|
|
2140
|
+
return { width, locale, ...(context ? { context } : {}), path: join(workspace.projectDir, NOTIS_DIR, name) };
|
|
2141
|
+
});
|
|
2142
|
+
});
|
|
2099
2143
|
}
|
|
2100
2144
|
|
|
2101
2145
|
/** Retain the original CAS after an uncertain publish response, across CLI exits. */
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's fetch gives up on any answer that takes longer than 300 s to start (headersTimeout) or
|
|
3
|
+
* pauses longer than 300 s mid-body (bodyTimeout), and reports it as a bare "fetch failed". The
|
|
4
|
+
* CLI already bounds every request with its own AbortSignal (--timeout-ms, or a longer limit a
|
|
5
|
+
* command sets), so these requests go through an agent without those two hidden limits: the
|
|
6
|
+
* caller's signal is the one deadline, and its timeout message is the one a user reads.
|
|
7
|
+
*
|
|
8
|
+
* Only pass this dispatcher with a signal that ends the request.
|
|
9
|
+
*/
|
|
10
|
+
let agent;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Node's own fetch sends through HTTP_PROXY / HTTPS_PROXY (and honours NO_PROXY) only when its env
|
|
14
|
+
* proxy is on (NODE_USE_ENV_PROXY=1 or --use-env-proxy). A plain Agent would connect directly, so
|
|
15
|
+
* that case keeps the proxy with undici's EnvHttpProxyAgent, which reads the same variables.
|
|
16
|
+
*/
|
|
17
|
+
export function nodeEnvProxyEnabled(env = process.env, execArgv = process.execArgv) {
|
|
18
|
+
// As Node decides: the last --use-env-proxy / --no-use-env-proxy wins (NODE_OPTIONS, then the command line),
|
|
19
|
+
// and without either flag only NODE_USE_ENV_PROXY=1 turns it on.
|
|
20
|
+
const flags = [...String(env.NODE_OPTIONS || '').split(/\s+/), ...execArgv]
|
|
21
|
+
.filter(flag => flag === '--use-env-proxy' || flag === '--no-use-env-proxy');
|
|
22
|
+
return flags.length ? flags.at(-1) === '--use-env-proxy' : env.NODE_USE_ENV_PROXY === '1';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function deadlineDispatcher() {
|
|
26
|
+
if (agent === undefined) {
|
|
27
|
+
try {
|
|
28
|
+
const { Agent, EnvHttpProxyAgent } = await import('undici');
|
|
29
|
+
const options = { headersTimeout: 0, bodyTimeout: 0 };
|
|
30
|
+
agent = nodeEnvProxyEnabled() ? new EnvHttpProxyAgent(options) : new Agent(options);
|
|
31
|
+
} catch {
|
|
32
|
+
// A checkout whose dependencies predate undici keeps Node's default agent and its 300 s limits.
|
|
33
|
+
agent = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return agent ?? undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// A connect timeout is undici's own 10 s, not a slow answer: it stays a network_error naming UND_ERR_CONNECT_TIMEOUT.
|
|
40
|
+
const TIMEOUT_CODES = new Set(['UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT']);
|
|
41
|
+
|
|
42
|
+
/** The network code under fetch's bare "fetch failed" (ECONNRESET, ENOTFOUND, UND_ERR_SOCKET, ...), when there is one. */
|
|
43
|
+
export function networkCauseCode(error) {
|
|
44
|
+
for (let value = error, depth = 0; value && depth < 4; value = value.cause, depth += 1) {
|
|
45
|
+
if (typeof value.code === 'string' && value.code) return value.code;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** True when the transport itself stopped waiting for an answer (not our own AbortSignal). */
|
|
51
|
+
export function isTransportTimeout(error) {
|
|
52
|
+
return TIMEOUT_CODES.has(networkCauseCode(error));
|
|
53
|
+
}
|
|
@@ -6,6 +6,16 @@ import { usageError } from './errors.js';
|
|
|
6
6
|
|
|
7
7
|
const MAX_BYTES = 8 * 1024 * 1024;
|
|
8
8
|
const UUID = /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i;
|
|
9
|
+
// Same rule as the server (server/lib/env_file_names.py): env files hold secrets and are never stored.
|
|
10
|
+
export const ENV_FILE_MESSAGE = 'Env files (.env, .env.*, *.env) hold secrets such as API keys and are never stored. '
|
|
11
|
+
+ 'Nothing was uploaded. Share the setting names without their values instead.';
|
|
12
|
+
|
|
13
|
+
/** Whether a file name or path names a developer env file: server/lib/env_file_names.py's rule, kept the same. */
|
|
14
|
+
export function isEnvFileName(value) {
|
|
15
|
+
const name = String(value || '').replace(/\\/g, '/').replace(/\/+$/, '').split('/').pop().trim().toLowerCase();
|
|
16
|
+
return /^\.env(?:[._-][\s\S]*|rc)?$/.test(name) || name.endsWith('.env');
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
const MIME = { '.html': 'text/html', '.htm': 'text/html', '.txt': 'text/plain', '.md': 'text/markdown',
|
|
10
20
|
'.json': 'application/json', '.pdf': 'application/pdf', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp' };
|
|
11
21
|
|
|
@@ -17,6 +27,7 @@ export async function uploadNativeRecordFileWithCliRuntime({ runtime, target, re
|
|
|
17
27
|
|| !target || typeof target !== 'object' || Array.isArray(target) || !filePath) {
|
|
18
28
|
throw usageError('Choose a local file, native target, record key, schema revision and stable request ID.');
|
|
19
29
|
}
|
|
30
|
+
if (isEnvFileName(filePath) || isEnvFileName(name)) throw usageError(ENV_FILE_MESSAGE);
|
|
20
31
|
const handle = await open(filePath, 'r');
|
|
21
32
|
let data;
|
|
22
33
|
try {
|
package/src/runtime/oauth.js
CHANGED
|
@@ -651,7 +651,8 @@ function connectedCallbackHtml({ portalOrigin }) {
|
|
|
651
651
|
transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
|
|
652
652
|
}
|
|
653
653
|
.button:hover { transform: translateY(-1px); border-color: #454b57; background: #1b1e24; }
|
|
654
|
-
.button:focus-visible {
|
|
654
|
+
.button:focus-visible { border-color: var(--focus); }
|
|
655
|
+
@media (forced-colors: none) { :focus, :focus-visible { outline: none; } }
|
|
655
656
|
.button-primary { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
|
|
656
657
|
.button-primary:hover { border-color: #fff; background: #fff; }
|
|
657
658
|
.helper { margin: 12px 0 0; color: #777f8d; font-size: 0.78rem; line-height: 1.45; }
|
|
@@ -149,16 +149,6 @@ export async function pushChangedSkills(
|
|
|
149
149
|
return { skills: saved, ...(failed.length ? { failed } : {}) };
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export async function downloadSkillBundle(bundleUrl: string): Promise<Buffer> {
|
|
153
|
-
const response = await fetch(bundleUrl, { signal: AbortSignal.timeout(90_000) });
|
|
154
|
-
if (!response.ok) {
|
|
155
|
-
const text = await response.text();
|
|
156
|
-
throw new Error(`GET ${bundleUrl} → ${response.status}: ${text}`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return Buffer.from(await response.arrayBuffer());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
152
|
export async function updateAgentTargets(
|
|
163
153
|
serverUrl: string,
|
|
164
154
|
jwt: string,
|
|
@@ -15,7 +15,6 @@ import { normalizeAgentTargets } from "./types";
|
|
|
15
15
|
import { assertNativePull, checkedNativeReference, isNativeSkill, nativeState } from './native-identity';
|
|
16
16
|
import { bindNativeFolders, hasNativeFolderHistory, nativeLinkRows, nativeLocalReady, pendingLegacyUpgrade, previousNativeState, retainMissingNativeState } from './native-plan';
|
|
17
17
|
import {
|
|
18
|
-
downloadSkillBundle,
|
|
19
18
|
fetchSyncSettings,
|
|
20
19
|
pullSkills,
|
|
21
20
|
pushChangedSkills,
|
|
@@ -39,7 +38,7 @@ import {
|
|
|
39
38
|
type DeletedAgentSymlink,
|
|
40
39
|
} from "./symlink-manager";
|
|
41
40
|
import { getPushCandidates, selectCloudSkillsToApply } from "./sync-plan";
|
|
42
|
-
import {
|
|
41
|
+
import { writeCloudSkill } from "./write-cloud-skill";
|
|
43
42
|
export { fetchSyncSettings, pushChangedSkills } from './cloud-client';
|
|
44
43
|
|
|
45
44
|
export interface RunSkillSyncResult {
|
|
@@ -115,7 +114,6 @@ interface RunSkillSyncDependencies {
|
|
|
115
114
|
fetchSyncSettings: typeof fetchSyncSettings;
|
|
116
115
|
pullSkills: typeof pullSkills;
|
|
117
116
|
pushChangedSkills: typeof pushChangedSkills;
|
|
118
|
-
downloadSkillBundle: typeof downloadSkillBundle;
|
|
119
117
|
gatherTopLevelLocalSkills: typeof gatherTopLevelLocalSkills;
|
|
120
118
|
readLegacySyncState: typeof readLegacySyncState;
|
|
121
119
|
readSyncState: typeof readSyncState;
|
|
@@ -134,7 +132,6 @@ const DEFAULT_RUN_SKILL_SYNC_DEPS: RunSkillSyncDependencies = {
|
|
|
134
132
|
fetchSyncSettings,
|
|
135
133
|
pullSkills,
|
|
136
134
|
pushChangedSkills,
|
|
137
|
-
downloadSkillBundle,
|
|
138
135
|
gatherTopLevelLocalSkills,
|
|
139
136
|
readLegacySyncState,
|
|
140
137
|
readSyncState,
|
|
@@ -239,7 +236,10 @@ function cloudContentHash(skill: SyncPullResponse['skills'][number]): string {
|
|
|
239
236
|
return createHash('sha256').update(JSON.stringify({
|
|
240
237
|
md: skill.skill_md,
|
|
241
238
|
hash: skill.skill_folder_hash,
|
|
242
|
-
|
|
239
|
+
// A recorded origin is provenance, never content (SKL-059): a URL hashes as null so
|
|
240
|
+
// it cannot force a rewrite, and an absent or null one hashes as before so stored
|
|
241
|
+
// hashes stay valid.
|
|
242
|
+
source: skill.skill_source_url ? null : skill.skill_source_url,
|
|
243
243
|
files: skill.bundle_files?.slice().sort((a, b) => a.path.localeCompare(b.path)),
|
|
244
244
|
hydrationFailed: skill.bundle_hydration_failed === true,
|
|
245
245
|
})).digest('hex');
|
|
@@ -270,8 +270,8 @@ export function shouldWriteCloudSkill(
|
|
|
270
270
|
if (previous?.folderHash === localSkill.folderHash
|
|
271
271
|
&& previous.cloudContentHash === cloudContentHash(cloudSkill)) return false;
|
|
272
272
|
|
|
273
|
-
// Without a stored content baseline (
|
|
274
|
-
//
|
|
273
|
+
// Without a stored content baseline (a state file written by an older client for a
|
|
274
|
+
// Skill it fetched through a source URL keeps none) the only other signal is
|
|
275
275
|
// `skill_folder_hash`, which the server does NOT always compute the way the local
|
|
276
276
|
// folder hash is computed. A bundle-entry hash can never equal the hash of the
|
|
277
277
|
// extracted directory, and comparing the two replaced the folder on every sync
|
|
@@ -379,7 +379,7 @@ function buildSyncState(
|
|
|
379
379
|
agentTargets: normalizeAgentTargets(skill.agent_targets),
|
|
380
380
|
verifiedAgentLinks: skill.status === "active" ? verifiedAgentLinks[skill.name] ?? {} : {},
|
|
381
381
|
cloudUpdatedAt: skill.updated_at,
|
|
382
|
-
...(!failedContentNames.has(skill.name)
|
|
382
|
+
...(!failedContentNames.has(skill.name)
|
|
383
383
|
? { cloudContentHash: cloudContentHash(skill) } : {}),
|
|
384
384
|
...(appliedCloudFolderHash !== undefined ? { appliedCloudFolderHash } : {}),
|
|
385
385
|
...(appliedFileList !== undefined ? { appliedFiles: appliedFileList } : {}),
|
|
@@ -512,7 +512,7 @@ async function writePulledSkillsToScopedMirror(
|
|
|
512
512
|
syncPaths: ReturnType<typeof getSkillSyncPathsForUser>,
|
|
513
513
|
deps: Pick<
|
|
514
514
|
RunSkillSyncDependencies,
|
|
515
|
-
"
|
|
515
|
+
"writeCloudSkillToDisk"
|
|
516
516
|
>,
|
|
517
517
|
failures: SkillSyncFailure[] = [],
|
|
518
518
|
writtenSkillNames: Set<string> = new Set(),
|
|
@@ -539,10 +539,9 @@ async function writePulledSkillsToScopedMirror(
|
|
|
539
539
|
continue;
|
|
540
540
|
}
|
|
541
541
|
|
|
542
|
-
const outcome = await
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
deps.writeCloudSkillToDisk(skill, bundleBytes, syncPaths, {
|
|
542
|
+
const outcome = await writeCloudSkill(cloudSkill, {
|
|
543
|
+
writeCloudSkillToDisk: (skill) =>
|
|
544
|
+
deps.writeCloudSkillToDisk(skill, syncPaths, {
|
|
546
545
|
// What the last write put there. Everything else in the folder was
|
|
547
546
|
// produced locally and survives this one.
|
|
548
547
|
previouslyApplied: previouslyAppliedFiles(skill, local, previousState),
|
|
@@ -558,7 +557,7 @@ async function writePulledSkillsToScopedMirror(
|
|
|
558
557
|
appliedFilesByName[cloudSkill.name] = outcome.appliedFiles;
|
|
559
558
|
}
|
|
560
559
|
} else {
|
|
561
|
-
failures.push({ name: cloudSkill.name, error: "Skill content could not be
|
|
560
|
+
failures.push({ name: cloudSkill.name, error: "Skill content could not be written; sync will retry" });
|
|
562
561
|
}
|
|
563
562
|
}
|
|
564
563
|
|
|
@@ -589,7 +588,6 @@ export async function materializeCloudSkillsForLocalShell(
|
|
|
589
588
|
jwt: string,
|
|
590
589
|
dependencies: Partial<Pick<
|
|
591
590
|
RunSkillSyncDependencies,
|
|
592
|
-
| "downloadSkillBundle"
|
|
593
591
|
| "deleteLocalSkill"
|
|
594
592
|
| "pullSkills"
|
|
595
593
|
| "readSyncState"
|
|
@@ -953,54 +953,6 @@ async function createZipFromDirectory(directoryPath: string): Promise<string> {
|
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
async function extractZipToDirectory(
|
|
957
|
-
zipPath: string,
|
|
958
|
-
destinationDir: string,
|
|
959
|
-
): Promise<string[]> {
|
|
960
|
-
const extractRoot = await fs.mkdtemp(
|
|
961
|
-
path.join(os.tmpdir(), "notis-skill-extract-"),
|
|
962
|
-
);
|
|
963
|
-
|
|
964
|
-
try {
|
|
965
|
-
if (process.platform === "win32") {
|
|
966
|
-
await execFileAsync("powershell.exe", [
|
|
967
|
-
"-NoProfile",
|
|
968
|
-
"-Command",
|
|
969
|
-
`Expand-Archive -Path '${zipPath.replace(/'/g, "''")}' -DestinationPath '${extractRoot.replace(/'/g, "''")}' -Force`,
|
|
970
|
-
]);
|
|
971
|
-
} else {
|
|
972
|
-
await execFileAsync("unzip", ["-qq", zipPath, "-d", extractRoot]);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
const extractedEntries = await fs.readdir(extractRoot, {
|
|
976
|
-
withFileTypes: true,
|
|
977
|
-
});
|
|
978
|
-
const extractedDirectory = extractedEntries.find((entry) =>
|
|
979
|
-
entry.isDirectory(),
|
|
980
|
-
);
|
|
981
|
-
const sourceDir = extractedDirectory
|
|
982
|
-
? path.join(extractRoot, extractedDirectory.name)
|
|
983
|
-
: extractRoot;
|
|
984
|
-
|
|
985
|
-
await fs.rm(destinationDir, { recursive: true, force: true });
|
|
986
|
-
await fs.mkdir(path.dirname(destinationDir), { recursive: true });
|
|
987
|
-
await fs.cp(sourceDir, destinationDir, { recursive: true });
|
|
988
|
-
return await listRelativeFiles(destinationDir);
|
|
989
|
-
} finally {
|
|
990
|
-
await fs.rm(extractRoot, { recursive: true, force: true });
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
async function listRelativeFiles(dirPath: string): Promise<string[]> {
|
|
995
|
-
try {
|
|
996
|
-
const files = await listFilesRecursive(dirPath);
|
|
997
|
-
return files.map((filePath) => toPosixRelativePath(dirPath, filePath)).sort();
|
|
998
|
-
} catch (error) {
|
|
999
|
-
if ((error as NodeJS.ErrnoException)?.code === "ENOENT") return [];
|
|
1000
|
-
throw error;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
956
|
function toPosixRelativePath(rootDir: string, filePath: string): string {
|
|
1005
957
|
return path.relative(rootDir, filePath).split(path.sep).join("/");
|
|
1006
958
|
}
|
|
@@ -1178,14 +1130,12 @@ export async function captureNativeSkillFiles(skill: LocalSkill): Promise<Bundle
|
|
|
1178
1130
|
|
|
1179
1131
|
export async function writeCloudSkillToDisk(
|
|
1180
1132
|
skill: CloudSkill,
|
|
1181
|
-
bundleBytes?: Buffer,
|
|
1182
1133
|
paths: SkillSyncPaths = DEFAULT_SYNC_PATHS,
|
|
1183
1134
|
options: { previouslyApplied?: readonly string[]; expectedFolderHash?: string; legacyBaseline?: boolean } = {},
|
|
1184
1135
|
): Promise<SkillWriteOutcome | false> {
|
|
1185
1136
|
if (isNativeSkill(skill)) {
|
|
1186
1137
|
assertNativePull({ skills: [{ ...skill, name: 'native-' + skill.id }], skill_sync_protocol: 2, sync_scope: skill.native_scope,
|
|
1187
1138
|
sync_enabled: true, last_synced_at: null });
|
|
1188
|
-
if (bundleBytes?.length) throw new Error('Native Skills require their verified complete file response.');
|
|
1189
1139
|
}
|
|
1190
1140
|
const skillDir = path.join(
|
|
1191
1141
|
paths.skillsDir,
|
|
@@ -1196,23 +1146,6 @@ export async function writeCloudSkillToDisk(
|
|
|
1196
1146
|
// An unchanged legacy folder upgrading in place: shared files take the cloud version.
|
|
1197
1147
|
legacyBaseline: isNativeSkill(skill) && options.legacyBaseline === true && options.expectedFolderHash !== undefined };
|
|
1198
1148
|
|
|
1199
|
-
if (bundleBytes?.length) {
|
|
1200
|
-
const bundlePath = path.join(
|
|
1201
|
-
os.tmpdir(),
|
|
1202
|
-
`notis-skill-download-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`,
|
|
1203
|
-
);
|
|
1204
|
-
try {
|
|
1205
|
-
await fs.writeFile(bundlePath, bundleBytes);
|
|
1206
|
-
let appliedFiles: string[] = [];
|
|
1207
|
-
await replaceSkillDirectoryAtomically(skillDir, async (stagingDir) => {
|
|
1208
|
-
appliedFiles = await extractZipToDirectory(bundlePath, stagingDir);
|
|
1209
|
-
}, preserve);
|
|
1210
|
-
return { written: true, appliedFiles };
|
|
1211
|
-
} finally {
|
|
1212
|
-
await fs.rm(bundlePath, { force: true });
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
1149
|
if (
|
|
1217
1150
|
!skill.skill_md &&
|
|
1218
1151
|
(!skill.bundle_files || skill.bundle_files.length === 0)
|
|
@@ -85,6 +85,7 @@ export interface CloudSkill {
|
|
|
85
85
|
skill_md: string | null;
|
|
86
86
|
agent_targets?: Partial<AgentTargets> | null;
|
|
87
87
|
skill_folder_hash?: string | null;
|
|
88
|
+
/** Where the Skill came from. Provenance only: sync never downloads it (SKL-059). */
|
|
88
89
|
skill_source_url?: string | null;
|
|
89
90
|
bundle_files?: BundleFile[] | null;
|
|
90
91
|
bundle_hydration_failed?: boolean | null;
|
|
@@ -1,35 +1,19 @@
|
|
|
1
1
|
import type { CloudSkill, SkillWriteOutcome } from './types';
|
|
2
2
|
|
|
3
3
|
interface WriteCloudSkillDependencies {
|
|
4
|
-
|
|
5
|
-
writeCloudSkillToDisk: (skill: CloudSkill, bundleBytes?: Buffer) => Promise<SkillWriteOutcome | boolean>;
|
|
4
|
+
writeCloudSkillToDisk: (skill: CloudSkill) => Promise<SkillWriteOutcome | boolean>;
|
|
6
5
|
onWarning?: (message: string, error: unknown) => void;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Writes one pulled Skill from what the pull itself carries: its saved files
|
|
10
|
+
* (`bundle_files`) or, without them, its SKILL.md. Nothing is downloaded;
|
|
11
|
+
* `skill_source_url` only records where a Skill came from (SKL-059).
|
|
12
|
+
*/
|
|
13
|
+
export async function writeCloudSkill(
|
|
10
14
|
skill: CloudSkill,
|
|
11
15
|
dependencies: WriteCloudSkillDependencies,
|
|
12
16
|
): Promise<SkillWriteOutcome | boolean> {
|
|
13
|
-
if (skill.skill_source_url) {
|
|
14
|
-
try {
|
|
15
|
-
const bundleBytes = await dependencies.downloadSkillBundle(skill.skill_source_url);
|
|
16
|
-
const wroteBundleToDisk = await dependencies.writeCloudSkillToDisk(skill, bundleBytes);
|
|
17
|
-
if (wroteBundleToDisk) {
|
|
18
|
-
return wroteBundleToDisk;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
dependencies.onWarning?.(
|
|
22
|
-
`Bundle sync for "${skill.name}" produced no local changes, falling back to SKILL.md payload.`,
|
|
23
|
-
new Error('Bundle write returned false'),
|
|
24
|
-
);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
dependencies.onWarning?.(
|
|
27
|
-
`Failed to apply bundle sync for "${skill.name}", falling back to SKILL.md payload.`,
|
|
28
|
-
error,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
17
|
if (skill.bundle_hydration_failed) {
|
|
34
18
|
dependencies.onWarning?.(
|
|
35
19
|
`Skipping markdown fallback for synced skill "${skill.name}" because its stored bundle could not be hydrated by the server.`,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Space workspace builds with its own packages (TypeScript, Vite, Tailwind, React, the SDK). A folder that
|
|
3
|
+
* has never been installed (a copy, a fresh clone, a scaffold) gets them on its first `notis spaces build`:
|
|
4
|
+
* `npm ci` from its lock file, `--prefer-offline` so every package this machine has already downloaded for
|
|
5
|
+
* another Space comes from npm's shared cache instead of the network. A workspace that is already installed
|
|
6
|
+
* is never touched.
|
|
7
|
+
*/
|
|
8
|
+
import { spawnSync } from 'node:child_process';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { usageError } from './errors.js';
|
|
13
|
+
import { npmFailureReason } from './app-platform.js';
|
|
14
|
+
|
|
15
|
+
const INSTALL_TIMEOUT_MS = 10 * 60_000;
|
|
16
|
+
// --include=dev: a build needs the devDependencies (TypeScript, Vite, Tailwind) even under NODE_ENV=production or omit=dev.
|
|
17
|
+
const INSTALL_FLAGS = Object.freeze(['--include=dev', '--prefer-offline', '--no-audit', '--no-fund']);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* True when the package a build loads first resolves from this workspace, the way the build resolves it:
|
|
21
|
+
* from its own node_modules or an ancestor's (an npm workspace member installed at the root).
|
|
22
|
+
*/
|
|
23
|
+
export function spaceDependenciesInstalled(projectDir) {
|
|
24
|
+
const require = createRequire(join(projectDir, 'package.json'));
|
|
25
|
+
try { require.resolve('typescript/package.json'); return true; } catch { return false; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function runNpm(args, projectDir) {
|
|
29
|
+
// A verbose npm config can print more than spawnSync's 1 MB default before it finishes.
|
|
30
|
+
return spawnSync('npm', args, { cwd: projectDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024,
|
|
31
|
+
timeout: INSTALL_TIMEOUT_MS, shell: process.platform === 'win32' });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Install this workspace's packages when it has none yet. Returns what it did, for the build answer:
|
|
36
|
+
* `null` when nothing was needed, else `{ command, seconds }`.
|
|
37
|
+
*/
|
|
38
|
+
export function ensureSpaceDependencies(projectDir, { log = () => {}, run = runNpm } = {}) {
|
|
39
|
+
if (!existsSync(join(projectDir, 'package.json')) || spaceDependenciesInstalled(projectDir)) return null;
|
|
40
|
+
const locked = existsSync(join(projectDir, 'package-lock.json'));
|
|
41
|
+
let args = [locked ? 'ci' : 'install', ...INSTALL_FLAGS];
|
|
42
|
+
let command = `npm ${args.join(' ')}`;
|
|
43
|
+
log(`This Space folder has no installed packages yet: running ${command} once (packages this machine already has come from npm's cache).`);
|
|
44
|
+
const started = Date.now();
|
|
45
|
+
let result = run(args, projectDir);
|
|
46
|
+
if (locked && result.status !== 0 && !result.error && /in sync/i.test(`${result.stderr || ''}\n${result.stdout || ''}`)) {
|
|
47
|
+
// package.json gained a package its lock file does not hold yet: npm install records it instead of refusing.
|
|
48
|
+
args = ['install', ...INSTALL_FLAGS];
|
|
49
|
+
command = `npm ${args.join(' ')}`;
|
|
50
|
+
log(`package-lock.json does not match package.json yet: running ${command} instead.`);
|
|
51
|
+
result = run(args, projectDir);
|
|
52
|
+
}
|
|
53
|
+
const seconds = Math.round((Date.now() - started) / 100) / 10;
|
|
54
|
+
if (result.error || result.status !== 0) {
|
|
55
|
+
const reason = result.error?.code === 'ETIMEDOUT' ? 'it did not finish within 10 minutes'
|
|
56
|
+
: result.error?.code === 'ENOENT' ? 'npm is not installed on this machine'
|
|
57
|
+
: npmFailureReason(`${result.stderr || ''}\n${result.stdout || ''}`) || `npm exited with code ${result.status}`;
|
|
58
|
+
throw usageError(`Installing this Space's packages failed (${command}: ${reason}). Nothing was built. `
|
|
59
|
+
+ `Fix that, or run ${command} in ${projectDir} yourself, then build again.`);
|
|
60
|
+
}
|
|
61
|
+
if (!spaceDependenciesInstalled(projectDir)) {
|
|
62
|
+
throw usageError(`${command} finished but TypeScript is still missing from this Space's packages. Add typescript to its devDependencies, then build again.`);
|
|
63
|
+
}
|
|
64
|
+
log(`Installed this Space's packages in ${seconds} s.`);
|
|
65
|
+
return { command, seconds };
|
|
66
|
+
}
|