Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-starters-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ankhorage/devtools': minor
---

Add released Universal Expo ZORA and plain-Expo bootstrap selection with catalog-validated infrastructure planning.
2,277 changes: 1,905 additions & 372 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,13 @@
"@ankhorage/apm": "^0.8.15",
"@ankhorage/capability": "^0.2.3",
"@ankhorage/contracts": "^28.4.0",
"@ankhorage/infra": "^7.7.1",
"@ankhorage/project-detector": "^0.3.6",
"@ankhorage/projects": "^0.11.0",
"@ankhorage/repository": "^0.14.5",
"@ankhorage/rules-repository": "^0.6.2",
"@ankhorage/utility": "^0.5.5",
"@ankhorage/templates": "12.11.1",
"@changesets/cli": "^3.1.0",
"@eslint/compat": "^2.1.1",
"@eslint/js": "^10.0.1",
Expand Down
160 changes: 159 additions & 1 deletion src/cli/commands/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
import { join } from 'node:path';

import { isRecord } from '@ankhorage/utility/object';
import { afterEach, expect, test } from 'bun:test';

import { init } from './init.js';
Expand Down Expand Up @@ -84,7 +85,8 @@ test('initializes a genuinely empty directory from a selected SPDX license templ

expect(result).toEqual({ exitCode: 0 });
expect(await readFile(join(target, 'LICENSE'), 'utf8')).toContain('Example Owner');
expect(JSON.parse(await readFile(join(target, 'package.json'), 'utf8'))).toMatchObject({
const manifest: unknown = JSON.parse(await readFile(join(target, 'package.json'), 'utf8'));
expect(isRecord(manifest) ? manifest : {}).toMatchObject({
name: '@example/scoped-package',
repository: { url: 'git+https://github.com/example/scoped-package.git' },
});
Expand Down Expand Up @@ -114,6 +116,8 @@ test('preserves an explicitly supplied license file', async () => {
'explicit-license-package',
'--purpose',
'Exercise explicit license file handling.',
'--project-type',
'package',
'--release-profile',
'none',
'--repository',
Expand All @@ -138,6 +142,131 @@ test('preserves an explicitly supplied license file', async () => {
);
});

test('materializes the released ZORA application before managed bootstrap preserves its files', async () => {
const target = await mkdtemp('/tmp/devtools-bootstrap-application-');
temporaryDirectories.push(target);
const context = { cwd: target, writeStderr: () => undefined, writeStdout: () => undefined };

const result = await init(
[
'--copyright-owner',
'Example Owner',
'--description',
'A generated application',
'--keywords',
'example',
'--kind',
'application',
'--license',
'MIT',
'--name',
'@example/application',
'--purpose',
'Exercise released application materialization.',
'--release-profile',
'none',
'--repository',
'example/application',
'--summary',
'Application bootstrap coverage.',
'--title',
'Application',
],
context,
{
publishBootstrapRepositoryAsync: () => Promise.resolve(),
runBootstrapScriptsAsync: () => Promise.resolve(),
runRepositoryCommand: () => Promise.resolve({ exitCode: 0 }),
runRepositoryMetadataCommandAsync: () => Promise.resolve({ exitCode: 0 }),
},
);

expect(result).toEqual({ exitCode: 0 });
expect(await Bun.file(join(target, 'src', 'app', 'index.tsx')).exists()).toBe(true);
expect(await Bun.file(join(target, 'src', 'index.ts')).exists()).toBe(false);
const manifest = await readFile(join(target, 'package.json'), 'utf8');
expect(manifest).toContain('"@ankhorage/zora"');
expect(manifest).toContain('"name": "@example/application"');
});

test('materializes the released plain Expo application without ZORA', async () => {
const target = await mkdtemp('/tmp/devtools-bootstrap-plain-expo-');
temporaryDirectories.push(target);
const context = { cwd: target, writeStderr: () => undefined, writeStdout: () => undefined };

const result = await init(
[
'--copyright-owner',
'Example Owner',
'--description',
'A generated plain Expo application',
'--keywords',
'example',
'--kind',
'application',
'--license',
'MIT',
'--name',
'@example/plain-application',
'--purpose',
'Exercise released plain Expo materialization.',
'--release-profile',
'none',
'--repository',
'example/plain-application',
'--summary',
'Plain Expo application bootstrap coverage.',
'--title',
'Plain Expo application',
'--ui-framework',
'none',
],
context,
{
publishBootstrapRepositoryAsync: () => Promise.resolve(),
runBootstrapScriptsAsync: () => Promise.resolve(),
runRepositoryCommand: () => Promise.resolve({ exitCode: 0 }),
runRepositoryMetadataCommandAsync: () => Promise.resolve({ exitCode: 0 }),
},
);

expect(result).toEqual({ exitCode: 0 });
expect(await Bun.file(join(target, 'app', 'index.tsx')).exists()).toBe(true);
const manifest = await readFile(join(target, 'package.json'), 'utf8');
expect(manifest).toContain('"expo"');
expect(manifest).toContain('"name": "@example/plain-application"');
});

test('rejects configured infrastructure before bootstrap mutates the target or GitHub', async () => {
const target = await mkdtemp('/tmp/devtools-bootstrap-infrastructure-');
temporaryDirectories.push(target);
let operations = 0;
const context = { cwd: target, writeStderr: () => undefined, writeStdout: () => undefined };

const result = await init(configuredApplicationArguments, context, {
publishBootstrapRepositoryAsync: () => {
operations += 1;
return Promise.resolve();
},
runBootstrapScriptsAsync: () => {
operations += 1;
return Promise.resolve();
},
runRepositoryCommand: () => {
operations += 1;
return Promise.resolve({ exitCode: 0 });
},
runRepositoryMetadataCommandAsync: () => {
operations += 1;
return Promise.resolve({ exitCode: 0 });
},
});

expect(result).toEqual({ exitCode: 1 });
expect(operations).toBe(0);
expect(await Bun.file(join(target, 'package.json')).exists()).toBe(false);
});

const publicationArguments = [
'--github-visibility',
'public',
Expand All @@ -147,6 +276,35 @@ const publicationArguments = [
'ankhorage/example',
] as const;

const configuredApplicationArguments = [
'--copyright-owner',
'Example Owner',
'--description',
'A configured application',
'--infrastructure-config',
JSON.stringify({
deployment: { compute: { provider: 'local' }, runtime: { provider: 'minikube' } },
}),
'--keywords',
'example',
'--kind',
'application',
'--license',
'MIT',
'--name',
'@example/configured-application',
'--purpose',
'Exercise configured infrastructure rejection.',
'--release-profile',
'none',
'--repository',
'example/configured-application',
'--summary',
'Configured infrastructure stays fail-closed.',
'--title',
'Configured application',
] as const;

async function createTargetAsync(): Promise<string> {
const target = await mkdtemp('/tmp/devtools-bootstrap-init-');
temporaryDirectories.push(target);
Expand Down
Loading