@nimiplatform/app-tools 0.1.0
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/LICENSE +9 -0
- package/README.md +44 -0
- package/bin/nimi-app.mjs +112 -0
- package/lib/app-doctor-update.mjs +472 -0
- package/lib/app-scaffold.mjs +959 -0
- package/lib/index.mjs +93 -0
- package/package.json +25 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_APP_ID = 'my-nimi-app';
|
|
5
|
+
const DEFAULT_APP_TITLE = 'My Nimi App';
|
|
6
|
+
export const SCAFFOLD_VERSION = '2026-05-24.wave-4-remediation-b';
|
|
7
|
+
export const SCAFFOLD_LOCK_PATH = '.nimi/scaffold.lock.json';
|
|
8
|
+
export const SUPPORTED_APP_SCAFFOLD_PROFILES = ['standalone', 'workspace-app'];
|
|
9
|
+
const SCAFFOLD_LICENSE_YEAR = '2026';
|
|
10
|
+
const LOCKFILE_POLICY = 'author-install-generates-lockfile';
|
|
11
|
+
const MINIMAL_TAURI_ICON_PNG = Buffer.from(
|
|
12
|
+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=',
|
|
13
|
+
'base64',
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
function jsonFile(value) {
|
|
17
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function slugify(input) {
|
|
21
|
+
const normalized = String(input || DEFAULT_APP_ID)
|
|
22
|
+
.trim()
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
25
|
+
.replace(/^-+|-+$/g, '');
|
|
26
|
+
return normalized || DEFAULT_APP_ID;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function normalizeExplicitAppId(input) {
|
|
30
|
+
const normalized = String(input || '')
|
|
31
|
+
.trim()
|
|
32
|
+
.toLowerCase();
|
|
33
|
+
if (!/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/.test(normalized)) {
|
|
34
|
+
throw new Error(`Invalid app id: ${input}`);
|
|
35
|
+
}
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function resolveAppId(options) {
|
|
40
|
+
if (String(options.appId || '').trim()) {
|
|
41
|
+
return normalizeExplicitAppId(options.appId);
|
|
42
|
+
}
|
|
43
|
+
return slugify(options.name || DEFAULT_APP_ID);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function packageSafeName(input) {
|
|
47
|
+
const normalized = String(input || DEFAULT_APP_ID)
|
|
48
|
+
.trim()
|
|
49
|
+
.toLowerCase()
|
|
50
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
51
|
+
.replace(/^-+|-+$/g, '');
|
|
52
|
+
return normalized || DEFAULT_APP_ID;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function validateNpmPackageSegment(segment) {
|
|
56
|
+
return /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/.test(segment);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function normalizeExplicitPackageName(input) {
|
|
60
|
+
const normalized = String(input || '').trim();
|
|
61
|
+
if (!normalized || normalized.length > 214 || /\s/.test(normalized)) {
|
|
62
|
+
throw new Error(`Invalid npm package name: ${input}`);
|
|
63
|
+
}
|
|
64
|
+
if (normalized.startsWith('@')) {
|
|
65
|
+
const scopedMatch = normalized.match(/^@([^/]+)\/(.+)$/);
|
|
66
|
+
if (!scopedMatch || !validateNpmPackageSegment(scopedMatch[1]) || !validateNpmPackageSegment(scopedMatch[2])) {
|
|
67
|
+
throw new Error(`Invalid npm package name: ${input}`);
|
|
68
|
+
}
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
if (!validateNpmPackageSegment(normalized)) {
|
|
72
|
+
throw new Error(`Invalid npm package name: ${input}`);
|
|
73
|
+
}
|
|
74
|
+
return normalized;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function resolvePackageName(options, appId) {
|
|
78
|
+
if (String(options.packageName || '').trim()) {
|
|
79
|
+
return normalizeExplicitPackageName(options.packageName);
|
|
80
|
+
}
|
|
81
|
+
return packageSafeName(appId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function cargoSafeNameFromPackageName(input) {
|
|
85
|
+
const normalized = String(input || DEFAULT_APP_ID)
|
|
86
|
+
.trim()
|
|
87
|
+
.toLowerCase()
|
|
88
|
+
.replace(/^@/, '')
|
|
89
|
+
.replace(/\//g, '-')
|
|
90
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
91
|
+
.replace(/^-+|-+$/g, '');
|
|
92
|
+
return normalized || DEFAULT_APP_ID;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function tauriIdentifierFromAppId(appId) {
|
|
96
|
+
const suffix = String(appId || DEFAULT_APP_ID)
|
|
97
|
+
.toLowerCase()
|
|
98
|
+
.replace(/[^a-z0-9]+/g, '.')
|
|
99
|
+
.replace(/^\.+|\.+$/g, '')
|
|
100
|
+
.replace(/\.+/g, '.');
|
|
101
|
+
return `ai.nimi.apps.${suffix || DEFAULT_APP_ID.replace(/-/g, '.')}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function buildAppIdentity(profile, appId, appTitle, packageName, author = '') {
|
|
105
|
+
const resolvedPackageName = packageName || packageSafeName(appId);
|
|
106
|
+
return {
|
|
107
|
+
appId,
|
|
108
|
+
appTitle,
|
|
109
|
+
profile,
|
|
110
|
+
packageName: resolvedPackageName,
|
|
111
|
+
cargoPackageName: `${cargoSafeNameFromPackageName(resolvedPackageName)}-shell`,
|
|
112
|
+
tauriIdentifier: tauriIdentifierFromAppId(appId),
|
|
113
|
+
author: String(author || '').trim(),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function resolveProfile(options) {
|
|
118
|
+
const profile = String(options.profile || '').trim() || 'standalone';
|
|
119
|
+
if (!SUPPORTED_APP_SCAFFOLD_PROFILES.includes(profile)) {
|
|
120
|
+
throw new Error(`Unsupported app scaffold profile: ${profile}`);
|
|
121
|
+
}
|
|
122
|
+
return profile;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function buildPackageJson(profile, versions, identity) {
|
|
126
|
+
const packageJson = {
|
|
127
|
+
name: identity.packageName,
|
|
128
|
+
private: true,
|
|
129
|
+
type: 'module',
|
|
130
|
+
scripts: {
|
|
131
|
+
dev: 'vite',
|
|
132
|
+
build: 'tsc --noEmit && vite build',
|
|
133
|
+
test: 'node --test test/*.test.mjs',
|
|
134
|
+
check: 'pnpm run doctor && pnpm run test && pnpm run validate',
|
|
135
|
+
pack: 'node scripts/pack.mjs',
|
|
136
|
+
validate: 'node scripts/validate.mjs',
|
|
137
|
+
'local-audit': 'node scripts/local-audit.mjs',
|
|
138
|
+
doctor: 'nimi-app doctor',
|
|
139
|
+
update: 'nimi-app update',
|
|
140
|
+
},
|
|
141
|
+
dependencies: {
|
|
142
|
+
'@nimiplatform/sdk': profile === 'workspace-app' ? 'workspace:*' : versions.sdkVersion,
|
|
143
|
+
'@nimiplatform/kit': profile === 'workspace-app' ? 'workspace:*' : versions.kitVersion,
|
|
144
|
+
'@tauri-apps/api': versions.tauriApiVersion,
|
|
145
|
+
react: versions.reactVersion,
|
|
146
|
+
'react-dom': versions.reactDomVersion,
|
|
147
|
+
},
|
|
148
|
+
devDependencies: {
|
|
149
|
+
'@nimiplatform/app-tools': profile === 'workspace-app' ? 'workspace:*' : versions.appToolsVersion,
|
|
150
|
+
'@types/node': versions.nodeTypesVersion,
|
|
151
|
+
'@types/react': versions.reactTypesVersion,
|
|
152
|
+
'@types/react-dom': versions.reactDomTypesVersion,
|
|
153
|
+
'@vitejs/plugin-react': versions.viteReactPluginVersion,
|
|
154
|
+
typescript: versions.typescriptVersion,
|
|
155
|
+
vite: versions.viteVersion,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
if (identity.author) {
|
|
159
|
+
packageJson.author = identity.author;
|
|
160
|
+
}
|
|
161
|
+
return packageJson;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function buildRendererFiles(identity) {
|
|
165
|
+
return [
|
|
166
|
+
{
|
|
167
|
+
path: 'src/main.tsx',
|
|
168
|
+
content: [
|
|
169
|
+
"import React from 'react';",
|
|
170
|
+
"import { createRoot } from 'react-dom/client';",
|
|
171
|
+
"import { NimiThemeProvider } from '@nimiplatform/kit/ui';",
|
|
172
|
+
"import '@nimiplatform/kit/ui/styles.css';",
|
|
173
|
+
"import './styles.css';",
|
|
174
|
+
"import { App } from './shell/App.js';",
|
|
175
|
+
'',
|
|
176
|
+
"createRoot(document.getElementById('root') as HTMLElement).render(",
|
|
177
|
+
' <React.StrictMode>',
|
|
178
|
+
' <NimiThemeProvider accentPack="nimi-accent">',
|
|
179
|
+
' <App />',
|
|
180
|
+
' </NimiThemeProvider>',
|
|
181
|
+
' </React.StrictMode>,',
|
|
182
|
+
');',
|
|
183
|
+
'',
|
|
184
|
+
].join('\n'),
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
path: 'src/shell/App.tsx',
|
|
188
|
+
content: [
|
|
189
|
+
"import { RuntimeGate } from './auth/runtime-gate.js';",
|
|
190
|
+
"import { AuthGate } from './auth/auth-gate.js';",
|
|
191
|
+
"import { ProductArea } from './routes/product-area.js';",
|
|
192
|
+
"import { SettingsRoute } from './routes/settings.js';",
|
|
193
|
+
"import { DemoSurfaces } from './routes/demo-surfaces.js';",
|
|
194
|
+
'',
|
|
195
|
+
'export function App() {',
|
|
196
|
+
' return (',
|
|
197
|
+
' <RuntimeGate>',
|
|
198
|
+
' <AuthGate>',
|
|
199
|
+
' <main className="app-shell">',
|
|
200
|
+
' <ProductArea />',
|
|
201
|
+
' <aside className="side-panel">',
|
|
202
|
+
' <SettingsRoute />',
|
|
203
|
+
' <DemoSurfaces />',
|
|
204
|
+
' </aside>',
|
|
205
|
+
' </main>',
|
|
206
|
+
' </AuthGate>',
|
|
207
|
+
' </RuntimeGate>',
|
|
208
|
+
' );',
|
|
209
|
+
'}',
|
|
210
|
+
'',
|
|
211
|
+
].join('\n'),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
path: 'src/shell/auth/runtime-platform.ts',
|
|
215
|
+
content: [
|
|
216
|
+
"import { createNimiAppRuntimePlatformClient, type NimiAppAuthProjection } from '@nimiplatform/sdk';",
|
|
217
|
+
'',
|
|
218
|
+
`export const appId = '${identity.appId}';`,
|
|
219
|
+
`export const scaffoldProfile = '${identity.profile}' as const;`,
|
|
220
|
+
'',
|
|
221
|
+
'let runtimeProjection: Promise<NimiAppAuthProjection> | null = null;',
|
|
222
|
+
'',
|
|
223
|
+
'export function getRuntimePlatformProjection() {',
|
|
224
|
+
' runtimeProjection ??= createNimiAppRuntimePlatformClient({',
|
|
225
|
+
" mode: 'third-party-nimi-app',",
|
|
226
|
+
' appId,',
|
|
227
|
+
' });',
|
|
228
|
+
' return runtimeProjection;',
|
|
229
|
+
'}',
|
|
230
|
+
'',
|
|
231
|
+
].join('\n'),
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
path: 'src/shell/auth/auth-gate.tsx',
|
|
235
|
+
content: [
|
|
236
|
+
"import { useEffect, useState, type ReactNode } from 'react';",
|
|
237
|
+
"import type { NimiAppAuthProjection } from '@nimiplatform/sdk';",
|
|
238
|
+
"import { InlineAlert, StatusBadge } from '@nimiplatform/kit/ui';",
|
|
239
|
+
"import { getRuntimePlatformProjection } from './runtime-platform.js';",
|
|
240
|
+
'',
|
|
241
|
+
'export function AuthGate({ children }: { children: ReactNode }) {',
|
|
242
|
+
" const [projection, setProjection] = useState<NimiAppAuthProjection | null>(null);",
|
|
243
|
+
' useEffect(() => {',
|
|
244
|
+
' let active = true;',
|
|
245
|
+
' void getRuntimePlatformProjection().then((nextProjection) => {',
|
|
246
|
+
' if (active) setProjection(nextProjection);',
|
|
247
|
+
' });',
|
|
248
|
+
' return () => {',
|
|
249
|
+
' active = false;',
|
|
250
|
+
' };',
|
|
251
|
+
' }, []);',
|
|
252
|
+
'',
|
|
253
|
+
' if (!projection) {',
|
|
254
|
+
" return <div className=\"gate-panel\"><StatusBadge tone=\"neutral\">Runtime check</StatusBadge></div>;",
|
|
255
|
+
' }',
|
|
256
|
+
'',
|
|
257
|
+
" if (projection.status !== 'ready') {",
|
|
258
|
+
' return (',
|
|
259
|
+
' <div className="gate-panel">',
|
|
260
|
+
' <InlineAlert tone="warning">',
|
|
261
|
+
' <strong>Runtime action required</strong>',
|
|
262
|
+
' <span>{projection.message}</span>',
|
|
263
|
+
' </InlineAlert>',
|
|
264
|
+
' </div>',
|
|
265
|
+
' );',
|
|
266
|
+
' }',
|
|
267
|
+
'',
|
|
268
|
+
' return <>{children}</>;',
|
|
269
|
+
'}',
|
|
270
|
+
'',
|
|
271
|
+
].join('\n'),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
path: 'src/shell/auth/runtime-gate.tsx',
|
|
275
|
+
content: [
|
|
276
|
+
"import type { ReactNode } from 'react';",
|
|
277
|
+
"import { StatusBadge } from '@nimiplatform/kit/ui';",
|
|
278
|
+
'',
|
|
279
|
+
'export function RuntimeGate({ children }: { children: ReactNode }) {',
|
|
280
|
+
' return (',
|
|
281
|
+
' <section className="runtime-frame" aria-label="Runtime readiness gate">',
|
|
282
|
+
' <header className="runtime-frame__header">',
|
|
283
|
+
` <strong>${identity.appTitle}</strong>`,
|
|
284
|
+
' <StatusBadge tone="neutral">pre-submission self-check</StatusBadge>',
|
|
285
|
+
' </header>',
|
|
286
|
+
' {children}',
|
|
287
|
+
' </section>',
|
|
288
|
+
' );',
|
|
289
|
+
'}',
|
|
290
|
+
'',
|
|
291
|
+
].join('\n'),
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
path: 'src/shell/routes/product-area.tsx',
|
|
295
|
+
content: [
|
|
296
|
+
"import { Button, Surface } from '@nimiplatform/kit/ui';",
|
|
297
|
+
'',
|
|
298
|
+
'export function ProductArea() {',
|
|
299
|
+
' return (',
|
|
300
|
+
' <Surface className="product-area">',
|
|
301
|
+
' <p className="eyebrow">app-owned product route</p>',
|
|
302
|
+
` <h1>${identity.appTitle}</h1>`,
|
|
303
|
+
' <p>Replace this route with app product behavior while keeping auth, Runtime, and permission boundaries in scaffold-managed glue.</p>',
|
|
304
|
+
' <Button type="button">Open product action</Button>',
|
|
305
|
+
' </Surface>',
|
|
306
|
+
' );',
|
|
307
|
+
'}',
|
|
308
|
+
'',
|
|
309
|
+
].join('\n'),
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
path: 'src/shell/routes/settings.tsx',
|
|
313
|
+
content: [
|
|
314
|
+
"import { Surface, Toggle } from '@nimiplatform/kit/ui';",
|
|
315
|
+
'',
|
|
316
|
+
'export function SettingsRoute() {',
|
|
317
|
+
' return (',
|
|
318
|
+
' <Surface className="panel-section">',
|
|
319
|
+
' <h2>Settings</h2>',
|
|
320
|
+
' <label className="setting-row">',
|
|
321
|
+
' <span>Use local draft data</span>',
|
|
322
|
+
' <Toggle checked={false} onChange={() => {}} />',
|
|
323
|
+
' </label>',
|
|
324
|
+
' </Surface>',
|
|
325
|
+
' );',
|
|
326
|
+
'}',
|
|
327
|
+
'',
|
|
328
|
+
].join('\n'),
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
path: 'src/shell/routes/demo-surfaces.tsx',
|
|
332
|
+
content: [
|
|
333
|
+
"import { EmptyState, Surface } from '@nimiplatform/kit/ui';",
|
|
334
|
+
'',
|
|
335
|
+
'export function DemoSurfaces() {',
|
|
336
|
+
' return (',
|
|
337
|
+
' <Surface className="panel-section">',
|
|
338
|
+
' <h2>Demo</h2>',
|
|
339
|
+
' <EmptyState title="Add app-owned surfaces" description="Use reviewed SDK and kit imports only." />',
|
|
340
|
+
' </Surface>',
|
|
341
|
+
' );',
|
|
342
|
+
'}',
|
|
343
|
+
'',
|
|
344
|
+
].join('\n'),
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
path: 'src/styles.css',
|
|
348
|
+
content: [
|
|
349
|
+
':root {',
|
|
350
|
+
' color-scheme: light;',
|
|
351
|
+
' font-family: Inter, ui-sans-serif, system-ui, sans-serif;',
|
|
352
|
+
'}',
|
|
353
|
+
'',
|
|
354
|
+
'body {',
|
|
355
|
+
' margin: 0;',
|
|
356
|
+
' background: #f6f7f9;',
|
|
357
|
+
' color: #20242c;',
|
|
358
|
+
'}',
|
|
359
|
+
'',
|
|
360
|
+
'.runtime-frame {',
|
|
361
|
+
' min-height: 100vh;',
|
|
362
|
+
' padding: 24px;',
|
|
363
|
+
'}',
|
|
364
|
+
'',
|
|
365
|
+
'.runtime-frame__header, .app-shell {',
|
|
366
|
+
' display: grid;',
|
|
367
|
+
' gap: 16px;',
|
|
368
|
+
'}',
|
|
369
|
+
'',
|
|
370
|
+
'.runtime-frame__header {',
|
|
371
|
+
' grid: auto / 1fr auto;',
|
|
372
|
+
' align-items: center;',
|
|
373
|
+
' margin-bottom: 16px;',
|
|
374
|
+
'}',
|
|
375
|
+
'',
|
|
376
|
+
'.app-shell {',
|
|
377
|
+
' grid: auto / minmax(0, 1fr) minmax(280px, 360px);',
|
|
378
|
+
'}',
|
|
379
|
+
'',
|
|
380
|
+
'.product-area, .panel-section, .gate-panel {',
|
|
381
|
+
' padding: 20px;',
|
|
382
|
+
'}',
|
|
383
|
+
'',
|
|
384
|
+
'.side-panel {',
|
|
385
|
+
' display: grid;',
|
|
386
|
+
' align-content: start;',
|
|
387
|
+
' gap: 16px;',
|
|
388
|
+
'}',
|
|
389
|
+
'',
|
|
390
|
+
'.eyebrow {',
|
|
391
|
+
' margin: 0 0 8px;',
|
|
392
|
+
' color: #5b6472;',
|
|
393
|
+
' font-size: 12px;',
|
|
394
|
+
' text-transform: uppercase;',
|
|
395
|
+
'}',
|
|
396
|
+
'',
|
|
397
|
+
'.setting-row {',
|
|
398
|
+
' display: flex;',
|
|
399
|
+
' align-items: center;',
|
|
400
|
+
' justify-content: space-between;',
|
|
401
|
+
' gap: 12px;',
|
|
402
|
+
'}',
|
|
403
|
+
'',
|
|
404
|
+
'@media (max-width: 820px) {',
|
|
405
|
+
' .app-shell, .runtime-frame__header {',
|
|
406
|
+
' grid: auto / 1fr;',
|
|
407
|
+
' }',
|
|
408
|
+
'}',
|
|
409
|
+
'',
|
|
410
|
+
].join('\n'),
|
|
411
|
+
},
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function buildCommonFiles(identity, versions) {
|
|
416
|
+
return [
|
|
417
|
+
{
|
|
418
|
+
path: 'package.json',
|
|
419
|
+
content: jsonFile(buildPackageJson(identity.profile, versions, identity)),
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
path: 'tsconfig.json',
|
|
423
|
+
content: jsonFile({
|
|
424
|
+
compilerOptions: {
|
|
425
|
+
target: 'ES2022',
|
|
426
|
+
module: 'ESNext',
|
|
427
|
+
moduleResolution: 'Bundler',
|
|
428
|
+
jsx: 'react-jsx',
|
|
429
|
+
strict: true,
|
|
430
|
+
skipLibCheck: true,
|
|
431
|
+
noEmit: true,
|
|
432
|
+
types: ['node'],
|
|
433
|
+
},
|
|
434
|
+
include: ['src/**/*.ts', 'src/**/*.tsx', 'test/**/*.mjs'],
|
|
435
|
+
}),
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
path: 'index.html',
|
|
439
|
+
content: [
|
|
440
|
+
'<!doctype html>',
|
|
441
|
+
'<html lang="en">',
|
|
442
|
+
' <head>',
|
|
443
|
+
' <meta charset="UTF-8" />',
|
|
444
|
+
' <meta name="viewport" content="width=device-width, initial-scale=1.0" />',
|
|
445
|
+
` <title>${identity.appTitle}</title>`,
|
|
446
|
+
' </head>',
|
|
447
|
+
' <body>',
|
|
448
|
+
' <div id="root"></div>',
|
|
449
|
+
' <script type="module" src="/src/main.tsx"></script>',
|
|
450
|
+
' </body>',
|
|
451
|
+
'</html>',
|
|
452
|
+
'',
|
|
453
|
+
].join('\n'),
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
path: 'vite.config.ts',
|
|
457
|
+
content: [
|
|
458
|
+
"import { defineConfig } from 'vite';",
|
|
459
|
+
"import react from '@vitejs/plugin-react';",
|
|
460
|
+
'',
|
|
461
|
+
'export default defineConfig({',
|
|
462
|
+
' plugins: [react()],',
|
|
463
|
+
'});',
|
|
464
|
+
'',
|
|
465
|
+
].join('\n'),
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
path: 'nimi.app.yaml',
|
|
469
|
+
content: [
|
|
470
|
+
`app_id: ${identity.appId}`,
|
|
471
|
+
`display_name: ${identity.appTitle}`,
|
|
472
|
+
`profile: ${identity.profile}`,
|
|
473
|
+
'manifest_role: submitted-input',
|
|
474
|
+
'permissions:',
|
|
475
|
+
' declared_nimi_api_scopes:',
|
|
476
|
+
' - scope: app.local.drafts',
|
|
477
|
+
' qualifier: app-local-drafts',
|
|
478
|
+
' purpose: Store drafts owned by this app during author testing.',
|
|
479
|
+
'',
|
|
480
|
+
].join('\n'),
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
path: '.nimi/config/app-identity.yaml',
|
|
484
|
+
content: [
|
|
485
|
+
`app_id: ${identity.appId}`,
|
|
486
|
+
`display_name: ${identity.appTitle}`,
|
|
487
|
+
`npm_package_name: ${identity.packageName}`,
|
|
488
|
+
`cargo_package_name: ${identity.cargoPackageName}`,
|
|
489
|
+
`tauri_identifier: ${identity.tauriIdentifier}`,
|
|
490
|
+
...(identity.author ? [`package_author: ${identity.author}`] : []),
|
|
491
|
+
'identity_role: scaffold-generated-authoring-input',
|
|
492
|
+
'',
|
|
493
|
+
].join('\n'),
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
path: '.nimi/config/build-profile.yaml',
|
|
497
|
+
content: [
|
|
498
|
+
'build_profile_ref: tauri-pnpm-vite',
|
|
499
|
+
'toolchain_version: node>=20;pnpm>=9;rust>=1.80;tauri=2',
|
|
500
|
+
'build_command: pnpm run build',
|
|
501
|
+
'output_path: src-tauri/target/release',
|
|
502
|
+
'lockfile_path: pnpm-lock.yaml',
|
|
503
|
+
`lockfile_policy: ${LOCKFILE_POLICY}`,
|
|
504
|
+
'ci_install_command: pnpm install --no-frozen-lockfile',
|
|
505
|
+
'profile_role: developer-workflow-input',
|
|
506
|
+
'',
|
|
507
|
+
].join('\n'),
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
path: '.nimi/contracts/scaffold-boundary.yaml',
|
|
511
|
+
content: [
|
|
512
|
+
'scaffold_contract: P-SCAF',
|
|
513
|
+
`profile: ${identity.profile}`,
|
|
514
|
+
'public_admission_truth: not-generated',
|
|
515
|
+
'local_audit_role: pre-submission-self-check',
|
|
516
|
+
'permission_declarations: transparency-input-only',
|
|
517
|
+
'',
|
|
518
|
+
].join('\n'),
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
path: '.nimi/methodology/scaffold-managed-files.yaml',
|
|
522
|
+
content: [
|
|
523
|
+
'mutation_classes:',
|
|
524
|
+
' package_owned_projection:',
|
|
525
|
+
' - .nimi/config/**',
|
|
526
|
+
' - .nimi/contracts/**',
|
|
527
|
+
' - .nimi/methodology/**',
|
|
528
|
+
' scaffold_managed_glue:',
|
|
529
|
+
' - .github/**',
|
|
530
|
+
' - .gitignore',
|
|
531
|
+
' - package.json',
|
|
532
|
+
' - README.md',
|
|
533
|
+
' - SECURITY.md',
|
|
534
|
+
' - nimi.app.yaml',
|
|
535
|
+
' - src/shell/auth/**',
|
|
536
|
+
' - src-tauri/**',
|
|
537
|
+
' - scripts/**',
|
|
538
|
+
' app_owned_product_code:',
|
|
539
|
+
' - src/shell/routes/product-area.tsx',
|
|
540
|
+
'',
|
|
541
|
+
].join('\n'),
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
path: 'AGENTS.md',
|
|
545
|
+
content: [
|
|
546
|
+
'# AGENTS.md',
|
|
547
|
+
'- Treat `.nimi/**` as host-local scaffold truth for this generated app.',
|
|
548
|
+
'- Keep auth, Runtime, permission, manifest, and Tauri shell glue in scaffold-managed files.',
|
|
549
|
+
'- Product behavior belongs under `src/shell/routes/product-area.tsx` unless a later scaffold update expands the app-owned area.',
|
|
550
|
+
'- Local checks are pre-submission self-checks only.',
|
|
551
|
+
'',
|
|
552
|
+
].join('\n'),
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
path: '.gitignore',
|
|
556
|
+
content: [
|
|
557
|
+
'node_modules/',
|
|
558
|
+
'dist/',
|
|
559
|
+
'src-tauri/target/',
|
|
560
|
+
'.turbo/',
|
|
561
|
+
'.vite/',
|
|
562
|
+
'.DS_Store',
|
|
563
|
+
'',
|
|
564
|
+
].join('\n'),
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
path: 'README.md',
|
|
568
|
+
content: [
|
|
569
|
+
`# ${identity.appTitle}`,
|
|
570
|
+
'',
|
|
571
|
+
`Profile: \`${identity.profile}\``,
|
|
572
|
+
'',
|
|
573
|
+
'This repository is a Nimi App authoring scaffold. `nimi.app.yaml`, the build profile, permission declarations, pack output, validate output, and local audit output are submitted inputs and pre-submission self-checks only.',
|
|
574
|
+
'',
|
|
575
|
+
'## Development',
|
|
576
|
+
'',
|
|
577
|
+
'```bash',
|
|
578
|
+
'pnpm install',
|
|
579
|
+
'pnpm run dev',
|
|
580
|
+
'pnpm run validate',
|
|
581
|
+
'pnpm run local-audit',
|
|
582
|
+
'pnpm run pack',
|
|
583
|
+
'pnpm run doctor',
|
|
584
|
+
'pnpm run update',
|
|
585
|
+
'```',
|
|
586
|
+
'',
|
|
587
|
+
'`doctor` and `update` are developer scaffold checks for this source repository. They do not update an installed app, publish admission truth, create release descriptors, or grant permissions.',
|
|
588
|
+
'',
|
|
589
|
+
'Upstream Platform/Runtime review produces release descriptors, ordinary visibility, install truth, and scope authorization. This scaffold does not mint those outcomes.',
|
|
590
|
+
'',
|
|
591
|
+
].join('\n'),
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
path: 'LICENSE',
|
|
595
|
+
content: [
|
|
596
|
+
'MIT License',
|
|
597
|
+
'',
|
|
598
|
+
`Copyright (c) ${SCAFFOLD_LICENSE_YEAR} ${identity.appTitle}`,
|
|
599
|
+
'',
|
|
600
|
+
'Permission is hereby granted, free of charge, to any person obtaining a copy',
|
|
601
|
+
'of this software and associated documentation files to deal in the Software',
|
|
602
|
+
'without restriction, including without limitation the rights to use, copy,',
|
|
603
|
+
'modify, merge, publish, distribute, sublicense, and/or sell copies of the',
|
|
604
|
+
'Software, and to permit persons to whom the Software is furnished to do so.',
|
|
605
|
+
'',
|
|
606
|
+
].join('\n'),
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
path: 'SECURITY.md',
|
|
610
|
+
content: [
|
|
611
|
+
'# Security',
|
|
612
|
+
'',
|
|
613
|
+
'- Do not store Realm credentials or app-owned bearer credentials in this repository.',
|
|
614
|
+
'- Use `createNimiAppRuntimePlatformClient` for Runtime platform projection.',
|
|
615
|
+
'- Treat permission declarations as review transparency, not grants.',
|
|
616
|
+
'',
|
|
617
|
+
].join('\n'),
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
path: 'scripts/validate.mjs',
|
|
621
|
+
content: [
|
|
622
|
+
"import { readFileSync } from 'node:fs';",
|
|
623
|
+
'',
|
|
624
|
+
"const manifest = readFileSync(new URL('../nimi.app.yaml', import.meta.url), 'utf8');",
|
|
625
|
+
"if (!manifest.includes('manifest_role: submitted-input')) {",
|
|
626
|
+
" throw new Error('submitted manifest role marker missing');",
|
|
627
|
+
'}',
|
|
628
|
+
"console.log('[nimi-app] validate pre-submission self-check passed');",
|
|
629
|
+
'',
|
|
630
|
+
].join('\n'),
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
path: 'scripts/local-audit.mjs',
|
|
634
|
+
content: [
|
|
635
|
+
"import { readFileSync } from 'node:fs';",
|
|
636
|
+
'',
|
|
637
|
+
"const boundary = readFileSync(new URL('../.nimi/contracts/scaffold-boundary.yaml', import.meta.url), 'utf8');",
|
|
638
|
+
"if (!boundary.includes('local_audit_role: pre-submission-self-check')) {",
|
|
639
|
+
" throw new Error('local audit role marker missing');",
|
|
640
|
+
'}',
|
|
641
|
+
"console.log('[nimi-app] local-audit pre-submission self-check passed');",
|
|
642
|
+
'',
|
|
643
|
+
].join('\n'),
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
path: 'scripts/pack.mjs',
|
|
647
|
+
content: [
|
|
648
|
+
"import { mkdirSync, writeFileSync } from 'node:fs';",
|
|
649
|
+
"import { join } from 'node:path';",
|
|
650
|
+
'',
|
|
651
|
+
"mkdirSync('dist', { recursive: true });",
|
|
652
|
+
"writeFileSync(join('dist', 'pre-submission-pack.txt'), 'pre-submission self-check artifact\\n');",
|
|
653
|
+
"console.log('[nimi-app] pack pre-submission self-check wrote dist/pre-submission-pack.txt');",
|
|
654
|
+
'',
|
|
655
|
+
].join('\n'),
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
path: 'test/scaffold-boundary.test.mjs',
|
|
659
|
+
content: [
|
|
660
|
+
"import assert from 'node:assert/strict';",
|
|
661
|
+
"import { readFileSync } from 'node:fs';",
|
|
662
|
+
"import test from 'node:test';",
|
|
663
|
+
'',
|
|
664
|
+
"const authSource = readFileSync(new URL('../src/shell/auth/runtime-platform.ts', import.meta.url), 'utf8');",
|
|
665
|
+
"const manifest = readFileSync(new URL('../nimi.app.yaml', import.meta.url), 'utf8');",
|
|
666
|
+
'',
|
|
667
|
+
"test('auth glue uses Nimi App runtime platform helper', () => {",
|
|
668
|
+
" assert.match(authSource, /createNimiAppRuntimePlatformClient/);",
|
|
669
|
+
" assert.doesNotMatch(authSource, /createPlatformClient\\s*\\(/);",
|
|
670
|
+
"});",
|
|
671
|
+
'',
|
|
672
|
+
"test('manifest remains submitted input', () => {",
|
|
673
|
+
" assert.match(manifest, /manifest_role: submitted-input/);",
|
|
674
|
+
" assert.match(manifest, /declared_nimi_api_scopes/);",
|
|
675
|
+
"});",
|
|
676
|
+
'',
|
|
677
|
+
].join('\n'),
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
path: '.github/workflows/ci.yml',
|
|
681
|
+
content: [
|
|
682
|
+
'name: pre-submission-self-check',
|
|
683
|
+
'on:',
|
|
684
|
+
' pull_request:',
|
|
685
|
+
' push:',
|
|
686
|
+
'jobs:',
|
|
687
|
+
' check:',
|
|
688
|
+
' runs-on: ubuntu-latest',
|
|
689
|
+
' steps:',
|
|
690
|
+
' - uses: actions/checkout@v4',
|
|
691
|
+
' - uses: pnpm/action-setup@v4',
|
|
692
|
+
' with:',
|
|
693
|
+
' version: 9',
|
|
694
|
+
' - uses: actions/setup-node@v4',
|
|
695
|
+
' with:',
|
|
696
|
+
' node-version: 22',
|
|
697
|
+
' - run: pnpm install --no-frozen-lockfile',
|
|
698
|
+
' - run: pnpm run check',
|
|
699
|
+
'',
|
|
700
|
+
].join('\n'),
|
|
701
|
+
},
|
|
702
|
+
];
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function buildTauriFiles(identity, versions) {
|
|
706
|
+
const shellDependency = identity.profile === 'workspace-app'
|
|
707
|
+
? '{ path = "../../../kit/shell/tauri" }'
|
|
708
|
+
: `"${versions.nimiShellTauriVersion}"`;
|
|
709
|
+
return [
|
|
710
|
+
{
|
|
711
|
+
path: 'src-tauri/Cargo.toml',
|
|
712
|
+
content: [
|
|
713
|
+
'[package]',
|
|
714
|
+
`name = "${identity.cargoPackageName}"`,
|
|
715
|
+
'version = "0.1.0"',
|
|
716
|
+
'edition = "2021"',
|
|
717
|
+
'',
|
|
718
|
+
'[dependencies]',
|
|
719
|
+
'tauri = "2"',
|
|
720
|
+
`nimi-shell-tauri = ${shellDependency}`,
|
|
721
|
+
'',
|
|
722
|
+
'[build-dependencies]',
|
|
723
|
+
'tauri-build = { version = "2", features = [] }',
|
|
724
|
+
'',
|
|
725
|
+
].join('\n'),
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
path: 'src-tauri/build.rs',
|
|
729
|
+
content: [
|
|
730
|
+
'fn main() {',
|
|
731
|
+
' tauri_build::build();',
|
|
732
|
+
'}',
|
|
733
|
+
'',
|
|
734
|
+
].join('\n'),
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
path: 'src-tauri/tauri.conf.json',
|
|
738
|
+
content: jsonFile({
|
|
739
|
+
productName: identity.appTitle,
|
|
740
|
+
version: '0.1.0',
|
|
741
|
+
identifier: identity.tauriIdentifier,
|
|
742
|
+
build: {
|
|
743
|
+
beforeDevCommand: 'pnpm run dev',
|
|
744
|
+
beforeBuildCommand: 'pnpm run build',
|
|
745
|
+
devUrl: 'http://localhost:1420',
|
|
746
|
+
frontendDist: '../dist',
|
|
747
|
+
},
|
|
748
|
+
app: {
|
|
749
|
+
windows: [
|
|
750
|
+
{
|
|
751
|
+
title: identity.appTitle,
|
|
752
|
+
width: 1120,
|
|
753
|
+
height: 760,
|
|
754
|
+
},
|
|
755
|
+
],
|
|
756
|
+
},
|
|
757
|
+
bundle: {
|
|
758
|
+
icon: ['icons/icon.png'],
|
|
759
|
+
},
|
|
760
|
+
}),
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
path: 'src-tauri/icons/icon.png',
|
|
764
|
+
content: MINIMAL_TAURI_ICON_PNG,
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
path: 'src-tauri/src/main.rs',
|
|
768
|
+
content: [
|
|
769
|
+
'fn main() {',
|
|
770
|
+
' tauri::Builder::default()',
|
|
771
|
+
' .invoke_handler(nimi_shell_tauri::nimi_shell_tauri_runtime_bridge_handler![])',
|
|
772
|
+
' .run(tauri::generate_context!())',
|
|
773
|
+
' .expect("failed to run Nimi App shell");',
|
|
774
|
+
'}',
|
|
775
|
+
'',
|
|
776
|
+
].join('\n'),
|
|
777
|
+
},
|
|
778
|
+
];
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function buildWorkspaceAppFiles(identity) {
|
|
782
|
+
return [
|
|
783
|
+
{
|
|
784
|
+
path: `apps/${identity.packageName}/spec/app-slice.md`,
|
|
785
|
+
content: [
|
|
786
|
+
`# ${identity.appId} App Slice`,
|
|
787
|
+
'',
|
|
788
|
+
'Workspace-app profile input under P-APP authority. This app-slice file is not public Nimi App admission and does not create ordinary-user visibility.',
|
|
789
|
+
'',
|
|
790
|
+
].join('\n'),
|
|
791
|
+
},
|
|
792
|
+
];
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function buildScaffoldFiles(identity, versions) {
|
|
796
|
+
return [
|
|
797
|
+
...buildCommonFiles(identity, versions),
|
|
798
|
+
...buildRendererFiles(identity),
|
|
799
|
+
...buildTauriFiles(identity, versions),
|
|
800
|
+
...(identity.profile === 'workspace-app' ? buildWorkspaceAppFiles(identity) : []),
|
|
801
|
+
];
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function normalizePathList(paths) {
|
|
805
|
+
return [...paths].sort((left, right) => left.localeCompare(right));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function classifyScaffoldFile(filePath) {
|
|
809
|
+
if (filePath === 'src/shell/routes/product-area.tsx') {
|
|
810
|
+
return 'app-owned product code';
|
|
811
|
+
}
|
|
812
|
+
if (
|
|
813
|
+
filePath.startsWith('.nimi/config/')
|
|
814
|
+
|| filePath.startsWith('.nimi/contracts/')
|
|
815
|
+
|| filePath.startsWith('.nimi/methodology/')
|
|
816
|
+
|| /^apps\/[^/]+\/spec\//.test(filePath)
|
|
817
|
+
) {
|
|
818
|
+
return 'package-owned projection';
|
|
819
|
+
}
|
|
820
|
+
return 'scaffold-managed glue';
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export function hashScaffoldContent(content) {
|
|
824
|
+
return createHash('sha256').update(content).digest('hex');
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function buildDependencyMatrix(profile, versions) {
|
|
828
|
+
return {
|
|
829
|
+
npm: {
|
|
830
|
+
'@nimiplatform/app-tools': profile === 'workspace-app' ? 'workspace:*' : versions.appToolsVersion,
|
|
831
|
+
'@nimiplatform/sdk': profile === 'workspace-app' ? 'workspace:*' : versions.sdkVersion,
|
|
832
|
+
'@nimiplatform/kit': profile === 'workspace-app' ? 'workspace:*' : versions.kitVersion,
|
|
833
|
+
'@tauri-apps/api': versions.tauriApiVersion,
|
|
834
|
+
react: versions.reactVersion,
|
|
835
|
+
'react-dom': versions.reactDomVersion,
|
|
836
|
+
typescript: versions.typescriptVersion,
|
|
837
|
+
vite: versions.viteVersion,
|
|
838
|
+
'@vitejs/plugin-react': versions.viteReactPluginVersion,
|
|
839
|
+
},
|
|
840
|
+
cargo: {
|
|
841
|
+
'nimi-shell-tauri': profile === 'workspace-app'
|
|
842
|
+
? { path: '../../../kit/shell/tauri' }
|
|
843
|
+
: versions.nimiShellTauriVersion,
|
|
844
|
+
tauri: '2',
|
|
845
|
+
'tauri-build': '2',
|
|
846
|
+
},
|
|
847
|
+
toolchain: {
|
|
848
|
+
node: '>=20',
|
|
849
|
+
pnpm: '>=9',
|
|
850
|
+
rust: '>=1.80',
|
|
851
|
+
tauri: '2',
|
|
852
|
+
},
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function buildScaffoldLock(identity, versions, files) {
|
|
857
|
+
const taxonomy = {
|
|
858
|
+
'package-owned projection': [],
|
|
859
|
+
'scaffold-managed glue': [],
|
|
860
|
+
'app-owned product code': [],
|
|
861
|
+
};
|
|
862
|
+
const managedFileHashes = {};
|
|
863
|
+
const appOwnedInitialHashes = {};
|
|
864
|
+
|
|
865
|
+
for (const file of files) {
|
|
866
|
+
const mutationClass = classifyScaffoldFile(file.path);
|
|
867
|
+
taxonomy[mutationClass].push(file.path);
|
|
868
|
+
const digest = hashScaffoldContent(file.content);
|
|
869
|
+
if (mutationClass === 'app-owned product code') {
|
|
870
|
+
appOwnedInitialHashes[file.path] = {
|
|
871
|
+
class: mutationClass,
|
|
872
|
+
sha256: digest,
|
|
873
|
+
};
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
managedFileHashes[file.path] = {
|
|
877
|
+
class: mutationClass,
|
|
878
|
+
sha256: digest,
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return {
|
|
883
|
+
lockVersion: 1,
|
|
884
|
+
scaffoldVersion: SCAFFOLD_VERSION,
|
|
885
|
+
profile: identity.profile,
|
|
886
|
+
appId: identity.appId,
|
|
887
|
+
appTitle: identity.appTitle,
|
|
888
|
+
packageName: identity.packageName,
|
|
889
|
+
packageAuthor: identity.author || null,
|
|
890
|
+
cargoPackageName: identity.cargoPackageName,
|
|
891
|
+
tauriIdentifier: identity.tauriIdentifier,
|
|
892
|
+
appIdentity: {
|
|
893
|
+
appId: identity.appId,
|
|
894
|
+
appTitle: identity.appTitle,
|
|
895
|
+
npmPackageName: identity.packageName,
|
|
896
|
+
packageAuthor: identity.author || null,
|
|
897
|
+
cargoPackageName: identity.cargoPackageName,
|
|
898
|
+
tauriIdentifier: identity.tauriIdentifier,
|
|
899
|
+
identityRole: 'scaffold-generated-authoring-input',
|
|
900
|
+
},
|
|
901
|
+
managedFileTaxonomy: {
|
|
902
|
+
packageOwnedProjection: normalizePathList(taxonomy['package-owned projection']),
|
|
903
|
+
scaffoldManagedGlue: normalizePathList(taxonomy['scaffold-managed glue']),
|
|
904
|
+
appOwnedProductCode: normalizePathList(taxonomy['app-owned product code']),
|
|
905
|
+
},
|
|
906
|
+
managedFileHashes,
|
|
907
|
+
appOwnedInitialHashes,
|
|
908
|
+
dependencyMatrix: buildDependencyMatrix(identity.profile, versions),
|
|
909
|
+
semantics: {
|
|
910
|
+
doctorAndUpdateRole: 'developer-scaffold-check-only',
|
|
911
|
+
publicAdmissionTruth: 'not-generated',
|
|
912
|
+
installedAppUpdateTruth: 'not-generated',
|
|
913
|
+
permissionGrantTruth: 'not-generated',
|
|
914
|
+
lockfilePolicy: LOCKFILE_POLICY,
|
|
915
|
+
ignoredVerificationArtifacts: ['dist/'],
|
|
916
|
+
},
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
export function buildAppScaffoldSnapshot({ profile, versions, appId, appTitle, packageName, author }) {
|
|
921
|
+
const identity = buildAppIdentity(profile, appId, appTitle, packageName, author);
|
|
922
|
+
const files = buildScaffoldFiles(identity, versions);
|
|
923
|
+
const lock = buildScaffoldLock(identity, versions, files);
|
|
924
|
+
const allFiles = [
|
|
925
|
+
...files,
|
|
926
|
+
{
|
|
927
|
+
path: SCAFFOLD_LOCK_PATH,
|
|
928
|
+
content: jsonFile(lock),
|
|
929
|
+
},
|
|
930
|
+
];
|
|
931
|
+
return {
|
|
932
|
+
appId: identity.appId,
|
|
933
|
+
appTitle: identity.appTitle,
|
|
934
|
+
profile: identity.profile,
|
|
935
|
+
packageName: identity.packageName,
|
|
936
|
+
packageAuthor: identity.author || null,
|
|
937
|
+
cargoPackageName: identity.cargoPackageName,
|
|
938
|
+
tauriIdentifier: identity.tauriIdentifier,
|
|
939
|
+
files: allFiles,
|
|
940
|
+
filesWithoutLock: files,
|
|
941
|
+
lock,
|
|
942
|
+
filesByPath: new Map(allFiles.map((file) => [file.path, file])),
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
export function createAppScaffold(input) {
|
|
947
|
+
const { cwd, options, versions, createFileTree, ensureDirEmptyOrMissing } = input;
|
|
948
|
+
const profile = resolveProfile(options);
|
|
949
|
+
const appId = resolveAppId(options);
|
|
950
|
+
const appTitle = String(options.title || options.name || DEFAULT_APP_TITLE).trim() || DEFAULT_APP_TITLE;
|
|
951
|
+
const packageName = resolvePackageName(options, appId);
|
|
952
|
+
const author = String(options.author || '').trim();
|
|
953
|
+
const targetDir = path.resolve(cwd, String(options.dir || '').trim() || appId);
|
|
954
|
+
ensureDirEmptyOrMissing(targetDir);
|
|
955
|
+
input.mkdirSync(targetDir, { recursive: true });
|
|
956
|
+
const snapshot = buildAppScaffoldSnapshot({ profile, versions, appId, appTitle, packageName, author });
|
|
957
|
+
createFileTree(targetDir, snapshot.files);
|
|
958
|
+
process.stdout.write(`[nimi-app] created ${profile} app scaffold at ${targetDir}\n`);
|
|
959
|
+
}
|