create-thally-docs 0.10.31 → 0.10.33
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 +24 -0
- package/dist/{chunk-NIYRBHH7.js → chunk-5TBIIZHQ.js} +1 -1
- package/dist/{chunk-EXH4PYPC.js → chunk-DPYULA35.js} +2 -2
- package/dist/{chunk-IRFT5MUJ.js → chunk-HOQBNMQ4.js} +1 -1
- package/dist/{chunk-VLLFRIPP.js → chunk-I2OURFVJ.js} +47 -7
- package/dist/chunk-V5PERCVX.js +608 -0
- package/dist/index.js +31 -405
- package/dist/migrate/index.d.ts +23 -0
- package/dist/migrate/index.js +5 -5
- package/dist/release.js +1 -1
- package/dist/scaffold.js +4 -4
- package/dist/starter-sync.js +2 -2
- package/dist/starter-update.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-DXD5Q42N.js +0 -113
package/dist/chunk-DXD5Q42N.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
initGit,
|
|
4
|
-
installDeps,
|
|
5
|
-
scaffold
|
|
6
|
-
} from "./chunk-NIYRBHH7.js";
|
|
7
|
-
|
|
8
|
-
// src/migrate/index.ts
|
|
9
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
10
|
-
import { tmpdir } from "os";
|
|
11
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
12
|
-
import {
|
|
13
|
-
cloneGitHubRepository,
|
|
14
|
-
migrateRepository,
|
|
15
|
-
migrateUrl,
|
|
16
|
-
parseGitHubRepositoryUrl,
|
|
17
|
-
renderMigrationFiles
|
|
18
|
-
} from "@thallylabs/migrate";
|
|
19
|
-
function projectPath(projectDir, candidate) {
|
|
20
|
-
const target = resolve(projectDir, candidate);
|
|
21
|
-
const fromRoot = relative(resolve(projectDir), target);
|
|
22
|
-
if (isAbsolute(fromRoot) || fromRoot === ".." || fromRoot.startsWith(`..${sep}`)) {
|
|
23
|
-
throw new Error(`Generated migration path escapes the project: ${candidate}`);
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
}
|
|
27
|
-
function readExistingConfig(projectDir) {
|
|
28
|
-
const configPath = projectPath(projectDir, "docs.json");
|
|
29
|
-
if (!existsSync(configPath)) return void 0;
|
|
30
|
-
return JSON.parse(readFileSync(configPath, "utf8"));
|
|
31
|
-
}
|
|
32
|
-
function resetFreshMigrationContent(projectDir) {
|
|
33
|
-
const contentDirectory = projectPath(projectDir, "src/content");
|
|
34
|
-
rmSync(contentDirectory, { recursive: true, force: true });
|
|
35
|
-
mkdirSync(contentDirectory, { recursive: true });
|
|
36
|
-
for (const sampleSpec of ["openapi.yaml", "openapi.json"]) {
|
|
37
|
-
rmSync(projectPath(projectDir, sampleSpec), { force: true });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function discoverMigration(options) {
|
|
41
|
-
const url = new URL(options.sourceUrl);
|
|
42
|
-
if (url.hostname.toLowerCase() !== "github.com") {
|
|
43
|
-
console.log(` \u{1F310} Discovering public docs at ${url.origin}${url.pathname}...`);
|
|
44
|
-
return migrateUrl({
|
|
45
|
-
sourceUrl: options.sourceUrl,
|
|
46
|
-
platform: options.platform,
|
|
47
|
-
maxPages: options.maxPages,
|
|
48
|
-
fetcher: options.fetcher
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const source = parseGitHubRepositoryUrl(options.sourceUrl);
|
|
52
|
-
if (options.branch) source.branch = options.branch;
|
|
53
|
-
const temporaryRoot = mkdtempSync(join(tmpdir(), "thally-migrate-"));
|
|
54
|
-
const cloneDir = join(temporaryRoot, "repository");
|
|
55
|
-
console.log(` \u{1F4E6} Cloning ${source.owner}/${source.repo}...`);
|
|
56
|
-
try {
|
|
57
|
-
await cloneGitHubRepository(source, cloneDir);
|
|
58
|
-
return migrateRepository({
|
|
59
|
-
repositoryDir: cloneDir,
|
|
60
|
-
sourceUrl: options.sourceUrl,
|
|
61
|
-
docsDir: options.docsDir ?? (source.docsDir || void 0),
|
|
62
|
-
platform: options.platform
|
|
63
|
-
});
|
|
64
|
-
} finally {
|
|
65
|
-
rmSync(temporaryRoot, { recursive: true, force: true });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async function migrateDocs(options) {
|
|
69
|
-
const projectDir = resolve(options.projectDir);
|
|
70
|
-
const bundle = await discoverMigration(options);
|
|
71
|
-
if (!options.into) {
|
|
72
|
-
console.log(`
|
|
73
|
-
\u{1F3D7} Scaffolding new project at ${projectDir}...`);
|
|
74
|
-
await scaffold({
|
|
75
|
-
projectDir,
|
|
76
|
-
projectName: options.projectName ?? bundle.site?.name ?? "My Docs",
|
|
77
|
-
description: bundle.site?.description ?? `Documentation migrated from ${new URL(options.sourceUrl).hostname}`,
|
|
78
|
-
brandPreset: "primary",
|
|
79
|
-
repoUrl: bundle.sourceKind === "repository" ? options.sourceUrl : "",
|
|
80
|
-
doInstall: false
|
|
81
|
-
});
|
|
82
|
-
resetFreshMigrationContent(projectDir);
|
|
83
|
-
} else if (!existsSync(projectDir)) {
|
|
84
|
-
throw new Error(`Project directory "${projectDir}" does not exist. Use without --into to scaffold a new one.`);
|
|
85
|
-
}
|
|
86
|
-
const rendered = renderMigrationFiles(bundle, {
|
|
87
|
-
existingConfig: options.into ? readExistingConfig(projectDir) : void 0
|
|
88
|
-
});
|
|
89
|
-
for (const file of rendered) {
|
|
90
|
-
const destination = projectPath(projectDir, file.path);
|
|
91
|
-
mkdirSync(dirname(destination), { recursive: true });
|
|
92
|
-
writeFileSync(destination, file.content);
|
|
93
|
-
}
|
|
94
|
-
for (const warning of bundle.warnings) {
|
|
95
|
-
console.warn(` \u26A0 ${warning.message}${warning.source ? ` (${warning.source})` : ""}`);
|
|
96
|
-
}
|
|
97
|
-
console.log(` \u2713 Imported ${bundle.pages.length} pages and ${bundle.assets.length} assets from ${bundle.platform}.`);
|
|
98
|
-
if (!options.into) {
|
|
99
|
-
installDeps(projectDir);
|
|
100
|
-
initGit(projectDir);
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
pagesWritten: bundle.pages.length,
|
|
104
|
-
assetsWritten: bundle.assets.length,
|
|
105
|
-
projectDir,
|
|
106
|
-
platform: bundle.platform,
|
|
107
|
-
warnings: bundle.warnings
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
migrateDocs
|
|
113
|
-
};
|