mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-22 21:07:57 +00:00
Compare commits
No commits in common. "31c3105e346b0b5b6b2d833656d5bfde1990851d" and "c4c41e0e31c230271489132e13c61b30ee8a2bc6" have entirely different histories.
31c3105e34
...
c4c41e0e31
5 changed files with 40 additions and 45 deletions
|
|
@ -93,7 +93,7 @@ GRANT_TOKEN_SECRET="your-secret-here"
|
||||||
|
|
||||||
- [x] Project renamed from Embargo to Myst
|
- [x] Project renamed from Embargo to Myst
|
||||||
- [x] CLI scaffold (`myst init`)
|
- [x] CLI scaffold (`myst init`)
|
||||||
- [x] Config generation (`.env`)
|
- [x] Config generation (`.env`, `myst.config.json`)
|
||||||
- [ ] Service foundation (FastAPI + PostgreSQL)
|
- [ ] Service foundation (FastAPI + PostgreSQL)
|
||||||
- [ ] `myst forgejo bootstrap` — verify Forgejo connectivity
|
- [ ] `myst forgejo bootstrap` — verify Forgejo connectivity
|
||||||
- [ ] `myst doctor` — validate configuration
|
- [ ] `myst doctor` — validate configuration
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,8 @@ Only repo owners can create view links for their repos.
|
||||||
|
|
||||||
`myst init` should generate all Myst-owned deployment config needed for Phase 1:
|
`myst init` should generate all Myst-owned deployment config needed for Phase 1:
|
||||||
|
|
||||||
- `.env` (environment variables for Docker/container deployment)
|
- `.env`
|
||||||
|
- `myst.config.json`
|
||||||
- any future Myst-only deployment templates, but never Forgejo provisioning files
|
- any future Myst-only deployment templates, but never Forgejo provisioning files
|
||||||
|
|
||||||
`myst init` should provide inline guidance that:
|
`myst init` should provide inline guidance that:
|
||||||
|
|
|
||||||
|
|
@ -208,6 +208,7 @@ The CLI is the primary way to configure and validate Myst against an existing Fo
|
||||||
- generate a grant token secret by default unless the operator pastes one
|
- generate a grant token secret by default unless the operator pastes one
|
||||||
- generate all Myst-owned config files needed for deployment in Phase 1
|
- generate all Myst-owned config files needed for deployment in Phase 1
|
||||||
- write `.env`
|
- write `.env`
|
||||||
|
- write `myst.config.json`
|
||||||
- print manual follow-up actions for admin URL protection, app deployment, and Forgejo validation
|
- print manual follow-up actions for admin URL protection, app deployment, and Forgejo validation
|
||||||
- show links to Forgejo docs for API usage, token scopes, repo permissions, and the admin CLI
|
- show links to Forgejo docs for API usage, token scopes, repo permissions, and the admin CLI
|
||||||
- remind operators to run `myst init` in the directory where Myst will be deployed, usually on the target VPS or server workspace
|
- remind operators to run `myst init` in the directory where Myst will be deployed, usually on the target VPS or server workspace
|
||||||
|
|
@ -284,6 +285,7 @@ Forgejo docs to link directly from CLI output:
|
||||||
Expected outputs from `init`:
|
Expected outputs from `init`:
|
||||||
|
|
||||||
- `.env`
|
- `.env`
|
||||||
|
- `myst.config.json`
|
||||||
- optional platform templates for Myst only (e.g., Docker Compose for Dokploy)
|
- optional platform templates for Myst only (e.g., Docker Compose for Dokploy)
|
||||||
|
|
||||||
## Data Model
|
## Data Model
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ function validateHttpUrlOrHost(
|
||||||
try {
|
try {
|
||||||
const normalized = normalizeHttpUrl(value);
|
const normalized = normalizeHttpUrl(value);
|
||||||
const url = new URL(normalized);
|
const url = new URL(normalized);
|
||||||
|
|
||||||
if (!url.hostname) {
|
if (!url.hostname) {
|
||||||
return `${label} must include a domain or hostname`;
|
return `${label} must include a domain or hostname`;
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +125,7 @@ async function preflightWriteTargets(filePaths: string[]): Promise<void> {
|
||||||
* @param _args - The command arguments.
|
* @param _args - The command arguments.
|
||||||
* @returns {Promise<void>} A promise that resolves when the initialization is complete.
|
* @returns {Promise<void>} A promise that resolves when the initialization is complete.
|
||||||
*/
|
*/
|
||||||
export async function initCommand(args?: string[]): Promise<void> {
|
export async function initCommand(_args: string[]): Promise<void> {
|
||||||
p.intro(c.bold("myst init"));
|
p.intro(c.bold("myst init"));
|
||||||
p.note(
|
p.note(
|
||||||
[
|
[
|
||||||
|
|
@ -223,14 +224,30 @@ export async function initCommand(args?: string[]): Promise<void> {
|
||||||
publicUrl,
|
publicUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const configContent = JSON.stringify(
|
||||||
|
{
|
||||||
|
adminUrl,
|
||||||
|
forgejoBaseUrl,
|
||||||
|
forgejoBotUsername: answers.forgejoBotUsername,
|
||||||
|
publicUrl,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
);
|
||||||
|
|
||||||
const outDir = process.cwd();
|
const outDir = process.cwd();
|
||||||
const envPath = path.join(outDir, ".env");
|
const envPath = path.join(outDir, ".env");
|
||||||
|
const configPath = path.join(outDir, "myst.config.json");
|
||||||
|
|
||||||
await preflightWriteTargets([envPath]);
|
await preflightWriteTargets([envPath, configPath]);
|
||||||
await writePrivateFile(envPath, envContent);
|
await writePrivateFile(envPath, envContent);
|
||||||
|
await writePrivateFile(configPath, configContent);
|
||||||
|
|
||||||
s.stop("Config files generated");
|
s.stop("Config files generated");
|
||||||
p.note(c.green(".env"), c.yellow("File written to current directory"));
|
p.note(
|
||||||
|
[c.green(".env"), c.green("myst.config.json")].join("\n"),
|
||||||
|
c.yellow("Files written to current directory"),
|
||||||
|
);
|
||||||
p.note(
|
p.note(
|
||||||
[
|
[
|
||||||
`${c.bold("Public viewer URL:")} ${c.cyan(publicUrl)}`,
|
`${c.bold("Public viewer URL:")} ${c.cyan(publicUrl)}`,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { parseArgs } from "node:util";
|
|
||||||
|
|
||||||
import * as c from "yoctocolors";
|
import * as c from "yoctocolors";
|
||||||
import pkg from "../package.json" with { type: "json" };
|
import pkg from "../package.json" with { type: "json" };
|
||||||
|
|
||||||
|
|
@ -9,42 +7,31 @@ import { getHelpText } from "./help.js";
|
||||||
|
|
||||||
type CommandName = "init";
|
type CommandName = "init";
|
||||||
|
|
||||||
type CommandHandler = (args?: string[]) => Promise<void>;
|
type CommandHandler = (args: string[]) => Promise<void>;
|
||||||
|
|
||||||
const commandHandlers: Record<CommandName, CommandHandler> = {
|
const commandHandlers: Record<CommandName, CommandHandler> = {
|
||||||
init: initCommand,
|
init: initCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isKnownCommand(value: string): value is CommandName {
|
||||||
|
return value in commandHandlers;
|
||||||
|
}
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
const { values, positionals } = parseArgs({
|
const [command, ...options] = process.argv.slice(2);
|
||||||
args: process.argv.slice(2),
|
const flags = options.filter((o) => o.startsWith("-"));
|
||||||
options: {
|
|
||||||
version: {
|
|
||||||
type: "boolean",
|
|
||||||
short: "v",
|
|
||||||
},
|
|
||||||
help: {
|
|
||||||
type: "boolean",
|
|
||||||
short: "h",
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
type: "string",
|
|
||||||
short: "o",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
allowPositionals: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const command = positionals[0];
|
if (flags.includes("-v") || flags.includes("--version")) {
|
||||||
|
process.stdout.write(`${pkg.version}\n`);
|
||||||
if (!command) {
|
|
||||||
process.stdout.write(getHelpText());
|
|
||||||
process.exitCode = 0;
|
process.exitCode = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isKnownCommand = (cmd: string): cmd is CommandName =>
|
if (!command || flags.includes("-h") || flags.includes("--help")) {
|
||||||
cmd in commandHandlers;
|
process.stdout.write(getHelpText());
|
||||||
|
process.exitCode = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isKnownCommand(command)) {
|
if (!isKnownCommand(command)) {
|
||||||
process.stderr.write(`Unknown command: ${command}\n`);
|
process.stderr.write(`Unknown command: ${command}\n`);
|
||||||
|
|
@ -52,20 +39,8 @@ async function main(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (values.help) {
|
|
||||||
process.stdout.write(getHelpText());
|
|
||||||
process.exitCode = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values.version) {
|
|
||||||
process.stdout.write(`${pkg.version}`);
|
|
||||||
process.exitCode = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await commandHandlers[command]();
|
await commandHandlers[command](options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : "Unknown error";
|
const message = error instanceof Error ? error.message : "Unknown error";
|
||||||
process.stderr.write(`${c.red("Error:")} ${message}\n`);
|
process.stderr.write(`${c.red("Error:")} ${message}\n`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue