@supersdk/supercli 0.3.3-staging.45 → 0.3.3-staging.47

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.
Files changed (67) hide show
  1. package/dist/build/artifactIntegrity.js +158 -2
  2. package/dist/build/artifactIntegrity.js.map +1 -1
  3. package/dist/build/projectBuild.js +335 -0
  4. package/dist/build/projectBuild.js.map +1 -0
  5. package/dist/cli.js +0 -2
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/add.js +35 -29
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/build.js +407 -105
  10. package/dist/commands/build.js.map +1 -1
  11. package/dist/commands/init.js +22 -29
  12. package/dist/commands/init.js.map +1 -1
  13. package/dist/commands/register.js +62 -217
  14. package/dist/commands/register.js.map +1 -1
  15. package/dist/config/appConfig.js +36 -163
  16. package/dist/config/appConfig.js.map +1 -1
  17. package/dist/config/superConfig.js +213 -185
  18. package/dist/config/superConfig.js.map +1 -1
  19. package/dist/deploy/manifest.js +189 -167
  20. package/dist/deploy/manifest.js.map +1 -1
  21. package/dist/deploy/preflight.js +15 -16
  22. package/dist/deploy/preflight.js.map +1 -1
  23. package/dist/deploy/runAdapter.js +7 -4
  24. package/dist/deploy/runAdapter.js.map +1 -1
  25. package/dist/docker/dockerCli.js +72 -77
  26. package/dist/docker/dockerCli.js.map +1 -1
  27. package/dist/template/README.md +26 -94
  28. package/dist/template/android/gradle/supersdk-config-reader.gradle +13 -62
  29. package/dist/template/android/scripts/build.sh +11 -0
  30. package/dist/template/ios/project.yml +1 -1
  31. package/dist/template/ios/scripts/build.sh +19 -0
  32. package/dist/template/ios/scripts/render_project.py +60 -0
  33. package/dist/template/ios/supersdk-default.config.json +6 -0
  34. package/dist/template/service/scripts/build.sh +11 -0
  35. package/dist/template/super.json +22 -14
  36. package/dist/template/template_manifest.json +3 -7
  37. package/dist/template/web/package.json +8 -0
  38. package/dist/template/web/scripts/build.sh +8 -0
  39. package/dist/template/web/scripts/web_package.py +490 -0
  40. package/dist/template/web/src/js/app.js +2 -2
  41. package/dist/util/shell.js +3 -3
  42. package/dist/workspace/config.js +3 -79
  43. package/dist/workspace/config.js.map +1 -1
  44. package/dist/workspace/identity.js +6 -15
  45. package/dist/workspace/identity.js.map +1 -1
  46. package/dist/workspace/projectIdentity.js +2 -7
  47. package/dist/workspace/projectIdentity.js.map +1 -1
  48. package/dist/workspace/template.js +205 -77
  49. package/dist/workspace/template.js.map +1 -1
  50. package/package.json +3 -1
  51. package/dist/commands/config.js +0 -170
  52. package/dist/commands/config.js.map +0 -1
  53. package/dist/template/scripts/android_snapshot_canary.py +0 -145
  54. package/dist/template/scripts/build_android.sh +0 -382
  55. package/dist/template/scripts/build_ios.sh +0 -331
  56. package/dist/template/scripts/build_service.sh +0 -89
  57. package/dist/template/scripts/build_site.sh +0 -57
  58. package/dist/template/scripts/lib/workspace.sh +0 -43
  59. package/dist/template/scripts/serve_web.py +0 -78
  60. package/dist/template/scripts/super_build_orchestrator.py +0 -344
  61. package/dist/template/scripts/supersdk_template.py +0 -1394
  62. package/dist/template/scripts/web_host_validator.py +0 -103
  63. package/dist/template/scripts/web_package.py +0 -296
  64. package/dist/template/scripts/ws03_shared_schema_merge_guard.py +0 -73
  65. package/dist/template/super_build.sh +0 -70
  66. package/dist/workspace/inspect.js +0 -275
  67. package/dist/workspace/inspect.js.map +0 -1
@@ -40,7 +40,7 @@ exports.canonicalConfigDigest = canonicalConfigDigest;
40
40
  exports.parseSuperConfig = parseSuperConfig;
41
41
  exports.findSuperConfig = findSuperConfig;
42
42
  exports.configProblem = configProblem;
43
- /** Strict schema-v4 mirror of the bundled Python manifest authority. */
43
+ /** Strict schema-v5 parser and workspace discovery. */
44
44
  const crypto = __importStar(require("node:crypto"));
45
45
  const fs = __importStar(require("node:fs"));
46
46
  const node_net_1 = require("node:net");
@@ -49,36 +49,71 @@ const appConfig_1 = require("./appConfig");
49
49
  exports.CONFIG_FILENAME = appConfig_1.APP_CONFIG_FILENAME;
50
50
  exports.CONFIG_SCHEMA_VERSION = appConfig_1.APP_CONFIG_SCHEMA_VERSION;
51
51
  const MAX_SEARCH_DEPTH = 64;
52
- const rootKeys = new Set(['schemaVersion', 'spid', 'orgId', 'name', 'version', 'sdk', 'projects']);
53
- const commonProjectKeys = new Set(['projectId', 'type', 'dir', 'name', 'version', 'sdk']);
52
+ const rootKeys = new Set(['schemaVersion', 'spid', 'orgId', 'name', 'version', 'projects']);
53
+ const commonProjectKeys = new Set(['projectId', 'type', 'dir', 'name', 'build', 'version']);
54
54
  const typeProjectKeys = {
55
- android: new Set(['package']), ios: new Set(['bundleId', 'spmMode']),
56
- site: new Set(['deploy', 'offline', 'build']), service: new Set(['deploy', 'build']),
55
+ android: new Set(['package']),
56
+ ios: new Set(['bundleId', 'spmMode']),
57
+ site: new Set(['deploy', 'offline']),
58
+ service: new Set(['deploy']),
57
59
  };
58
60
  const versionKeys = new Set(['name', 'code']);
59
- const sdkKeys = new Set(['androidVersion', 'iosPackageUrl', 'iosVersion']);
60
- const siteBuildKeys = new Set(['outputDir']);
61
- const serviceBuildKeys = new Set(['context', 'dockerfile', 'platform', 'argsFromEnv']);
61
+ const buildKeys = new Set(['entry', 'args', 'artifacts']);
62
+ const artifactKeys = new Set(['id', 'kind', 'path']);
62
63
  const deployCommonKeys = new Set(['envTarget', 'slug', 'name', 'env']);
63
- const serviceDeployKeys = new Set([...deployCommonKeys, 'port', 'cpuMilli', 'memoryMiB', 'maxScale', 'databaseConnection', 'runtimeEnvFromEnv', 'secretsFromEnv']);
64
- function plain(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
65
- function fail(filePath, reason) { return { kind: 'invalid', path: filePath, reason }; }
66
- function exactKeys(object, allowed, label) { const unknown = Object.keys(object).filter((key) => !allowed.has(key)); return unknown.length ? `${label} contains unknown field(s): ${unknown.join(', ')}` : undefined; }
67
- function string(value) { return typeof value === 'string' && value.trim() !== ''; }
68
- function integer(value) { return Number.isInteger(value) && typeof value === 'number'; }
69
- function envName(value) { return typeof value === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value); }
70
- function validProjectId(value) { return typeof value === 'string' && /^[a-z][a-z0-9-]{0,63}$/.test(value); }
71
- function validEnvTarget(value) { return typeof value === 'string' && /^[a-z][a-z0-9-]{0,31}$/.test(value); }
72
- function normalizeProjectDir(raw) { if (raw.trim() !== raw || raw.length === 0 || raw.startsWith('/') || raw.includes('\\') || /^[A-Za-z]:/.test(raw))
73
- return undefined; const parts = raw.split('/'); if (parts.some((part) => part === '' || part === '.' || part === '..'))
74
- return undefined; return parts.join('/'); }
75
- function normalizedRelative(raw, allowDot = false) { if (!string(raw) || raw.includes('\\') || raw.startsWith('/') || /^[A-Za-z]:/.test(raw))
76
- return undefined; if (raw === '.' && allowDot)
77
- return raw; const parts = raw.split('/'); return parts.length && !parts.some((part) => part === '' || part === '.' || part === '..') ? parts.join('/') : undefined; }
64
+ const serviceDeployKeys = new Set([
65
+ ...deployCommonKeys,
66
+ 'port',
67
+ 'cpuMilli',
68
+ 'memoryMiB',
69
+ 'maxScale',
70
+ 'databaseConnection',
71
+ 'runtimeEnvFromEnv',
72
+ 'secretsFromEnv',
73
+ ]);
74
+ function plain(value) {
75
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
76
+ }
77
+ function fail(filePath, reason) {
78
+ return { kind: 'invalid', path: filePath, reason };
79
+ }
80
+ function exactKeys(object, allowed, label) {
81
+ const unknown = Object.keys(object).filter((key) => !allowed.has(key));
82
+ return unknown.length ? `${label} contains unknown field(s): ${unknown.join(', ')}` : undefined;
83
+ }
84
+ function nonEmptyString(value) {
85
+ return typeof value === 'string' && value.trim() !== '';
86
+ }
87
+ function integer(value) {
88
+ return typeof value === 'number' && Number.isInteger(value);
89
+ }
90
+ function envName(value) {
91
+ return typeof value === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
92
+ }
93
+ function validProjectId(value) {
94
+ return typeof value === 'string' && /^[a-z][a-z0-9-]{0,63}$/.test(value);
95
+ }
96
+ function validEnvTarget(value) {
97
+ return typeof value === 'string' && /^[a-z][a-z0-9-]{0,31}$/.test(value);
98
+ }
99
+ function normalizeProjectDir(raw) {
100
+ if (raw.trim() !== raw || raw.length === 0 || raw.includes('\0') || raw.startsWith('/') || raw.includes('\\') || /^[A-Za-z]:/.test(raw))
101
+ return undefined;
102
+ const parts = raw.split('/');
103
+ if (parts.some((part) => part === '' || part === '.' || part === '..'))
104
+ return undefined;
105
+ return parts.join('/');
106
+ }
107
+ function normalizedRelative(raw) {
108
+ if (!nonEmptyString(raw) || raw.trim() !== raw || raw.includes('\0') || raw.includes('\\') || raw.startsWith('/') || /^[A-Za-z]:/.test(raw))
109
+ return undefined;
110
+ const parts = raw.split('/');
111
+ return parts.length > 0 && !parts.some((part) => part === '' || part === '.' || part === '..') ? parts.join('/') : undefined;
112
+ }
78
113
  function isAncestor(a, b) { return a !== b && b.startsWith(`${a}/`); }
79
114
  function validateVersion(value, label, complete) {
80
115
  if (value === undefined)
81
- return complete ? `${label} is required` : undefined;
116
+ return undefined;
82
117
  if (!plain(value))
83
118
  return `${label} must be a JSON object`;
84
119
  const unknown = exactKeys(value, versionKeys, label);
@@ -86,73 +121,27 @@ function validateVersion(value, label, complete) {
86
121
  return unknown;
87
122
  if (complete && (!Object.hasOwn(value, 'name') || !Object.hasOwn(value, 'code')))
88
123
  return `${label} must contain name and code`;
89
- if (value.name !== undefined && !string(value.name))
124
+ if (value.name !== undefined && !nonEmptyString(value.name))
90
125
  return `${label}.name must be a non-empty string`;
91
126
  if (value.code !== undefined && (!integer(value.code) || value.code < 1 || value.code > 2147483647))
92
127
  return `${label}.code must be a positive 32-bit integer`;
93
128
  return undefined;
94
129
  }
95
- function validateSdk(value, label) { if (value === undefined)
96
- return undefined; if (!plain(value))
97
- return `${label} must be a JSON object`; const unknown = exactKeys(value, sdkKeys, label); if (unknown)
98
- return unknown; for (const [key, scalar] of Object.entries(value))
99
- if (plain(scalar) || Array.isArray(scalar))
100
- return `${label}.${key} must be a scalar`; return undefined; }
101
- function validIosPackageUrl(value) {
102
- if (!string(value))
103
- return false;
104
- let parsed;
105
- try {
106
- parsed = new URL(value);
107
- }
108
- catch {
109
- return false;
110
- }
111
- if (parsed.protocol !== 'https:' || !parsed.hostname)
112
- return false;
113
- const host = parsed.hostname.toLowerCase().replace(/^\[|\]$/g, '');
114
- if (host === 'localhost' || host === 'example.com' || host === 'example.org'
115
- || host.endsWith('.localhost') || host.endsWith('.local') || host.endsWith('.example.com')
116
- || host.endsWith('.example.org') || host.includes('example.invalid'))
117
- return false;
118
- if ((0, node_net_1.isIP)(host) === 4) {
119
- const octets = host.split('.').map(Number);
120
- if (octets[0] === 10 || octets[0] === 127 || octets[0] === 0
121
- || (octets[0] === 169 && octets[1] === 254) || (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31)
122
- || (octets[0] === 192 && octets[1] === 168))
123
- return false;
124
- }
125
- if ((0, node_net_1.isIP)(host) === 6 && (host === '::' || host === '::1' || /^f[cd]/.test(host) || /^fe[89ab]/.test(host)))
126
- return false;
127
- return true;
128
- }
129
- function validateProjectSdk(type, mode, sdk, label) {
130
- if (type === 'android') {
131
- if (typeof sdk.androidVersion !== 'string' || !/^[0-9]+\.[0-9]+\.[0-9]+(?:[-.][A-Za-z0-9]+)*$/.test(sdk.androidVersion.trim()))
132
- return `${label}.sdk.androidVersion must be a valid Android SDK version`;
133
- }
134
- if (type === 'ios') {
135
- const spmMode = mode ?? 'mock';
136
- if (spmMode === 'mock' && (Object.hasOwn(sdk, 'iosPackageUrl') || Object.hasOwn(sdk, 'iosVersion')))
137
- return `${label}.sdk iosPackageUrl/iosVersion are not allowed when spmMode is mock`;
138
- if (spmMode === 'real') {
139
- if (!validIosPackageUrl(sdk.iosPackageUrl))
140
- return `${label}.sdk.iosPackageUrl must be a non-local HTTPS URL when spmMode is real`;
141
- if (typeof sdk.iosVersion !== 'string' || !/^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$/.test(sdk.iosVersion))
142
- return `${label}.sdk.iosVersion must be a semantic version when spmMode is real`;
130
+ function validateRefs(value, label) {
131
+ if (!Array.isArray(value))
132
+ return `${label} must be an array`;
133
+ const seen = new Set();
134
+ for (let i = 0; i < value.length; i += 1) {
135
+ const item = value[i];
136
+ if (!plain(item) || Object.keys(item).some((key) => key !== 'name' && key !== 'sourceEnv') || !envName(item.name) || !envName(item.sourceEnv)) {
137
+ return `${label}[${i}] must contain valid name/sourceEnv`;
143
138
  }
139
+ if (seen.has(item.name))
140
+ return `${label}[${i}].name duplicates a platform environment variable name`;
141
+ seen.add(item.name);
144
142
  }
145
143
  return undefined;
146
144
  }
147
- function validateRefs(value, label) { if (!Array.isArray(value))
148
- return `${label} must be an array`; const seen = new Set(); for (let i = 0; i < value.length; i += 1) {
149
- const item = value[i];
150
- if (!plain(item) || Object.keys(item).some((key) => key !== 'name' && key !== 'sourceEnv') || !envName(item.name) || !envName(item.sourceEnv))
151
- return `${label}[${i}] must contain valid name/sourceEnv`;
152
- if (seen.has(item.name))
153
- return `${label}[${i}].name duplicates a platform environment variable name`;
154
- seen.add(item.name);
155
- } return undefined; }
156
145
  function validateDeploy(value, type, label) {
157
146
  if (value === undefined)
158
147
  return [];
@@ -168,20 +157,20 @@ function validateDeploy(value, type, label) {
168
157
  const unknown = exactKeys(item, type === 'service' ? serviceDeployKeys : deployCommonKeys, where);
169
158
  if (unknown)
170
159
  return unknown;
171
- if (!validEnvTarget(item.envTarget) || typeof item.slug !== 'string' || !/^[a-z0-9]{1,32}$/.test(item.slug) || item.slug === 'stg' || item.slug === 'site' || typeof item.env !== 'string' || !/^[a-z0-9]{1,10}$/.test(item.env))
160
+ if (!validEnvTarget(item.envTarget) || typeof item.slug !== 'string' || !/^[a-z0-9]{1,32}$/.test(item.slug) || item.slug === 'stg' || item.slug === 'site' || typeof item.env !== 'string' || !/^[a-z0-9]{1,10}$/.test(item.env)) {
172
161
  return `${where} requires valid envTarget, slug and env`;
162
+ }
173
163
  if (targets.has(item.envTarget))
174
164
  return `${where}.envTarget must be unique within the project`;
175
165
  targets.add(item.envTarget);
176
- if (item.name !== undefined && (!string(item.name) || item.name !== item.name.trim() || item.name.length > 50))
166
+ if (item.name !== undefined && (!nonEmptyString(item.name) || item.name !== item.name.trim() || item.name.length > 50))
177
167
  return `${where}.name must be 1..50 characters without surrounding whitespace`;
178
- if (type !== 'service' && Object.keys(item).some((key) => !deployCommonKeys.has(key)))
179
- return `${where} has service-only fields`;
180
168
  if (type === 'service') {
181
- for (const [key, max] of [['port', 65535], ['cpuMilli', 4000], ['memoryMiB', 8192], ['maxScale', 10]])
169
+ for (const [key, max] of [['port', 65535], ['cpuMilli', 4000], ['memoryMiB', 8192], ['maxScale', 10]]) {
182
170
  if (item[key] !== undefined && (!integer(item[key]) || item[key] < 1 || item[key] > max))
183
171
  return `${where}.${key} must be an integer from 1 to ${max}`;
184
- if (item.databaseConnection !== undefined && item.databaseConnection !== null && !string(item.databaseConnection))
172
+ }
173
+ if (item.databaseConnection !== undefined && item.databaseConnection !== null && !nonEmptyString(item.databaseConnection))
185
174
  return `${where}.databaseConnection must be a string or null`;
186
175
  const runtime = item.runtimeEnvFromEnv === undefined ? undefined : validateRefs(item.runtimeEnvFromEnv, `${where}.runtimeEnvFromEnv`);
187
176
  if (runtime)
@@ -229,24 +218,79 @@ function validOfflineHost(value) {
229
218
  return labels.length >= 2 && !/^\d+$/.test(labels[labels.length - 1])
230
219
  && labels.every((part) => part.length <= 63 && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(part));
231
220
  }
232
- function validateSite(item, label) { const build = item.build === undefined ? {} : item.build; if (!plain(build))
233
- return `${label}.build must be a JSON object`; const unknownBuild = exactKeys(build, siteBuildKeys, `${label}.build`); if (unknownBuild)
234
- return unknownBuild; if (normalizedRelative(build.outputDir ?? 'dist') === undefined)
235
- return `${label}.build.outputDir must stay within the project directory`; const offline = item.offline === undefined ? {} : item.offline; if (!plain(offline))
236
- return `${label}.offline must be a JSON object`; const unknownOffline = exactKeys(offline, new Set(['host']), `${label}.offline`); if (unknownOffline)
237
- return unknownOffline; if (offline.host !== undefined && !validOfflineHost(offline.host))
238
- return `${label}.offline.host must be a deployable domain or HTTP(S) URL`; return undefined; }
239
- function validateService(item, label) { if (!Object.hasOwn(item, 'build') || !plain(item.build))
240
- return `${label}.build is required for service projects`; const build = item.build; const unknown = exactKeys(build, serviceBuildKeys, `${label}.build`); if (unknown)
241
- return unknown; if (normalizedRelative(build.context ?? '.', true) === undefined)
242
- return `${label}.build.context must be a project-relative POSIX path`; if (normalizedRelative(build.dockerfile ?? 'Dockerfile') === undefined)
243
- return `${label}.build.dockerfile must be a project-relative POSIX path`; if ((build.platform ?? 'linux/amd64') !== 'linux/amd64')
244
- return `${label}.build.platform must be linux/amd64 for this engine version`; if (build.argsFromEnv !== undefined) {
245
- if (!Array.isArray(build.argsFromEnv) || build.argsFromEnv.some((value) => !envName(value)) || new Set(build.argsFromEnv).size !== build.argsFromEnv.length)
246
- return `${label}.build.argsFromEnv must be unique environment variable names`;
247
- } return undefined; }
221
+ function containsBuildVariable(value) { return value.includes('${'); }
222
+ function validateBuildArg(value, label) {
223
+ if (value.includes('\0'))
224
+ return `${label} must not contain NUL`;
225
+ let cursor = 0;
226
+ while (cursor < value.length) {
227
+ const start = value.indexOf('${', cursor);
228
+ if (start < 0)
229
+ return undefined;
230
+ if (!value.startsWith('${spid}', start))
231
+ return `${label} only supports the exact \${spid} placeholder`;
232
+ cursor = start + '${spid}'.length;
233
+ }
234
+ return undefined;
235
+ }
236
+ function validateBuild(value, type, label) {
237
+ if (!plain(value))
238
+ return `${label} is required and must be a JSON object`;
239
+ const keys = Object.keys(value);
240
+ if (keys.length === 0)
241
+ return {};
242
+ const unknown = exactKeys(value, buildKeys, label);
243
+ if (unknown)
244
+ return unknown;
245
+ if (keys.length !== buildKeys.size || !Object.hasOwn(value, 'entry') || !Object.hasOwn(value, 'args') || !Object.hasOwn(value, 'artifacts')) {
246
+ return `${label} must be {} or contain exactly entry, args and artifacts`;
247
+ }
248
+ const entry = normalizedRelative(value.entry);
249
+ if (entry === undefined || (typeof value.entry === 'string' && containsBuildVariable(value.entry)))
250
+ return `${label}.entry must be a project-relative POSIX path without variables`;
251
+ if (!Array.isArray(value.args) || value.args.some((arg) => typeof arg !== 'string'))
252
+ return `${label}.args must be an array of strings`;
253
+ for (let i = 0; i < value.args.length; i += 1) {
254
+ const problem = validateBuildArg(value.args[i], `${label}.args[${i}]`);
255
+ if (problem)
256
+ return problem;
257
+ }
258
+ if (!Array.isArray(value.artifacts) || value.artifacts.length === 0)
259
+ return `${label}.artifacts must be a non-empty array`;
260
+ const artifacts = [];
261
+ const ids = new Set();
262
+ for (let i = 0; i < value.artifacts.length; i += 1) {
263
+ const artifact = value.artifacts[i];
264
+ const where = `${label}.artifacts[${i}]`;
265
+ if (!plain(artifact))
266
+ return `${where} must be an object`;
267
+ const extra = exactKeys(artifact, artifactKeys, where);
268
+ if (extra)
269
+ return extra;
270
+ if (Object.keys(artifact).length !== artifactKeys.size)
271
+ return `${where} must contain exactly id, kind and path`;
272
+ if (typeof artifact.id !== 'string' || !/^[a-z][a-z0-9._-]{0,63}$/.test(artifact.id))
273
+ return `${where}.id must match ^[a-z][a-z0-9._-]{0,63}$`;
274
+ if (ids.has(artifact.id))
275
+ return `${where}.id duplicates artifact id ${artifact.id}`;
276
+ ids.add(artifact.id);
277
+ if (artifact.kind !== 'file' && artifact.kind !== 'directory' && artifact.kind !== 'docker-image-archive')
278
+ return `${where}.kind must be file, directory or docker-image-archive`;
279
+ const artifactPath = normalizedRelative(artifact.path);
280
+ if (artifactPath === undefined || (typeof artifact.path === 'string' && containsBuildVariable(artifact.path)))
281
+ return `${where}.path must be a project-relative POSIX path without variables`;
282
+ artifacts.push({ id: artifact.id, kind: artifact.kind, path: artifactPath });
283
+ }
284
+ if (type === 'site' && !artifacts.some((artifact) => artifact.id === 'site-dist' && artifact.kind === 'directory'))
285
+ return `${label} for a site must declare site-dist as a directory`;
286
+ if (type === 'service' && !artifacts.some((artifact) => artifact.id === 'service-image' && artifact.kind === 'docker-image-archive'))
287
+ return `${label} for a service must declare service-image as a docker-image-archive`;
288
+ return { entry, args: [...value.args], artifacts };
289
+ }
248
290
  function canonicalConfigJson(document) { return (0, appConfig_1.serializeAppConfig)(document); }
249
- function canonicalConfigDigest(document) { return crypto.createHash('sha256').update(canonicalConfigJson(document), 'utf8').digest('hex'); }
291
+ function canonicalConfigDigest(document) {
292
+ return crypto.createHash('sha256').update(canonicalConfigJson(document), 'utf8').digest('hex');
293
+ }
250
294
  function parseSuperConfig(raw, filePath) {
251
295
  const duplicate = (0, appConfig_1.findDuplicateKey)(raw);
252
296
  if (duplicate)
@@ -263,20 +307,17 @@ function parseSuperConfig(raw, filePath) {
263
307
  const rootUnknown = exactKeys(document, rootKeys, 'root');
264
308
  if (rootUnknown)
265
309
  return fail(filePath, rootUnknown);
266
- if (document.schemaVersion !== 4)
267
- return fail(filePath, 'schemaVersion must be the number 4');
310
+ if (document.schemaVersion !== appConfig_1.APP_CONFIG_SCHEMA_VERSION)
311
+ return fail(filePath, 'only schemaVersion 5 is supported; update super.json manually');
268
312
  if (typeof document.spid !== 'string' || !/^[a-z0-9]{8}$/.test(document.spid))
269
313
  return fail(filePath, 'spid must be 8 lowercase letters or digits');
270
314
  if (document.orgId !== undefined && (typeof document.orgId !== 'string' || !/^[1-9][0-9]*$/.test(document.orgId)))
271
315
  return fail(filePath, 'orgId must be a positive decimal string');
272
- if (document.name !== undefined && (!string(document.name) || document.name !== document.name.trim() || document.name.length > 100))
316
+ if (document.name !== undefined && (!nonEmptyString(document.name) || document.name !== document.name.trim() || document.name.length > 100))
273
317
  return fail(filePath, 'name must be 1..100 characters without surrounding whitespace');
274
318
  const rootVersion = validateVersion(document.version, 'version', false);
275
319
  if (rootVersion)
276
320
  return fail(filePath, rootVersion);
277
- const rootSdk = validateSdk(document.sdk, 'sdk');
278
- if (rootSdk)
279
- return fail(filePath, rootSdk);
280
321
  if (!Array.isArray(document.projects))
281
322
  return fail(filePath, 'projects must be an array');
282
323
  const projects = [];
@@ -291,8 +332,7 @@ function parseSuperConfig(raw, filePath) {
291
332
  const type = item.type;
292
333
  if (type !== 'android' && type !== 'ios' && type !== 'site' && type !== 'service')
293
334
  return fail(filePath, `${label}.type must be android, ios, site or service`);
294
- const allowed = new Set([...commonProjectKeys, ...typeProjectKeys[type]]);
295
- const unknown = exactKeys(item, allowed, label);
335
+ const unknown = exactKeys(item, new Set([...commonProjectKeys, ...typeProjectKeys[type]]), label);
296
336
  if (unknown)
297
337
  return fail(filePath, unknown);
298
338
  if (!validProjectId(item.projectId))
@@ -300,7 +340,7 @@ function parseSuperConfig(raw, filePath) {
300
340
  if (ids.has(item.projectId))
301
341
  return fail(filePath, `duplicate projectId ${item.projectId}`);
302
342
  ids.add(item.projectId);
303
- if (typeof item.dir !== 'string' || !normalizeProjectDir(item.dir))
343
+ if (typeof item.dir !== 'string' || normalizeProjectDir(item.dir) === undefined)
304
344
  return fail(filePath, `${label}.dir must be a workspace-relative POSIX path`);
305
345
  const dir = normalizeProjectDir(item.dir);
306
346
  if (dirs.some((existing) => existing === dir || isAncestor(existing, dir) || isAncestor(dir, existing)))
@@ -309,26 +349,29 @@ function parseSuperConfig(raw, filePath) {
309
349
  const version = validateVersion(item.version, `${label}.version`, item.version !== undefined);
310
350
  if (version)
311
351
  return fail(filePath, version);
312
- const sdk = validateSdk(item.sdk, `${label}.sdk`);
313
- if (sdk)
314
- return fail(filePath, sdk);
315
- if (item.name !== undefined && (!string(item.name) || item.name !== item.name.trim() || item.name.length > (type === 'site' || type === 'service' ? 50 : 100)))
352
+ if (item.name !== undefined && (!nonEmptyString(item.name) || item.name !== item.name.trim() || item.name.length > (type === 'site' || type === 'service' ? 50 : 100)))
316
353
  return fail(filePath, `${label}.name must be 1..${type === 'site' || type === 'service' ? 50 : 100} characters without surrounding whitespace`);
317
- if ((type === 'android' || type === 'ios') && (!string(item.name) || item.name !== item.name.trim() || /[\x00-\x1f]/.test(item.name)))
354
+ if ((type === 'android' || type === 'ios') && (!nonEmptyString(item.name) || item.name !== item.name.trim() || /[\x00-\x1f]/.test(item.name)))
318
355
  return fail(filePath, `${label}.name is required for ${type}`);
319
- if (type === 'android' && (!string(item.package) || !/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$/.test(item.package) || item.package === 'com.supersdk.simple'))
356
+ if (type === 'android' && (!nonEmptyString(item.package) || !/^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$/.test(item.package) || item.package === 'com.supersdk.simple'))
320
357
  return fail(filePath, `${label}.package is required for android`);
321
- if (type === 'ios' && (!string(item.bundleId) || !/^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/.test(item.bundleId)))
358
+ if (type === 'ios' && (!nonEmptyString(item.bundleId) || !/^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/.test(item.bundleId)))
322
359
  return fail(filePath, `${label}.bundleId is required for ios`);
323
360
  if (type === 'ios' && item.spmMode !== undefined && item.spmMode !== 'mock' && item.spmMode !== 'real')
324
361
  return fail(filePath, `${label}.spmMode must be mock or real`);
325
- const effectiveSdk = item.sdk !== undefined ? item.sdk : document.sdk;
326
- const projectSdk = validateProjectSdk(type, item.spmMode, plain(effectiveSdk) ? effectiveSdk : {}, label);
327
- if (projectSdk)
328
- return fail(filePath, projectSdk);
329
- const site = type === 'site' ? validateSite(item, label) : type === 'service' ? validateService(item, label) : undefined;
330
- if (site)
331
- return fail(filePath, site);
362
+ const build = validateBuild(item.build, type, `${label}.build`);
363
+ if (typeof build === 'string')
364
+ return fail(filePath, build);
365
+ if (type === 'site') {
366
+ const offline = item.offline === undefined ? {} : item.offline;
367
+ if (!plain(offline))
368
+ return fail(filePath, `${label}.offline must be a JSON object`);
369
+ const unknownOffline = exactKeys(offline, new Set(['host']), `${label}.offline`);
370
+ if (unknownOffline)
371
+ return fail(filePath, unknownOffline);
372
+ if (offline.host !== undefined && !validOfflineHost(offline.host))
373
+ return fail(filePath, `${label}.offline.host must be a deployable domain or HTTP(S) URL`);
374
+ }
332
375
  const deploy = validateDeploy(item.deploy, type, `${label}.deploy`);
333
376
  if (typeof deploy === 'string')
334
377
  return fail(filePath, deploy);
@@ -338,92 +381,77 @@ function parseSuperConfig(raw, filePath) {
338
381
  return fail(filePath, `duplicate deploy target ${key}`);
339
382
  targets.add(key);
340
383
  }
341
- projects.push({ ...item, projectId: item.projectId, type, dir, ...(item.deploy !== undefined ? { deploy } : {}) });
384
+ projects.push({ ...item, projectId: item.projectId, type, dir, build, ...(item.deploy !== undefined ? { deploy } : {}) });
342
385
  }
343
386
  const resolved = path.resolve(filePath);
344
- return { kind: 'valid', config: { path: resolved, root: path.dirname(resolved), document, schemaVersion: 4, spid: document.spid, ...(typeof document.orgId === 'string' ? { orgId: document.orgId } : {}), ...(typeof document.name === 'string' ? { name: document.name } : {}), projects, digest: canonicalConfigDigest(document) } };
387
+ return {
388
+ kind: 'valid',
389
+ config: {
390
+ path: resolved,
391
+ root: path.dirname(resolved),
392
+ document,
393
+ schemaVersion: appConfig_1.APP_CONFIG_SCHEMA_VERSION,
394
+ spid: document.spid,
395
+ ...(typeof document.orgId === 'string' ? { orgId: document.orgId } : {}),
396
+ ...(typeof document.name === 'string' ? { name: document.name } : {}),
397
+ projects,
398
+ digest: canonicalConfigDigest(document),
399
+ },
400
+ };
345
401
  }
346
- function read(pathname) { try {
347
- return parseSuperConfig(fs.readFileSync(pathname, 'utf8'), pathname);
402
+ function read(pathname) {
403
+ try {
404
+ return parseSuperConfig(fs.readFileSync(pathname, 'utf8'), pathname);
405
+ }
406
+ catch (error) {
407
+ return fail(pathname, `cannot read config: ${error.message}`);
408
+ }
348
409
  }
349
- catch (error) {
350
- return fail(pathname, `cannot read config: ${error.message}`);
351
- } }
352
- function boundary(current) { return fs.existsSync(path.join(current, '.git')) || current === path.parse(current).root || current === path.resolve(process.env.HOME ?? '~'); }
353
- function legacyAt(root) { return appConfig_1.LEGACY_APP_CONFIG_FILENAMES.map((name) => path.join(root, name)).filter((candidate) => fs.existsSync(candidate)); }
354
- function scan(startDir) { let current = path.resolve(startDir); const dirs = []; const candidates = []; const legacy = []; for (let level = 0; level < MAX_SEARCH_DEPTH; level += 1) {
355
- dirs.push(current);
356
- const candidate = path.join(current, exports.CONFIG_FILENAME);
357
- if (fs.existsSync(candidate))
358
- candidates.push(candidate);
359
- legacy.push(...legacyAt(current));
360
- if (boundary(current))
361
- break;
362
- const parent = path.dirname(current);
363
- if (parent === current)
364
- break;
365
- current = parent;
366
- } return { dirs, candidates, legacy }; }
367
- function isWithin(root, candidate) {
368
- const relative = path.relative(path.resolve(root), path.resolve(candidate));
369
- return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
410
+ function boundary(current) {
411
+ return fs.existsSync(path.join(current, '.git')) || current === path.parse(current).root || current === path.resolve(process.env.HOME ?? '~');
370
412
  }
371
- /** Scan an explicit selection's cwd chain, but never import authority from another workspace. */
372
- function scanToRoot(startDir, root) {
373
- const selectedRoot = path.resolve(root);
413
+ function scan(startDir) {
374
414
  let current = path.resolve(startDir);
375
- if (!isWithin(selectedRoot, current))
376
- return { dirs: [], candidates: [], legacy: [] };
377
415
  const dirs = [];
378
416
  const candidates = [];
379
- const legacy = [];
380
417
  for (let level = 0; level < MAX_SEARCH_DEPTH; level += 1) {
381
418
  dirs.push(current);
382
419
  const candidate = path.join(current, exports.CONFIG_FILENAME);
383
420
  if (fs.existsSync(candidate))
384
421
  candidates.push(candidate);
385
- legacy.push(...legacyAt(current));
386
- if (current === selectedRoot)
422
+ if (boundary(current))
387
423
  break;
388
424
  const parent = path.dirname(current);
389
- if (parent === current || !isWithin(selectedRoot, parent))
425
+ if (parent === current)
390
426
  break;
391
427
  current = parent;
392
428
  }
393
- return { dirs, candidates, legacy };
429
+ return { dirs, candidates };
394
430
  }
395
431
  function findSuperConfig(startDir, explicitPath) {
396
432
  if (explicitPath !== undefined) {
397
433
  const selected = path.resolve(explicitPath);
398
434
  if (!fs.existsSync(selected))
399
435
  return { kind: 'absent', searched: [selected], explicit: true };
400
- // The selected file defines the workspace root. An unrelated cwd is only
401
- // a process-launch detail and must never contribute config/legacy state.
402
- // When cwd is inside the selected workspace, scan cwd -> selected root so
403
- // nested authorities still fail closed. A same-directory alternate and
404
- // super.json may coexist because --config chose the alternate explicitly.
405
- const selectedRoot = path.dirname(selected);
406
- const selectedChain = scanToRoot(startDir, selectedRoot);
407
- const conflicts = [...new Set(selectedChain.candidates)]
408
- .filter((candidate) => candidate !== selected && path.dirname(candidate) !== selectedRoot);
409
- if (conflicts.length)
410
- return { kind: 'ambiguous', paths: [selected, ...conflicts] };
411
- const rootLegacy = legacyAt(selectedRoot);
412
- const legacy = [...new Set([...rootLegacy, ...selectedChain.legacy])];
413
- if (legacy.length)
414
- return fail(selected, `${legacy[0]} coexists on the discovery chain; migrate/remove the retired configuration`);
415
436
  return read(selected);
416
437
  }
417
438
  const scanned = scan(startDir);
418
- if (scanned.legacy.length)
419
- return fail(scanned.legacy[0], `retired configuration found; migrate with \`supercli config migrate --from ${scanned.legacy[0]} --to ${path.join(path.dirname(scanned.legacy[0]), exports.CONFIG_FILENAME)}\``);
420
439
  if (scanned.candidates.length !== 1)
421
- return scanned.candidates.length ? { kind: 'ambiguous', paths: scanned.candidates } : { kind: 'absent', searched: scanned.dirs, explicit: false };
440
+ return scanned.candidates.length
441
+ ? { kind: 'ambiguous', paths: scanned.candidates }
442
+ : { kind: 'absent', searched: scanned.dirs, explicit: false };
422
443
  return read(scanned.candidates[0]);
423
444
  }
424
445
  exports.resolveSuperConfig = findSuperConfig;
425
- function configProblem(result) { if (result.kind === 'valid')
426
- return undefined; if (result.kind === 'absent')
427
- return result.explicit ? `explicit config not found: ${result.searched[0]}` : `no ${exports.CONFIG_FILENAME} found; run interactive \`supercli init\` to create one`; if (result.kind === 'ambiguous')
428
- return `CONFIG_AMBIGUOUS: multiple ${exports.CONFIG_FILENAME} candidates found: ${result.paths.join(', ')}`; return `CONFIG_INVALID: ${result.path}: ${result.reason}`; }
446
+ function configProblem(result) {
447
+ if (result.kind === 'valid')
448
+ return undefined;
449
+ if (result.kind === 'absent')
450
+ return result.explicit
451
+ ? `explicit config not found: ${result.searched[0]}`
452
+ : `no ${exports.CONFIG_FILENAME} found; run interactive \`supercli init\` to create one`;
453
+ if (result.kind === 'ambiguous')
454
+ return `CONFIG_AMBIGUOUS: multiple ${exports.CONFIG_FILENAME} candidates found: ${result.paths.join(', ')}`;
455
+ return `CONFIG_INVALID: ${result.path}: ${result.reason}`;
456
+ }
429
457
  //# sourceMappingURL=superConfig.js.map