@downdraft/cli 0.1.0 → 0.1.2-alpha.5
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/package.json +4 -3
- package/scripts/default-icon.png +0 -0
- package/scripts/native-lib-fetch.mjs +63 -0
- package/scripts/package-desktop.mjs +937 -0
- package/scripts/package-mobile.mjs +47 -4
- package/scripts/package-native.mjs +39 -10
- package/src/dev.ts +63 -22
- package/src/index.ts +12 -6
- package/src/mcp.ts +6 -2
- package/src/paths.ts +17 -0
- package/src/plugin-command.ts +10 -10
- package/src/release.ts +103 -41
- package/src/scaffold-plugin.ts +2 -2
- package/src/usage.ts +7 -2
- package/templates/_shared/partials/config-json-fields.eta +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@downdraft/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-alpha.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/knackstedt/downdraft.git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@aws-sdk/client-s3": "^3.700.0",
|
|
15
|
-
"@downdraft/engine": "^0.1.
|
|
15
|
+
"@downdraft/engine": "^0.1.2-alpha.5",
|
|
16
16
|
"eta": "^3.5.0",
|
|
17
17
|
"jimp": "^1.6.1",
|
|
18
18
|
"resedit": "3.1.0"
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"scripts",
|
|
32
32
|
"templates",
|
|
33
33
|
"README.md",
|
|
34
|
-
"!**/*.spec.ts"
|
|
34
|
+
"!**/*.spec.ts",
|
|
35
|
+
"!**/*.test.ts"
|
|
35
36
|
],
|
|
36
37
|
"description": "The `draft` command-line tool — project scaffolding (draft new), dev server, builds, release packaging, mobile targets, and plugin/module scaffolding."
|
|
37
38
|
}
|
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// native-lib-fetch.mjs — fetch @downdraft/native-<plat>-<arch> lib dirs
|
|
3
|
+
//
|
|
4
|
+
// The per-platform binary packages are published to npm as optional deps of
|
|
5
|
+
// @downdraft/platform-native, but npm/bun/deno skip installing packages whose
|
|
6
|
+
// os/cpu don't match the host — so cross-packaging (--target=win from linux,
|
|
7
|
+
// etc.) has no local copy of the target's cdylibs. The tarballs are still on
|
|
8
|
+
// the registry though; this fetches and caches them under
|
|
9
|
+
// <cacheRoot>/downdraft-native/<plat>-<arch>/lib.
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
import { execFileSync } from "node:child_process";
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import { dirname, join } from "node:path";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return a dir containing the target platform's cdylibs — the first existing
|
|
19
|
+
* candidate, else the @downdraft/native-<platKey> npm tarball fetched into
|
|
20
|
+
* the cache. Returns null when nothing is available.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} platKey e.g. "win32-x64", "darwin-arm64"
|
|
23
|
+
* @param {string[]} candidates existing dirs to try before fetching
|
|
24
|
+
* @param {string} cacheRoot parent dir for the fetch cache
|
|
25
|
+
* @param {string|null} version preferred package version (platform-native's,
|
|
26
|
+
* lockstep) — falls back to the registry's latest tag
|
|
27
|
+
*/
|
|
28
|
+
export async function resolvePlatLibDir(platKey, candidates, cacheRoot, version) {
|
|
29
|
+
const hit = candidates.find((d) => d && existsSync(d));
|
|
30
|
+
if (hit) return hit;
|
|
31
|
+
|
|
32
|
+
const pkgName = `@downdraft/native-${platKey}`;
|
|
33
|
+
const cacheDir = join(cacheRoot, "downdraft-native", platKey, "lib");
|
|
34
|
+
if (existsSync(cacheDir) && readdirSync(cacheDir).length > 0) return cacheDir;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const meta = await (await fetch(
|
|
38
|
+
`https://registry.npmjs.org/${pkgName.replace("/", "%2F")}`)).json();
|
|
39
|
+
const ver = meta?.versions?.[version] ? version : meta?.["dist-tags"]?.latest;
|
|
40
|
+
const tarball = ver && meta.versions[ver]?.dist?.tarball;
|
|
41
|
+
if (!tarball) return null;
|
|
42
|
+
|
|
43
|
+
const tmp = mkdtempSync(join(tmpdir(), "dd-native-"));
|
|
44
|
+
try {
|
|
45
|
+
const tgz = join(tmp, "pkg.tgz");
|
|
46
|
+
writeFileSync(tgz, Buffer.from(await (await fetch(tarball)).arrayBuffer()));
|
|
47
|
+
execFileSync("tar", ["-xzf", tgz, "-C", tmp], { stdio: "pipe" });
|
|
48
|
+
const libDir = join(tmp, "package", "lib");
|
|
49
|
+
if (!existsSync(libDir) || readdirSync(libDir).length === 0) return null;
|
|
50
|
+
rmSync(dirname(cacheDir), { recursive: true, force: true });
|
|
51
|
+
mkdirSync(dirname(cacheDir), { recursive: true });
|
|
52
|
+
// cpSync not renameSync: TMPDIR may be a different filesystem.
|
|
53
|
+
cpSync(libDir, cacheDir, { recursive: true });
|
|
54
|
+
console.log(`[package] fetched ${pkgName}@${ver} from npm → ${cacheDir}`);
|
|
55
|
+
return cacheDir;
|
|
56
|
+
} finally {
|
|
57
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.warn(`[package] ${pkgName} fetch failed: ${e?.message ?? e}`);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|