2026-04-11 00:38:00 +02:00
|
|
|
import { existsSync, mkdirSync, writeFileSync, readdirSync, statSync, readFileSync } from 'fs';
|
|
|
|
|
import { join, dirname } from 'path';
|
|
|
|
|
import { fileURLToPath } from 'url';
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
import { doctorCommand } from './doctor.js';
|
2026-04-11 00:38:00 +02:00
|
|
|
|
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
const TEMPLATES_DIR = join(here, '..', '..', 'templates');
|
|
|
|
|
|
|
|
|
|
export interface InitOptions {
|
|
|
|
|
name?: string;
|
|
|
|
|
template?: string;
|
|
|
|
|
prekeyServer?: string;
|
|
|
|
|
cwd?: string;
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
runDoctor?: boolean;
|
2026-04-11 00:38:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function initCommand(opts: InitOptions = {}): Promise<void> {
|
|
|
|
|
const name = opts.name ?? 'my-shade-app';
|
|
|
|
|
const template = opts.template ?? 'bun-server';
|
|
|
|
|
const cwd = opts.cwd ?? process.cwd();
|
|
|
|
|
const target = join(cwd, name);
|
|
|
|
|
|
|
|
|
|
if (existsSync(target)) {
|
|
|
|
|
throw new Error(`Target directory "${target}" already exists`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const templateDir = join(TEMPLATES_DIR, template);
|
|
|
|
|
if (!existsSync(templateDir)) {
|
|
|
|
|
const available = listTemplates();
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Template "${template}" not found. Available: ${available.join(', ')}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Recursive copy with placeholder substitution
|
|
|
|
|
mkdirSync(target, { recursive: true });
|
|
|
|
|
copyRecursive(templateDir, target, {
|
|
|
|
|
__PROJECT_NAME__: name,
|
|
|
|
|
__PREKEY_SERVER__: opts.prekeyServer ?? 'http://localhost:3900',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(`✓ Created ${name} from template "${template}"`);
|
|
|
|
|
console.log('');
|
|
|
|
|
console.log(` cd ${name}`);
|
|
|
|
|
console.log(' bun install');
|
|
|
|
|
console.log(' bun run start');
|
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.
Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
non-realtime stack.
Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
version 4.0.0 on /health.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00
|
|
|
|
|
|
|
|
if (opts.runDoctor) {
|
|
|
|
|
console.log('');
|
|
|
|
|
await doctorCommand({ cwd: target });
|
|
|
|
|
}
|
2026-04-11 00:38:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function listTemplates(): string[] {
|
|
|
|
|
if (!existsSync(TEMPLATES_DIR)) return [];
|
|
|
|
|
return readdirSync(TEMPLATES_DIR).filter((name) => {
|
|
|
|
|
return statSync(join(TEMPLATES_DIR, name)).isDirectory();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function copyRecursive(
|
|
|
|
|
source: string,
|
|
|
|
|
dest: string,
|
|
|
|
|
replacements: Record<string, string>,
|
|
|
|
|
): void {
|
|
|
|
|
mkdirSync(dest, { recursive: true });
|
|
|
|
|
for (const entry of readdirSync(source)) {
|
|
|
|
|
const srcPath = join(source, entry);
|
|
|
|
|
const destPath = join(dest, entry);
|
|
|
|
|
const st = statSync(srcPath);
|
|
|
|
|
|
|
|
|
|
if (st.isDirectory()) {
|
|
|
|
|
copyRecursive(srcPath, destPath, replacements);
|
|
|
|
|
} else {
|
|
|
|
|
const content = readFileSync(srcPath, 'utf-8');
|
|
|
|
|
const substituted = Object.entries(replacements).reduce(
|
|
|
|
|
(acc, [key, value]) => acc.replaceAll(key, value),
|
|
|
|
|
content,
|
|
|
|
|
);
|
|
|
|
|
writeFileSync(destPath, substituted);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|