create-portfoliable 1.2.8 → 1.2.10
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
CHANGED
|
@@ -16,7 +16,7 @@ npx create-portfoliable my-site
|
|
|
16
16
|
- installs the runtime dependencies needed for the generated project
|
|
17
17
|
- configures the project structure and base files
|
|
18
18
|
- provides a local dev, build, and preview workflow
|
|
19
|
-
- publishes
|
|
19
|
+
- publishes the canonical package to npm.org and a scoped alias to GitHub Packages
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
@@ -25,10 +25,12 @@ npx create-portfoliable my-site
|
|
|
25
25
|
|
|
26
26
|
## Publishing
|
|
27
27
|
|
|
28
|
-
This package is released through the repository workflow
|
|
28
|
+
This package is released only through the repository workflow. The canonical npm.org identity is `create-portfoliable`, which preserves `npm create portfoliable@latest`. The same version and payload are also published to GitHub Packages as `@portfoliablejs/create-portfoliable`, because GitHub's npm registry requires scoped names.
|
|
29
|
+
|
|
30
|
+
The registries are separate publish targets; publishing to one does not mirror to the other. The release workflow checks each registry before publishing and provides manual recovery modes for a version missing from GitHub Packages or a tagged release missing from npm.org.
|
|
29
31
|
|
|
30
32
|
## License
|
|
31
33
|
|
|
32
34
|
MIT
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
Normal maintainers do not publish this package locally.
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export const NPM_PACKAGE_NAME = 'create-portfoliable';
|
|
6
|
+
export const GITHUB_PACKAGE_NAME = '@portfoliablejs/create-portfoliable';
|
|
7
|
+
export const GITHUB_PACKAGES_REGISTRY = 'https://npm.pkg.github.com';
|
|
8
|
+
|
|
9
|
+
export function prepareGithubPackage(packageDirectory) {
|
|
10
|
+
const packageJsonPath = resolve(packageDirectory, 'package.json');
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
12
|
+
|
|
13
|
+
if (packageJson.name !== NPM_PACKAGE_NAME) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Expected staged package name ${NPM_PACKAGE_NAME} but found ${packageJson.name || '<missing>'}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const githubPackageJson = {
|
|
20
|
+
...packageJson,
|
|
21
|
+
name: GITHUB_PACKAGE_NAME,
|
|
22
|
+
publishConfig: {
|
|
23
|
+
...packageJson.publishConfig,
|
|
24
|
+
registry: GITHUB_PACKAGES_REGISTRY,
|
|
25
|
+
access: 'public',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(githubPackageJson, null, 2)}\n`);
|
|
30
|
+
return githubPackageJson;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const isMainModule =
|
|
34
|
+
typeof process.argv[1] === 'string' &&
|
|
35
|
+
import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
36
|
+
|
|
37
|
+
if (isMainModule) {
|
|
38
|
+
const packageDirectory = process.argv[2];
|
|
39
|
+
|
|
40
|
+
if (!packageDirectory) {
|
|
41
|
+
console.error('Usage: node prepare-github-package.mjs <staged-package-directory>');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const packageJson = prepareGithubPackage(packageDirectory);
|
|
46
|
+
console.log(`Prepared ${packageJson.name}@${packageJson.version} for GitHub Packages.`);
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
GITHUB_PACKAGE_NAME,
|
|
7
|
+
GITHUB_PACKAGES_REGISTRY,
|
|
8
|
+
prepareGithubPackage,
|
|
9
|
+
} from './prepare-github-package.mjs';
|
|
10
|
+
|
|
11
|
+
const temporaryDirectories = [];
|
|
12
|
+
|
|
13
|
+
function createPackageDirectory(packageJson) {
|
|
14
|
+
const packageDirectory = mkdtempSync(join(tmpdir(), 'portfoliable-github-package-'));
|
|
15
|
+
temporaryDirectories.push(packageDirectory);
|
|
16
|
+
writeFileSync(
|
|
17
|
+
join(packageDirectory, 'package.json'),
|
|
18
|
+
`${JSON.stringify(packageJson, null, 2)}\n`
|
|
19
|
+
);
|
|
20
|
+
return packageDirectory;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
for (const directory of temporaryDirectories.splice(0)) {
|
|
25
|
+
rmSync(directory, { recursive: true, force: true });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('GitHub Packages manifest preparation', () => {
|
|
30
|
+
it('rewrites only the staged package identity and registry', () => {
|
|
31
|
+
const sourcePackageJson = {
|
|
32
|
+
name: 'create-portfoliable',
|
|
33
|
+
version: '1.2.10',
|
|
34
|
+
bin: {
|
|
35
|
+
create: 'bin/create-portfoliable.mjs',
|
|
36
|
+
'create-portfoliable': 'bin/create-portfoliable.mjs',
|
|
37
|
+
},
|
|
38
|
+
files: ['bin', 'templates'],
|
|
39
|
+
repository: {
|
|
40
|
+
type: 'git',
|
|
41
|
+
url: 'git+https://github.com/portfoliablejs/portfoliable.git',
|
|
42
|
+
directory: 'create-portfoliable',
|
|
43
|
+
},
|
|
44
|
+
publishConfig: {
|
|
45
|
+
registry: 'https://registry.npmjs.org/',
|
|
46
|
+
access: 'public',
|
|
47
|
+
provenance: true,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const sourceDirectory = createPackageDirectory(sourcePackageJson);
|
|
51
|
+
const stagedDirectory = createPackageDirectory(sourcePackageJson);
|
|
52
|
+
|
|
53
|
+
const preparedPackageJson = prepareGithubPackage(stagedDirectory);
|
|
54
|
+
const persistedPackageJson = JSON.parse(
|
|
55
|
+
readFileSync(join(stagedDirectory, 'package.json'), 'utf8')
|
|
56
|
+
);
|
|
57
|
+
const unchangedSourcePackageJson = JSON.parse(
|
|
58
|
+
readFileSync(join(sourceDirectory, 'package.json'), 'utf8')
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(preparedPackageJson).toEqual(persistedPackageJson);
|
|
62
|
+
expect(persistedPackageJson.name).toBe(GITHUB_PACKAGE_NAME);
|
|
63
|
+
expect(persistedPackageJson.version).toBe(sourcePackageJson.version);
|
|
64
|
+
expect(persistedPackageJson.bin).toEqual(sourcePackageJson.bin);
|
|
65
|
+
expect(persistedPackageJson.files).toEqual(sourcePackageJson.files);
|
|
66
|
+
expect(persistedPackageJson.repository).toEqual(sourcePackageJson.repository);
|
|
67
|
+
expect(persistedPackageJson.publishConfig).toEqual({
|
|
68
|
+
registry: GITHUB_PACKAGES_REGISTRY,
|
|
69
|
+
access: 'public',
|
|
70
|
+
provenance: true,
|
|
71
|
+
});
|
|
72
|
+
expect(unchangedSourcePackageJson).toEqual(sourcePackageJson);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('rejects an unexpected source package identity', () => {
|
|
76
|
+
const stagedDirectory = createPackageDirectory({
|
|
77
|
+
name: '@portfoliablejs/create-portfoliable',
|
|
78
|
+
version: '1.2.10',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(() => prepareGithubPackage(stagedDirectory)).toThrow(
|
|
82
|
+
'Expected staged package name create-portfoliable'
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|