@craftland/ggpm 0.1.0 → 0.1.2
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 +92 -31
- package/bin/ggpm.cjs +8 -1
- package/lib/github-registry.cjs +50 -0
- package/lib/publish.cjs +220 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,31 +1,92 @@
|
|
|
1
|
-
# GG Package Manager
|
|
2
|
-
|
|
3
|
-
Package Manager for Craftland Packages
|
|
4
|
-
|
|
5
|
-
## Install the CLI
|
|
6
|
-
|
|
7
|
-
Once the CLI is published, install it with Node.js and npm:
|
|
8
|
-
|
|
9
|
-
```powershell
|
|
10
|
-
npm install -g @craftland/ggpm
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
# GG Package Manager
|
|
2
|
+
|
|
3
|
+
Package Manager for Craftland Packages
|
|
4
|
+
|
|
5
|
+
## Install the CLI
|
|
6
|
+
|
|
7
|
+
Once the CLI is published, install it with Node.js and npm:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
npm install -g @craftland/ggpm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
npm distributes the CLI. The separate
|
|
14
|
+
[`FF-OGC/ggpm-registry`](https://github.com/FF-OGC/ggpm-registry) GitHub repo
|
|
15
|
+
hosts `registry.json` and the Craftland package ZIPs.
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### `ggpm -v` or `ggpm --version`
|
|
20
|
+
|
|
21
|
+
Print the installed CLI version.
|
|
22
|
+
|
|
23
|
+
### `ggpm publish [path]`
|
|
24
|
+
|
|
25
|
+
Run `ggpm publish path/to/package` to publish a specific package folder.
|
|
26
|
+
The path can be absolute or relative to your current directory. With no path,
|
|
27
|
+
`ggpm publish` uses the current directory. The selected folder must contain
|
|
28
|
+
`ggpackage.json`.
|
|
29
|
+
The manifest needs a `Namespace/Name` package name and an exact SemVer version.
|
|
30
|
+
Declare dependencies as exact version pins and publish those versions first.
|
|
31
|
+
|
|
32
|
+
Set `GGPM_GITHUB_TOKEN` to a GitHub token with **Contents: Read and write**
|
|
33
|
+
access to `FF-OGC/ggpm-registry`, including permission to update `registry.json`
|
|
34
|
+
on the default branch. For example, from PowerShell 7:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
$env:GGPM_GITHUB_TOKEN = Read-Host -MaskInput 'GitHub token'
|
|
38
|
+
ggpm publish
|
|
39
|
+
Remove-Item Env:GGPM_GITHUB_TOKEN
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For `GG/Login@1.0.0`, the command:
|
|
43
|
+
|
|
44
|
+
1. Validates the manifest and confirms that its dependencies are already in
|
|
45
|
+
the registry and that this version is available to publish.
|
|
46
|
+
2. Creates a ZIP with `ggpackage.json` at its root, preserves the package's
|
|
47
|
+
file paths, and calculates the ZIP's SHA-256 checksum. Dotfiles and dot
|
|
48
|
+
directories, `node_modules`, OS metadata, and ZIP and TGZ files in the root
|
|
49
|
+
are excluded.
|
|
50
|
+
3. Creates the `GG/Login 1.0.0` GitHub Release with tag `gg-login-v1.0.0` and
|
|
51
|
+
uploads `gg-login-1.0.0.zip` as its asset.
|
|
52
|
+
4. Verifies the uploaded ZIP and commits its URL, asset ID, checksum, and
|
|
53
|
+
dependencies to `registry.json`. If another publish updated the catalog in
|
|
54
|
+
the meantime, the command reloads it and retries the merge.
|
|
55
|
+
|
|
56
|
+
If the ZIP upload succeeds but the catalog update fails, rerun `ggpm publish`
|
|
57
|
+
with the same package files. It reuses the uploaded ZIP when the checksum
|
|
58
|
+
matches. For a version already listed in the catalog, bump the version in
|
|
59
|
+
`ggpackage.json` before publishing again.
|
|
60
|
+
|
|
61
|
+
## Publish a CLI release
|
|
62
|
+
|
|
63
|
+
Add `NPM_TOKEN` under **Settings → Secrets and variables → Actions** in the
|
|
64
|
+
GitHub repository. Use an npm granular token with publish access to
|
|
65
|
+
`@craftland/ggpm` and **Bypass 2FA** enabled. The project's `.npmrc` reads the
|
|
66
|
+
token from the environment.
|
|
67
|
+
|
|
68
|
+
Commit your changes, including the publish workflow, before creating the tag.
|
|
69
|
+
For example, to release `0.1.1` from `0.1.0`:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
npm version patch
|
|
73
|
+
git push origin HEAD
|
|
74
|
+
git push origin v0.1.1
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The tag push starts **Publish ggpm to npm** in the repository's Actions tab.
|
|
78
|
+
The workflow checks that the tag matches the version in `package.json` before
|
|
79
|
+
publishing.
|
|
80
|
+
|
|
81
|
+
## Planned commands
|
|
82
|
+
|
|
83
|
+
- `ggpm list` shows available packages and their latest versions.
|
|
84
|
+
- `ggpm init` creates `ggpackage.json` at the root of a Craftland project.
|
|
85
|
+
- `ggpm install` installs the packages declared in the project manifest.
|
|
86
|
+
- `ggpm install <package-name> [version]` installs a package and records it in
|
|
87
|
+
the project manifest. Omitting the version selects the latest stable release.
|
|
88
|
+
- `ggpm update` updates installed packages to match the versions in the
|
|
89
|
+
project manifest.
|
|
90
|
+
|
|
91
|
+
## Note
|
|
92
|
+
Reference example packages for a package
|
package/bin/ggpm.cjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const { resolve } = require('node:path');
|
|
3
4
|
const { version } = require('../package.json');
|
|
4
5
|
|
|
5
6
|
const [flag, ...extraArgs] = process.argv.slice(2);
|
|
6
7
|
|
|
7
8
|
if (extraArgs.length === 0 && (flag === '-v' || flag === '--version')) {
|
|
8
9
|
console.log(version);
|
|
10
|
+
} else if (flag === 'publish' && extraArgs.length <= 1) {
|
|
11
|
+
const [packagePath = '.'] = extraArgs;
|
|
12
|
+
require('../lib/publish.cjs').publish(resolve(packagePath)).catch((error) => {
|
|
13
|
+
console.error(`ggpm publish: ${error.message}`);
|
|
14
|
+
process.exitCode = 1;
|
|
15
|
+
});
|
|
9
16
|
} else {
|
|
10
|
-
console.error('Usage: ggpm -v | ggpm --version');
|
|
17
|
+
console.error('Usage: ggpm -v | ggpm --version | ggpm publish [path]');
|
|
11
18
|
process.exitCode = 1;
|
|
12
19
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const registryRepo = 'FF-OGC/ggpm-registry';
|
|
2
|
+
|
|
3
|
+
function githubRegistry(token) {
|
|
4
|
+
async function request(path, { method = 'GET', json, bytes, upload = false } = {}) {
|
|
5
|
+
const host = upload ? 'uploads.github.com' : 'api.github.com';
|
|
6
|
+
const response = await fetch(`https://${host}/repos/${registryRepo}${path}`, {
|
|
7
|
+
method,
|
|
8
|
+
headers: {
|
|
9
|
+
accept: 'application/vnd.github+json',
|
|
10
|
+
authorization: `Bearer ${token}`,
|
|
11
|
+
'x-github-api-version': '2026-03-10',
|
|
12
|
+
...(json ? { 'content-type': 'application/json' } : {}),
|
|
13
|
+
...(bytes ? { 'content-type': 'application/zip' } : {}),
|
|
14
|
+
},
|
|
15
|
+
body: json ? JSON.stringify(json) : bytes,
|
|
16
|
+
redirect: 'error',
|
|
17
|
+
signal: AbortSignal.timeout(120_000),
|
|
18
|
+
}).catch((error) => {
|
|
19
|
+
throw new Error(`GitHub ${method} ${path} failed: ${error.cause?.message ?? error.message}`);
|
|
20
|
+
});
|
|
21
|
+
const result = await response.json().catch(() => null);
|
|
22
|
+
if (!response.ok) {
|
|
23
|
+
const detail = result?.message ?? response.statusText;
|
|
24
|
+
throw Object.assign(new Error(`GitHub ${method} ${path} (${response.status}): ${detail}`), {
|
|
25
|
+
status: response.status,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
getIndex: () => request('/contents/registry.json'),
|
|
33
|
+
updateIndex: (json) => request('/contents/registry.json', { method: 'PUT', json }),
|
|
34
|
+
async findRelease(tag) {
|
|
35
|
+
try {
|
|
36
|
+
return await request(`/releases/tags/${encodeURIComponent(tag)}`);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.status === 404) return null;
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
createRelease: (json) => request('/releases', { method: 'POST', json }),
|
|
43
|
+
uploadZip: (releaseId, name, bytes) => request(
|
|
44
|
+
`/releases/${releaseId}/assets?${new URLSearchParams({ name })}`,
|
|
45
|
+
{ method: 'POST', bytes, upload: true },
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = { githubRegistry, registryRepo };
|
package/lib/publish.cjs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
const { createHash } = require('node:crypto');
|
|
2
|
+
const { lstat, readFile, readdir } = require('node:fs/promises');
|
|
3
|
+
const { join } = require('node:path');
|
|
4
|
+
const { Zip, ZipDeflate } = require('fflate');
|
|
5
|
+
const { githubRegistry, registryRepo } = require('./github-registry.cjs');
|
|
6
|
+
|
|
7
|
+
const manifestFile = 'ggpackage.json';
|
|
8
|
+
const packageName = /^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/i;
|
|
9
|
+
const versionPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([a-z\d-]+(?:\.[a-z\d-]+)*))?(?:\+[a-z\d-]+(?:\.[a-z\d-]+)*)?$/i;
|
|
10
|
+
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
11
|
+
|
|
12
|
+
function parseVersion(value) {
|
|
13
|
+
if (typeof value !== 'string' || value !== value.trim()) return null;
|
|
14
|
+
const match = versionPattern.exec(value);
|
|
15
|
+
if (!match || match[4]?.split('.').some((part) => /^0\d+$/.test(part))) return null;
|
|
16
|
+
return { prerelease: Boolean(match[4]) };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseJson(bytes, label) {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(bytes.toString('utf8').replace(/^\uFEFF/, ''));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new Error(`${label} is not valid JSON: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function loadPackage(root) {
|
|
28
|
+
const path = join(root, manifestFile);
|
|
29
|
+
const info = await lstat(path).catch((error) => {
|
|
30
|
+
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {
|
|
31
|
+
throw new Error(`Could not find ${manifestFile} in package folder ${root}.`);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
});
|
|
35
|
+
if (!info.isFile()) throw new Error(`${manifestFile} must be a regular file.`);
|
|
36
|
+
|
|
37
|
+
const bytes = await readFile(path);
|
|
38
|
+
const manifest = parseJson(bytes, manifestFile);
|
|
39
|
+
if (!isObject(manifest)) throw new Error(`${manifestFile} must contain an object.`);
|
|
40
|
+
|
|
41
|
+
const { name, version, dependencies = {} } = manifest;
|
|
42
|
+
if (typeof name !== 'string' || name !== name.trim() || !packageName.test(name)) {
|
|
43
|
+
throw new Error(`${manifestFile} needs a package name in Namespace/Name format, such as GG/Login.`);
|
|
44
|
+
}
|
|
45
|
+
const parsed = parseVersion(version);
|
|
46
|
+
if (!parsed) throw new Error(`${manifestFile} needs an exact SemVer version, such as 1.0.0.`);
|
|
47
|
+
if (!isObject(dependencies)) throw new Error(`${manifestFile} dependencies must be an object.`);
|
|
48
|
+
for (const [dependency, pin] of Object.entries(dependencies)) {
|
|
49
|
+
if (dependency !== dependency.trim() || !packageName.test(dependency) || !parseVersion(pin)) {
|
|
50
|
+
throw new Error(`Invalid dependency ${JSON.stringify(dependency)}. Use Namespace/Name and an exact version.`);
|
|
51
|
+
}
|
|
52
|
+
if (dependency.toLowerCase() === name.toLowerCase()) {
|
|
53
|
+
throw new Error(`${name} cannot depend on itself.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Escape separators within a name segment so A-B/C and A/B-C produce distinct tags.
|
|
58
|
+
const slug = name.toLowerCase().split('/').map((part) =>
|
|
59
|
+
part.replace(/[^a-z0-9]/g, (character) => `_${character.charCodeAt(0).toString(16)}`),
|
|
60
|
+
).join('-');
|
|
61
|
+
return {
|
|
62
|
+
name, version, dependencies, bytes, prerelease: parsed.prerelease,
|
|
63
|
+
description: typeof manifest.description === 'string' ? manifest.description : '',
|
|
64
|
+
tag: `${slug}-v${version}`,
|
|
65
|
+
assetName: `${slug}-${version.replace('+', '_')}.zip`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function archivePackage(root, manifest) {
|
|
70
|
+
const chunks = [];
|
|
71
|
+
const zip = new Zip((error, data) => {
|
|
72
|
+
if (error) throw error;
|
|
73
|
+
chunks.push(data);
|
|
74
|
+
});
|
|
75
|
+
// Stable timestamps and entry order let an unchanged package reuse an uploaded ZIP.
|
|
76
|
+
const mtime = new Date(2000, 0, 1, 12);
|
|
77
|
+
|
|
78
|
+
function addFile(name, bytes) {
|
|
79
|
+
const file = new ZipDeflate(name);
|
|
80
|
+
file.mtime = mtime;
|
|
81
|
+
zip.add(file);
|
|
82
|
+
file.push(bytes, true);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function addFolder(folder, prefix = '') {
|
|
86
|
+
const entries = await readdir(folder, { withFileTypes: true });
|
|
87
|
+
entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
const { name } = entry;
|
|
90
|
+
const lowerName = name.toLowerCase();
|
|
91
|
+
if (name.startsWith('.') || ['node_modules', '__macosx', 'thumbs.db', 'desktop.ini'].includes(lowerName)) continue;
|
|
92
|
+
if (!prefix && (lowerName === manifestFile || /\.(zip|tgz)$/i.test(name))) continue;
|
|
93
|
+
|
|
94
|
+
const path = join(folder, name);
|
|
95
|
+
const archivePath = `${prefix}${name}`;
|
|
96
|
+
if (/[\\:<>"|?*]/.test(name)) throw new Error(`Invalid Windows package path: ${archivePath}`);
|
|
97
|
+
if (entry.isDirectory()) await addFolder(path, `${archivePath}/`);
|
|
98
|
+
else if (entry.isFile()) addFile(archivePath, await readFile(path));
|
|
99
|
+
else throw new Error(`Cannot package ${archivePath}: expected a regular file or directory.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
addFile(manifestFile, manifest.bytes);
|
|
104
|
+
await addFolder(root);
|
|
105
|
+
zip.end();
|
|
106
|
+
return Buffer.concat(chunks);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function readIndex(registry) {
|
|
110
|
+
const file = await registry.getIndex();
|
|
111
|
+
if (!file?.sha || file.encoding !== 'base64' || typeof file.content !== 'string') {
|
|
112
|
+
throw new Error(`Expected registry.json on the default branch of ${registryRepo}.`);
|
|
113
|
+
}
|
|
114
|
+
const index = parseJson(Buffer.from(file.content, 'base64'), 'registry.json');
|
|
115
|
+
if (index?.schemaVersion !== 1 || !isObject(index.packages)) {
|
|
116
|
+
throw new Error('registry.json must have schemaVersion 1 and a packages object.');
|
|
117
|
+
}
|
|
118
|
+
return { sha: file.sha, index };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function packageRecord(index, { name, dependencies }) {
|
|
122
|
+
const existingName = Object.keys(index.packages).find((key) => key.toLowerCase() === name.toLowerCase());
|
|
123
|
+
if (existingName && existingName !== name) {
|
|
124
|
+
throw new Error(`Use the existing registry spelling ${existingName} instead of ${name}.`);
|
|
125
|
+
}
|
|
126
|
+
const record = index.packages[name] ?? { versions: {} };
|
|
127
|
+
if (!isObject(record.versions)) throw new Error(`Invalid versions object for ${name} in registry.json.`);
|
|
128
|
+
for (const [dependency, pin] of Object.entries(dependencies)) {
|
|
129
|
+
const versions = index.packages[dependency]?.versions;
|
|
130
|
+
if (!isObject(versions) || !Object.hasOwn(versions, pin)) {
|
|
131
|
+
throw new Error(`Publish ${dependency}@${pin} before publishing ${name}.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return record;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function publishAsset(registry, manifest, archive, sha256) {
|
|
138
|
+
const { tag, assetName, name, version, prerelease } = manifest;
|
|
139
|
+
let release = await registry.findRelease(tag);
|
|
140
|
+
if (!release) {
|
|
141
|
+
try {
|
|
142
|
+
release = await registry.createRelease({ tag_name: tag, name: `${name} ${version}`, prerelease, make_latest: 'false' });
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.status !== 422) throw error;
|
|
145
|
+
release = await registry.findRelease(tag);
|
|
146
|
+
if (!release) throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (!release?.id || release.draft) throw new Error(`Release ${tag} must be published before use.`);
|
|
150
|
+
|
|
151
|
+
let asset = release.assets?.find((item) => item.name === assetName);
|
|
152
|
+
if (!asset) {
|
|
153
|
+
try {
|
|
154
|
+
asset = await registry.uploadZip(release.id, assetName, archive);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error.status !== 422) throw error;
|
|
157
|
+
release = await registry.findRelease(tag);
|
|
158
|
+
asset = release?.assets?.find((item) => item.name === assetName);
|
|
159
|
+
if (!asset) throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (asset?.state === 'starter') {
|
|
163
|
+
throw new Error(`Release ${tag} has an incomplete upload for ${assetName}. Remove the empty asset on GitHub and retry.`);
|
|
164
|
+
}
|
|
165
|
+
if (asset?.state !== 'uploaded' || asset.digest !== `sha256:${sha256}` || !asset.id || !asset.browser_download_url) {
|
|
166
|
+
throw new Error(`Could not verify the uploaded ZIP for ${tag}. Existing assets are never overwritten.`);
|
|
167
|
+
}
|
|
168
|
+
return { releaseTag: tag, assetId: asset.id, url: asset.browser_download_url, sha256 };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function updateIndex(registry, snapshot, manifest, asset) {
|
|
172
|
+
const { name, version, dependencies, description } = manifest;
|
|
173
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
174
|
+
const { index, sha } = snapshot;
|
|
175
|
+
const record = packageRecord(index, manifest);
|
|
176
|
+
if (Object.hasOwn(record.versions, version)) {
|
|
177
|
+
const existing = record.versions[version];
|
|
178
|
+
if (existing?.sha256 === asset.sha256 && existing.assetId === asset.assetId) return;
|
|
179
|
+
throw new Error(`${name}@${version} already exists in the registry. Bump the package version.`);
|
|
180
|
+
}
|
|
181
|
+
record.versions[version] = { ...asset, dependencies, ...(description ? { description } : {}) };
|
|
182
|
+
index.packages[name] = record;
|
|
183
|
+
try {
|
|
184
|
+
await registry.updateIndex({
|
|
185
|
+
sha,
|
|
186
|
+
message: `Publish ${name}@${version}`,
|
|
187
|
+
content: Buffer.from(`${JSON.stringify(index, null, 2)}\n`).toString('base64'),
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
if (![409, 422].includes(error.status) || attempt === 2) throw error;
|
|
192
|
+
snapshot = await readIndex(registry);
|
|
193
|
+
if (snapshot.sha === sha) throw error;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function publish(root, token = process.env.GGPM_GITHUB_TOKEN?.trim()) {
|
|
199
|
+
const manifest = await loadPackage(root);
|
|
200
|
+
if (!token) throw new Error(`Set GGPM_GITHUB_TOKEN with Contents write access to ${registryRepo}.`);
|
|
201
|
+
|
|
202
|
+
const registry = githubRegistry(token);
|
|
203
|
+
const snapshot = await readIndex(registry);
|
|
204
|
+
const { name, version, tag } = manifest;
|
|
205
|
+
if (Object.hasOwn(packageRecord(snapshot.index, manifest).versions, version)) {
|
|
206
|
+
throw new Error(`${name}@${version} already exists in the registry. Bump the package version.`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const archive = await archivePackage(root, manifest);
|
|
210
|
+
const sha256 = createHash('sha256').update(archive).digest('hex');
|
|
211
|
+
const asset = await publishAsset(registry, manifest, archive, sha256);
|
|
212
|
+
try {
|
|
213
|
+
await updateIndex(registry, snapshot, manifest, asset);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
throw new Error(`The ZIP is available on release ${tag}, but registry.json could not be updated. Rerun ggpm publish with the same package files. ${error.message}`);
|
|
216
|
+
}
|
|
217
|
+
console.log(`Published ${name}@${version} to ${registryRepo}\n${asset.url}`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = { publish };
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craftland/ggpm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Package manager for Craftland projects",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ggpm": "bin/ggpm.cjs"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
|
-
"bin/ggpm.cjs"
|
|
9
|
+
"bin/ggpm.cjs",
|
|
10
|
+
"lib/"
|
|
10
11
|
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
11
15
|
"publishConfig": {
|
|
12
16
|
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"fflate": "0.8.3"
|
|
13
20
|
}
|
|
14
21
|
}
|