@nimiplatform/app-tools 0.16.0-rc.12 → 0.16.0-rc.14
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 -3
- package/bin/nimi-app.mjs +12 -5
- package/lib/app-dependency-combinations.mjs +1 -0
- package/lib/app-doctor-update.mjs +19 -6
- package/lib/app-pack.mjs +1238 -155
- package/lib/app-project-lifecycle.mjs +41 -5
- package/lib/app-scaffold-capabilities.mjs +28 -0
- package/lib/app-scaffold-profiles.mjs +169 -42
- package/lib/app-scaffold.mjs +289 -15
- package/lib/desktop-window.mjs +106 -0
- package/lib/hosted-web-release.mjs +31 -5
- package/lib/index.mjs +4 -3
- package/lib/payload-links.mjs +96 -18
- package/package.json +5 -5
- package/scripts/dev-shell.mjs +13 -1
- package/templates/default-starter/README.md +14 -6
package/lib/index.mjs
CHANGED
|
@@ -133,6 +133,7 @@ export function createApp(cwd, options = {}) {
|
|
|
133
133
|
dir: options.dir,
|
|
134
134
|
profile: options.profile,
|
|
135
135
|
platform: options.platform,
|
|
136
|
+
carrier: options.carrier,
|
|
136
137
|
appId: options.appId,
|
|
137
138
|
name: options.name,
|
|
138
139
|
title: options.title,
|
|
@@ -220,12 +221,12 @@ export function buildApp(cwd, options = {}) {
|
|
|
220
221
|
return buildAppProject(cwd, options, appToolRunners());
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
export function packApp(cwd, options = {}) {
|
|
224
|
+
export async function packApp(cwd, options = {}) {
|
|
224
225
|
const manifest = parseYaml(readFileSync(path.join(path.resolve(cwd, options.dir || '.'), 'nimi.app.yaml'), 'utf8'));
|
|
225
226
|
if (manifest.platform === 'web') throw new Error('Web pack is not implemented; use the App-owned website build and deployment process.');
|
|
226
227
|
return options.aggregate
|
|
227
|
-
? aggregateAppTargetCandidates(cwd, options)
|
|
228
|
-
: packAppTarget(cwd, options);
|
|
228
|
+
? await aggregateAppTargetCandidates(cwd, options)
|
|
229
|
+
: await packAppTarget(cwd, options);
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.scaffold-web-carrier
|
package/lib/payload-links.mjs
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-014a
|
|
2
|
+
import { isUtf8 } from 'node:buffer';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
|
|
4
5
|
export const SYMBOLIC_LINK_MODE = 0o120777;
|
|
6
|
+
export const MAX_SYMLINK_HOPS = 32;
|
|
7
|
+
export const MAX_SYMLINK_TARGET_BYTES = 4096;
|
|
8
|
+
|
|
9
|
+
const UTF8_DECODER = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
10
|
+
|
|
11
|
+
function decodeStrictUtf8Target(bytes, entryName) {
|
|
12
|
+
if (!Buffer.isBuffer(bytes) || bytes.length === 0 || bytes.length > MAX_SYMLINK_TARGET_BYTES || !isUtf8(bytes)) {
|
|
13
|
+
throw new Error(`Invalid payload symbolic link: ${entryName}`);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return UTF8_DECODER.decode(bytes);
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error(`Invalid payload symbolic link: ${entryName}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
5
21
|
|
|
6
22
|
// Electron frameworks contain relative links such as Versions/Current -> A.
|
|
7
|
-
// Resolve against the archive tree
|
|
23
|
+
// Resolve component-by-component against the archive tree (matching XNU
|
|
24
|
+
// MAXSYMLINKS = 32), never collapsing `..` before expanding intermediate links.
|
|
8
25
|
export function validatePayloadLinks(entries, os) {
|
|
9
26
|
const directories = new Set();
|
|
10
27
|
for (const name of entries.keys()) {
|
|
@@ -15,27 +32,88 @@ export function validatePayloadLinks(entries, os) {
|
|
|
15
32
|
for (const name of directories) {
|
|
16
33
|
if (entries.has(name)) throw new Error(`nimiapp file/directory collision: ${name}`);
|
|
17
34
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
|
|
36
|
+
const resolveComponents = (base, rawTarget, entryName, state, active) => {
|
|
37
|
+
if (!rawTarget || rawTarget.startsWith('/') || rawTarget.includes('\\') || rawTarget.includes('\0')) {
|
|
38
|
+
throw new Error(`Invalid payload symbolic link: ${entryName}`);
|
|
39
|
+
}
|
|
40
|
+
let cur = [...base];
|
|
41
|
+
let trailingDir = rawTarget.endsWith('/');
|
|
42
|
+
const parts = rawTarget.split('/');
|
|
43
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
44
|
+
const part = parts[i];
|
|
45
|
+
const isLast = i === parts.length - 1;
|
|
46
|
+
if (part === '') {
|
|
47
|
+
if (!directories.has(cur.join('/'))) {
|
|
48
|
+
throw new Error(`Payload symbolic link traverses non-directory: ${entryName}`);
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (part === '.') {
|
|
53
|
+
if (!directories.has(cur.join('/'))) {
|
|
54
|
+
throw new Error(`Payload symbolic link traverses non-directory: ${entryName}`);
|
|
55
|
+
}
|
|
56
|
+
if (isLast) trailingDir = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (part === '..') {
|
|
60
|
+
if (!directories.has(cur.join('/'))) {
|
|
61
|
+
throw new Error(`Payload symbolic link traverses non-directory: ${entryName}`);
|
|
62
|
+
}
|
|
63
|
+
if (cur.length <= 1) {
|
|
64
|
+
throw new Error(`Payload symbolic link escapes its root: ${entryName}`);
|
|
65
|
+
}
|
|
66
|
+
cur.pop();
|
|
67
|
+
if (isLast) trailingDir = true;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!directories.has(cur.join('/'))) {
|
|
71
|
+
throw new Error(`Payload symbolic link traverses non-directory: ${entryName}`);
|
|
72
|
+
}
|
|
73
|
+
cur.push(part);
|
|
74
|
+
const joined = cur.join('/');
|
|
75
|
+
const nextEntry = entries.get(joined);
|
|
76
|
+
if (nextEntry?.mode === SYMBOLIC_LINK_MODE) {
|
|
77
|
+
if (active.has(joined)) {
|
|
78
|
+
throw new Error(`Cyclic payload symbolic link: ${joined}`);
|
|
79
|
+
}
|
|
80
|
+
state.hops += 1;
|
|
81
|
+
if (state.hops > MAX_SYMLINK_HOPS) {
|
|
82
|
+
throw new Error(`Excessive payload symbolic link hops: ${joined}`);
|
|
83
|
+
}
|
|
84
|
+
active.add(joined);
|
|
85
|
+
const target = decodeStrictUtf8Target(nextEntry.bytes, joined);
|
|
86
|
+
const expanded = resolveComponents(cur.slice(0, -1), target, joined, state, active);
|
|
87
|
+
active.delete(joined);
|
|
88
|
+
cur = expanded.resolved;
|
|
89
|
+
if (isLast && expanded.trailingDir) {
|
|
90
|
+
trailingDir = true;
|
|
91
|
+
}
|
|
28
92
|
}
|
|
29
|
-
const destination = path.posix.normalize(path.posix.join(path.posix.dirname(prefix), target, ...parts.slice(length)));
|
|
30
|
-
if (!destination.startsWith('payload/')) throw new Error(`Payload symbolic link escapes its root: ${prefix}`);
|
|
31
|
-
return resolve(destination, new Set([...visited, prefix]));
|
|
32
93
|
}
|
|
33
|
-
|
|
34
|
-
return name;
|
|
94
|
+
return { resolved: cur, trailingDir };
|
|
35
95
|
};
|
|
96
|
+
|
|
36
97
|
for (const [name, entry] of entries) {
|
|
37
98
|
if (entry.mode !== SYMBOLIC_LINK_MODE) continue;
|
|
38
|
-
if (os !== 'macos' || !name.startsWith('payload/'))
|
|
39
|
-
|
|
99
|
+
if (os !== 'macos' || !name.startsWith('payload/')) {
|
|
100
|
+
throw new Error(`Symbolic link is not admitted for this target: ${name}`);
|
|
101
|
+
}
|
|
102
|
+
const target = decodeStrictUtf8Target(entry.bytes, name);
|
|
103
|
+
const parentParts = path.posix.dirname(name).split('/');
|
|
104
|
+
const state = { hops: 1 };
|
|
105
|
+
const active = new Set([name]);
|
|
106
|
+
const { resolved, trailingDir } = resolveComponents(parentParts, target, name, state, active);
|
|
107
|
+
if (resolved.length < 2 || resolved[0] !== 'payload') {
|
|
108
|
+
throw new Error(`Payload symbolic link escapes its root: ${name}`);
|
|
109
|
+
}
|
|
110
|
+
const finalPath = resolved.join('/');
|
|
111
|
+
if (trailingDir) {
|
|
112
|
+
if (!directories.has(finalPath)) {
|
|
113
|
+
throw new Error(`Missing payload symbolic link destination: ${finalPath}`);
|
|
114
|
+
}
|
|
115
|
+
} else if (!entries.has(finalPath) && !directories.has(finalPath)) {
|
|
116
|
+
throw new Error(`Missing payload symbolic link destination: ${finalPath}`);
|
|
117
|
+
}
|
|
40
118
|
}
|
|
41
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.16.0-rc.
|
|
3
|
+
"version": "0.16.0-rc.14",
|
|
4
4
|
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"provenance": true
|
|
19
19
|
},
|
|
20
20
|
"nimiScaffoldVersions": {
|
|
21
|
-
"sdkVersion": "^0.24.0-rc.
|
|
22
|
-
"appToolsVersion": "^0.16.0-rc.
|
|
21
|
+
"sdkVersion": "^0.24.0-rc.11",
|
|
22
|
+
"appToolsVersion": "^0.16.0-rc.14",
|
|
23
23
|
"nimicodingVersion": "0.7.0",
|
|
24
24
|
"aiSdkVersion": "^7.0.171",
|
|
25
|
-
"kitVersion": "^0.24.0-rc.
|
|
25
|
+
"kitVersion": "^0.24.0-rc.18",
|
|
26
26
|
"reactVersion": "^19.3.1",
|
|
27
27
|
"reactDomVersion": "^19.3.1",
|
|
28
28
|
"i18nextVersion": "^26.7.2",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"prepublishOnly": "pnpm run build",
|
|
69
69
|
"test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
|
|
70
70
|
"test:large-archive": "node --test test/app-pack-large.test.mjs",
|
|
71
|
-
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-icons.test.mjs test/app-storefront.test.mjs test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-pack-large.test.mjs test/app-scaffold.test.mjs test/web-carrier.test.mjs test/hosted-web-release.test.mjs test/mobile-development.test.mjs"
|
|
71
|
+
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-icons.test.mjs test/app-storefront.test.mjs test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-pack-deflate.test.mjs test/app-pack-large.test.mjs test/app-scaffold.test.mjs test/managed-web-carrier.test.mjs test/web-carrier.test.mjs test/hosted-web-release.test.mjs test/mobile-development.test.mjs"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
74
|
"bin",
|
package/scripts/dev-shell.mjs
CHANGED
|
@@ -46,7 +46,9 @@ export async function runDevShell(cwd, options = {}) {
|
|
|
46
46
|
if (typeof fetchImpl !== 'function') {
|
|
47
47
|
throw new DevShellError('local-development-launcher-unavailable', 'This Node.js runtime does not provide fetch.');
|
|
48
48
|
}
|
|
49
|
-
if (!options.listRegistrations
|
|
49
|
+
if (!options.listRegistrations && !(await isManagedWebProject(projectRoot))) {
|
|
50
|
+
await assertProjectElectronRuntime(projectRoot);
|
|
51
|
+
}
|
|
50
52
|
let registrationSelector = options.resume;
|
|
51
53
|
if (options.listRegistrations || (!options.resume && !options.newRegistration)) {
|
|
52
54
|
const listed = await postJson(fetchImpl, descriptor, '/v1/registrations', {
|
|
@@ -207,6 +209,16 @@ export async function assertProjectElectronRuntime(projectRoot, platform = proce
|
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
export async function isManagedWebProject(projectRoot) {
|
|
213
|
+
try {
|
|
214
|
+
const raw = await readFile(path.join(projectRoot, '.nimi', 'config', 'build-profile.yaml'), 'utf8');
|
|
215
|
+
const parsed = parseYaml(raw);
|
|
216
|
+
return parsed?.build_profile_ref === 'managed-web-pnpm-vite';
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
210
222
|
export class DevShellError extends Error {
|
|
211
223
|
constructor(reasonCode, message) {
|
|
212
224
|
super(message);
|
|
@@ -24,18 +24,23 @@ pnpm install
|
|
|
24
24
|
pnpm run init
|
|
25
25
|
pnpm run sync
|
|
26
26
|
pnpm run check
|
|
27
|
-
pnpm run
|
|
28
|
-
pnpm run app:build -- --target windows-x86_64
|
|
27
|
+
pnpm run app:build
|
|
29
28
|
pnpm dev
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
### Local Development
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
Open Nimi Home, sign in and enable Developer Mode before running `pnpm dev`. Add an App test under `test/*.test.mjs` and run it with `pnpm test`.
|
|
35
34
|
|
|
36
35
|
### Building & Carrier Layout
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
<!-- carrier: managed-web -->
|
|
38
|
+
This App builds static frontend files into `dist/renderer/`. Nimi Home runs them in its managed desktop carrier on Windows x64 and macOS arm64. Both platforms use the same package.
|
|
39
|
+
|
|
40
|
+
Set the summary, PNG icon and release notes in `nimi.app.yaml` and the license identifier in `package.json`. Run `pnpm exec nimi-app pack --target desktop-universal` after building. The resulting `.nimiapp` is in `dist/nimi-app/`.
|
|
41
|
+
<!-- end carrier -->
|
|
42
|
+
<!-- carrier: native -->
|
|
43
|
+
The `windows-x86_64` build outputs a fresh non-installer Electron directory at `dist-electron-package/acme-widget-shell-win32-x64/`, containing:
|
|
39
44
|
|
|
40
45
|
- The App-specific executable `acme-widget-shell.exe`
|
|
41
46
|
- ASAR-packaged JavaScript and renderer assets
|
|
@@ -45,11 +50,14 @@ The production bundle rejects `--nimi-dev-renderer-url`. The protected native bi
|
|
|
45
50
|
|
|
46
51
|
Electron packages target Windows x64 and macOS arm64. Standard builds use Node, pnpm and the prebuilt native Kit package for the target.
|
|
47
52
|
|
|
53
|
+
Run `pnpm exec nimi-app pack --target windows-x86_64` on Windows or `pnpm exec nimi-app pack --target macos-aarch64` on macOS after building. Publishers may sign the Windows executable before packing. Production packing records the observed Authenticode signature or an explicit unsigned posture.
|
|
54
|
+
<!-- end carrier -->
|
|
55
|
+
|
|
48
56
|
### Packaging & Release Boundaries
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
Pushing a protected version tag triggers the managed GitHub Release workflow. Submit the resulting immutable Release through the Registry pull-request and human-review flow.
|
|
51
59
|
|
|
52
|
-
Before cutting a production release,
|
|
60
|
+
Before cutting a production release, enable a protected `v*` tag ruleset and immutable releases in the public GitHub repository, and provide a read-only repository-admin token to verify those settings. Manual workflow dispatch runs a development build.
|
|
53
61
|
|
|
54
62
|
A GitHub Release remains independent from registry admission, Runtime installation, Desktop launch, and Nimi Access. Runtime, Realm, registry admission, installed state, and process truth remain with their canonical owners. This repository stores no Runtime credentials or protected session material.
|
|
55
63
|
|