@parity-app/cli 0.0.0-stage → 0.0.0
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/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/bin.mjs +831 -0
- package/dist/client-DsTLQ2lT.mjs +286 -0
- package/dist/in-app.json +10 -0
- package/dist/index.d.mts +160 -0
- package/dist/index.mjs +1 -0
- package/dist/libraries/aria.lib.par +14516 -0
- package/dist/libraries/baseui.lib.par +8298 -0
- package/dist/libraries/buildkit-baseui.edits.json +3 -0
- package/dist/libraries/chakra.lib.par +539186 -0
- package/dist/libraries/fluent-icons.lib.par +2674 -0
- package/dist/libraries/fluent.lib.par +33703 -0
- package/dist/libraries/heroicons.lib.par +33 -0
- package/dist/libraries/hugeicons.lib.par +708 -0
- package/dist/libraries/lucide.lib.par +2123 -0
- package/dist/libraries/luma.lib.par +16362 -0
- package/dist/libraries/lyra.lib.par +16362 -0
- package/dist/libraries/maia.lib.par +16362 -0
- package/dist/libraries/mantine.lib.par +32935 -0
- package/dist/libraries/mira.lib.par +16362 -0
- package/dist/libraries/mui.lib.par +9817 -0
- package/dist/libraries/nova.lib.par +16363 -0
- package/dist/libraries/phosphor.lib.par +3060 -0
- package/dist/libraries/radix.lib.par +6890 -0
- package/dist/libraries/rhea.lib.par +16362 -0
- package/dist/libraries/sera.lib.par +16362 -0
- package/dist/libraries/tabler.lib.par +5325 -0
- package/dist/libraries/vega.lib.par +16362 -0
- package/dist/published-BtL8RM6W.mjs +1 -0
- package/dist/published-CdXoUgfD.mjs +200 -0
- package/dist/src-C8DCd2a1.mjs +1 -0
- package/dist/src-CSeISXoZ.mjs +1298 -0
- package/dist/src-WcAfq6g1.mjs +2 -0
- package/dist/src-rlZNC2MU.mjs +4690 -0
- package/dist/src-uPmBVSsB.mjs +53 -0
- package/package.json +50 -3
- package/skills/SKILL.md +96 -0
- package/skills/document.md +166 -0
- package/skills/execute.md +276 -0
- package/skills/guide/checking.md +56 -0
- package/skills/guide/components.md +48 -0
- package/skills/guide/design-system.md +52 -0
- package/skills/guide/mobile.md +32 -0
- package/skills/guide/states-and-modes.md +55 -0
- package/skills/guide/web-app.md +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as installedVersion, i as publishedVersion } from "./published-CdXoUgfD.mjs";
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { exec, execFile } from "node:child_process";
|
|
6
|
+
import { gunzipSync } from "node:zlib";
|
|
7
|
+
// ../libgen/src/published.ts
|
|
8
|
+
const registry = "https://registry.npmjs.org";
|
|
9
|
+
const run = promisify(execFile);
|
|
10
|
+
const shell = promisify(exec);
|
|
11
|
+
/** The versions npm has published of a package. */
|
|
12
|
+
async function publishedVersions(name) {
|
|
13
|
+
return Object.keys((await packument(name)).versions ?? {});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The version of a package that `wanted` names: that version when npm has published it, or the one a tag such as
|
|
17
|
+
* `latest` points to.
|
|
18
|
+
*/
|
|
19
|
+
async function publishedVersion(name, wanted) {
|
|
20
|
+
const { versions, "dist-tags": tags } = await packument(name);
|
|
21
|
+
if (versions?.[wanted]) return wanted;
|
|
22
|
+
const tagged = tags?.[wanted];
|
|
23
|
+
if (tagged) return tagged;
|
|
24
|
+
throw new Error(`npm has no ${name}@${wanted}: give a version it has published, or a tag such as latest`);
|
|
25
|
+
}
|
|
26
|
+
async function packument(name) {
|
|
27
|
+
const response = await fetch(`${registry}/${name.replace("/", "%2F")}`, { headers: { accept: "application/vnd.npm.install-v1+json" } });
|
|
28
|
+
if (!response.ok) throw new Error(`npm has no ${name} (${response.status})`);
|
|
29
|
+
return await response.json();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A folder with one version of a package installed, and what it depends on, so a library can be described without a
|
|
33
|
+
* project that has it. npm installs it with its peers, such as React, and without running anyone's install scripts. A
|
|
34
|
+
* version never changes, so each is installed once and kept.
|
|
35
|
+
*/
|
|
36
|
+
async function installedVersion(name, version, cacheRoot = join(homedir(), ".parity", "cache", "packages")) {
|
|
37
|
+
if (!/^(?:@[\w.~-]+\/)?[\w.~-]+$/.test(name) || !/^[\w.+-]+$/.test(version)) throw new Error(`${name}@${version} isn't a package name and version npm could have published`);
|
|
38
|
+
const dir = join(cacheRoot, `${name.replace("/", "+")}@${version}`);
|
|
39
|
+
const installed = join(dir, ".parity-installed");
|
|
40
|
+
if (await readFile(installed, "utf8").then(() => true, () => false)) return dir;
|
|
41
|
+
await rm(dir, {
|
|
42
|
+
recursive: true,
|
|
43
|
+
force: true
|
|
44
|
+
});
|
|
45
|
+
await mkdir(dir, { recursive: true });
|
|
46
|
+
await writeFile(join(dir, "package.json"), `${JSON.stringify({
|
|
47
|
+
name: "parity-library",
|
|
48
|
+
private: true,
|
|
49
|
+
dependencies: { [name]: version }
|
|
50
|
+
}, null, 2)}\n`);
|
|
51
|
+
const npm = (args = "") => shell(`npm install --ignore-scripts --no-audit --no-fund --loglevel=error${args}`, {
|
|
52
|
+
cwd: dir,
|
|
53
|
+
timeout: 6e5,
|
|
54
|
+
maxBuffer: 67108864,
|
|
55
|
+
windowsHide: true
|
|
56
|
+
});
|
|
57
|
+
await npm();
|
|
58
|
+
const react = await readFile(join(dir, "node_modules", "react", "package.json"), "utf8").then((text) => JSON.parse(text).version, () => void 0);
|
|
59
|
+
if (react && /^\d+\.\d+\.\d+$/.test(react)) {
|
|
60
|
+
const major = react.split(".")[0];
|
|
61
|
+
await npm(` --save-exact react@${react} react-dom@${react} @types/react@${major} @types/react-dom@${major}`);
|
|
62
|
+
}
|
|
63
|
+
await writeFile(installed, `${name}@${version}\n`);
|
|
64
|
+
return dir;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The repository a package's version was published from and its commit, as npm records them, when it does. The
|
|
68
|
+
* repository is the URL git fetches, whichever way the package wrote it (`git+https://….git`, `github:owner/name`).
|
|
69
|
+
*/
|
|
70
|
+
async function publishedSource(name, version) {
|
|
71
|
+
const response = await fetch(`${registry}/${name.replace("/", "%2F")}/${version}`);
|
|
72
|
+
if (!response.ok) throw new Error(`npm has no ${name}@${version} (${response.status})`);
|
|
73
|
+
const { gitHead, repository } = await response.json();
|
|
74
|
+
const url = typeof repository === "string" ? repository : repository?.url;
|
|
75
|
+
return {
|
|
76
|
+
...url ? { repository: repositoryUrl(url) } : {},
|
|
77
|
+
...gitHead && /^[0-9a-f]{40}$/.test(gitHead) ? { commit: gitHead } : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** A repository as npm may record it, as the https URL git fetches. */
|
|
81
|
+
function repositoryUrl(recorded) {
|
|
82
|
+
const shorthand = /^(?:github:)?([\w.-]+\/[\w.-]+)$/.exec(recorded);
|
|
83
|
+
if (shorthand) return `https://github.com/${shorthand[1].replace(/\.git$/, "")}`;
|
|
84
|
+
return recorded.replace(/^git\+/, "").replace(/^git:\/\//, "https://").replace(/^ssh:\/\/git@/, "https://").replace(/^git@([^:]+):/, "https://$1/").replace(/\.git$/, "");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A repository's files at one commit whose paths match, fetched alone: a shallow fetch without any file's contents,
|
|
88
|
+
* then a sparse checkout of just the matches. A commit never changes, so its files are cached.
|
|
89
|
+
*/
|
|
90
|
+
async function repositoryFiles(repo, commit, matches, cacheRoot = join(homedir(), ".parity", "cache", "repositories")) {
|
|
91
|
+
const dir = join(cacheRoot, `${repo.replace(/^https?:\/\//, "").replaceAll(/[^\w.-]+/g, "-")}-${commit.slice(0, 12)}`);
|
|
92
|
+
const listed = join(dir, ".parity-files");
|
|
93
|
+
const key = `${commit}\n${matches.source}\n`;
|
|
94
|
+
let paths = await readFile(listed, "utf8").then((text) => text.startsWith(key) ? text.slice(key.length).split("\n").filter(Boolean) : void 0, () => void 0);
|
|
95
|
+
if (!paths) {
|
|
96
|
+
await rm(dir, {
|
|
97
|
+
recursive: true,
|
|
98
|
+
force: true
|
|
99
|
+
});
|
|
100
|
+
await mkdir(dir, { recursive: true });
|
|
101
|
+
await git(["init", "-q"], dir);
|
|
102
|
+
await git([
|
|
103
|
+
"fetch",
|
|
104
|
+
"-q",
|
|
105
|
+
"--depth",
|
|
106
|
+
"1",
|
|
107
|
+
"--filter=blob:none",
|
|
108
|
+
repo,
|
|
109
|
+
commit
|
|
110
|
+
], dir, 3e5);
|
|
111
|
+
const { stdout } = await git([
|
|
112
|
+
"ls-tree",
|
|
113
|
+
"-r",
|
|
114
|
+
"--name-only",
|
|
115
|
+
"FETCH_HEAD"
|
|
116
|
+
], dir, 12e4);
|
|
117
|
+
paths = stdout.split("\n").filter((path) => path && matches.test(path));
|
|
118
|
+
if (paths.length > 0) {
|
|
119
|
+
await git([
|
|
120
|
+
"sparse-checkout",
|
|
121
|
+
"set",
|
|
122
|
+
"--no-cone",
|
|
123
|
+
"--stdin"
|
|
124
|
+
], dir, 6e4, paths.map((path) => `/${path}`).join("\n"));
|
|
125
|
+
await git([
|
|
126
|
+
"checkout",
|
|
127
|
+
"-q",
|
|
128
|
+
"FETCH_HEAD"
|
|
129
|
+
], dir, 6e5);
|
|
130
|
+
}
|
|
131
|
+
await writeFile(listed, key + paths.join("\n"));
|
|
132
|
+
}
|
|
133
|
+
const files = [];
|
|
134
|
+
for (const path of paths) {
|
|
135
|
+
const text = await readFile(join(dir, path), "utf8").catch(() => void 0);
|
|
136
|
+
if (text !== void 0) files.push({
|
|
137
|
+
path,
|
|
138
|
+
text
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return files;
|
|
142
|
+
}
|
|
143
|
+
async function git(args, cwd, timeout = 6e4, input) {
|
|
144
|
+
const child = run("git", args, {
|
|
145
|
+
cwd,
|
|
146
|
+
timeout,
|
|
147
|
+
maxBuffer: 268435456,
|
|
148
|
+
windowsHide: true
|
|
149
|
+
});
|
|
150
|
+
if (input !== void 0) {
|
|
151
|
+
child.child.stdin?.write(input);
|
|
152
|
+
child.child.stdin?.end();
|
|
153
|
+
}
|
|
154
|
+
return child;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* One file from a package as npm publishes it, read from its tarball, without installing it or running anything it
|
|
158
|
+
* ships. Each file is cached per version, which never changes once published.
|
|
159
|
+
*/
|
|
160
|
+
async function packageFile(name, version, path, cacheRoot = join(homedir(), ".parity", "cache", "npm")) {
|
|
161
|
+
const cached = join(cacheRoot, `${name.replace("/", "+")}@${version}`, ...path.split("/"));
|
|
162
|
+
try {
|
|
163
|
+
return await readFile(cached, "utf8");
|
|
164
|
+
} catch {}
|
|
165
|
+
const meta = await fetch(`${registry}/${name.replace("/", "%2F")}/${version}`);
|
|
166
|
+
if (!meta.ok) throw new Error(`npm has no ${name}@${version} (${meta.status})`);
|
|
167
|
+
const tarball = (await meta.json()).dist?.tarball;
|
|
168
|
+
if (!tarball) throw new Error(`npm gives no tarball for ${name}@${version}`);
|
|
169
|
+
const archive = await fetch(tarball);
|
|
170
|
+
if (!archive.ok) throw new Error(`${name}@${version}'s tarball couldn't be downloaded (${archive.status})`);
|
|
171
|
+
const file = tarEntry(gunzipSync(Buffer.from(await archive.arrayBuffer())), `package/${path}`);
|
|
172
|
+
if (!file) throw new Error(`${name}@${version} has no ${path}`);
|
|
173
|
+
const text = file.toString("utf8");
|
|
174
|
+
await mkdir(dirname(cached), { recursive: true });
|
|
175
|
+
await writeFile(cached, text);
|
|
176
|
+
return text;
|
|
177
|
+
}
|
|
178
|
+
/** A file in a tar archive by its path, reading the long names pax headers give. */
|
|
179
|
+
function tarEntry(archive, wanted) {
|
|
180
|
+
let offset = 0;
|
|
181
|
+
let longName;
|
|
182
|
+
while (offset + 512 <= archive.length) {
|
|
183
|
+
const header = archive.subarray(offset, offset + 512);
|
|
184
|
+
if (header.every((byte) => byte === 0)) return void 0;
|
|
185
|
+
const field = (start, length) => header.subarray(start, start + length).toString("utf8").replace(/\0.*$/s, "");
|
|
186
|
+
const size = Number.parseInt(field(124, 12).trim() || "0", 8);
|
|
187
|
+
const type = field(156, 1);
|
|
188
|
+
const prefix = field(345, 155);
|
|
189
|
+
const name = longName ?? (prefix ? `${prefix}/${field(0, 100)}` : field(0, 100));
|
|
190
|
+
longName = void 0;
|
|
191
|
+
const body = archive.subarray(offset + 512, offset + 512 + size);
|
|
192
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
193
|
+
if (type === "x") {
|
|
194
|
+
longName = /(?:^|\n)\d+ path=([^\n]*)\n/.exec(body.toString("utf8"))?.[1];
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if ((type === "0" || type === "") && name === wanted) return body;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export { publishedVersions as a, tarEntry as c, publishedVersion as i, packageFile as n, repositoryFiles as o, publishedSource as r, repositoryUrl as s, installedVersion as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as covers, n as registryDir, r as registryEntries } from "./src-uPmBVSsB.mjs";
|