@wpelevator/wp-release 0.14.0 → 0.16.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/README.md +256 -36
- package/dist/changeset-config.d.ts +3 -0
- package/dist/changeset-release.d.ts +9 -3
- package/dist/changeset-release.js +23 -14
- package/dist/cli.d.ts +17 -7
- package/dist/cli.js +27 -2
- package/dist/commands/args.d.ts +11 -0
- package/dist/commands/args.js +23 -0
- package/dist/commands/artifact-signing.d.ts +20 -0
- package/dist/commands/artifact-signing.js +42 -0
- package/dist/commands/build.d.ts +32 -0
- package/dist/commands/build.js +91 -0
- package/dist/commands/changeset-add.d.ts +55 -6
- package/dist/commands/changeset-add.js +12 -3
- package/dist/commands/changeset-args.js +2 -2
- package/dist/commands/changeset-project-args.d.ts +63 -0
- package/dist/commands/changeset-project-args.js +114 -0
- package/dist/commands/changeset-status.d.ts +50 -1
- package/dist/commands/changeset-status.js +4 -2
- package/dist/commands/changeset-tag.d.ts +55 -6
- package/dist/commands/changeset-tag.js +7 -4
- package/dist/commands/changeset-version.d.ts +55 -6
- package/dist/commands/changeset-version.js +4 -2
- package/dist/commands/checksums.d.ts +4 -1
- package/dist/commands/checksums.js +27 -6
- package/dist/commands/command.d.ts +3 -0
- package/dist/commands/deploy-svn.d.ts +11 -15
- package/dist/commands/deploy-svn.js +25 -5
- package/dist/commands/package-source.d.ts +43 -0
- package/dist/commands/package-source.js +101 -0
- package/dist/commands/sign.d.ts +0 -9
- package/dist/commands/sign.js +10 -47
- package/dist/commands/verify.d.ts +7 -1
- package/dist/commands/verify.js +53 -17
- package/dist/commands/zip.d.ts +25 -2
- package/dist/commands/zip.js +136 -110
- package/dist/index.d.ts +9 -2
- package/dist/index.js +3 -1
- package/dist/integrity.d.ts +33 -0
- package/dist/integrity.js +115 -0
- package/dist/output-files.d.ts +7 -0
- package/dist/output-files.js +25 -0
- package/dist/package-build.d.ts +33 -0
- package/dist/package-build.js +112 -0
- package/dist/package-files.d.ts +25 -0
- package/dist/package-files.js +24 -0
- package/dist/package-zip.d.ts +14 -2
- package/dist/package-zip.js +129 -38
- package/dist/release-tags.js +6 -0
- package/dist/signing.d.ts +36 -0
- package/dist/signing.js +52 -1
- package/dist/single-project.d.ts +32 -0
- package/dist/single-project.js +144 -0
- package/dist/summary.d.ts +9 -0
- package/dist/summary.js +25 -0
- package/dist/zip.d.ts +3 -0
- package/dist/zip.js +16 -6
- package/package.json +6 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { packageJsonVersion, composerJsonVersion, wordpressPluginVersion, wordpressThemeVersion, wordpressStableTag, phpConstantVersion, gitTagVersion, } from "../changeset-config.js";
|
|
2
|
+
import { ValidationError } from "../errors.js";
|
|
3
|
+
import { getBoolean, getString, getStrings } from "./command.js";
|
|
4
|
+
export const changesetProjectArgs = {
|
|
5
|
+
'version-package-json': { type: 'string', multiple: true },
|
|
6
|
+
'version-composer-json': { type: 'string', multiple: true },
|
|
7
|
+
'version-wordpress-plugin': { type: 'string', multiple: true },
|
|
8
|
+
'version-wordpress-theme': { type: 'string', multiple: true },
|
|
9
|
+
'version-wordpress-stable-tag': { type: 'string', multiple: true },
|
|
10
|
+
'version-php-constant': { type: 'string', multiple: true },
|
|
11
|
+
'version-git-tag': { type: 'string', multiple: true },
|
|
12
|
+
'version-from': { type: 'string' },
|
|
13
|
+
'base-branch': { type: 'string' },
|
|
14
|
+
remote: { type: 'string' },
|
|
15
|
+
'changesets-dir': { type: 'string' },
|
|
16
|
+
'readme-changelog': { type: 'boolean' },
|
|
17
|
+
'no-readme-changelog': { type: 'boolean' },
|
|
18
|
+
'changelog-insert-after': { type: 'string' },
|
|
19
|
+
};
|
|
20
|
+
export const changesetProjectHelp = `
|
|
21
|
+
Single-project options (without a release config file):
|
|
22
|
+
--version-package-json <file> npm version source/target (repeatable)
|
|
23
|
+
--version-composer-json <file> Composer source/target (repeatable)
|
|
24
|
+
--version-wordpress-plugin <file> Plugin header source/target (repeatable)
|
|
25
|
+
--version-wordpress-theme <file> Theme header source/target (repeatable)
|
|
26
|
+
--version-wordpress-stable-tag <file> Readme Stable tag source/target (repeatable)
|
|
27
|
+
--version-php-constant <file>#<constant> PHP constant source/target (repeatable)
|
|
28
|
+
--version-git-tag <pattern> Git tag source only; use {version}
|
|
29
|
+
--version-from <kind>[:<file>] Choose the source; constants use file#constant
|
|
30
|
+
--base-branch <branch> Default comparison branch on the remote
|
|
31
|
+
--remote <name> Git remote (default: origin)
|
|
32
|
+
--changesets-dir <dir> Changeset directory (default: .changeset)
|
|
33
|
+
--readme-changelog / --no-readme-changelog
|
|
34
|
+
Enable/disable readme changelog updates
|
|
35
|
+
--changelog-insert-after <marker> Insert changelog entries after this marker
|
|
36
|
+
|
|
37
|
+
Explicit descriptors define all version targets. Without them, detect one root
|
|
38
|
+
project. A unique non-Stable-tag descriptor is the inferred source; otherwise
|
|
39
|
+
pass --version-from, qualifying it with :file when its kind is repeated.
|
|
40
|
+
Use the same project options for every changeset command.`;
|
|
41
|
+
/**
|
|
42
|
+
* Parse shared single-project settings; operation flags stay command-specific.
|
|
43
|
+
*
|
|
44
|
+
* @param values Parsed command arguments.
|
|
45
|
+
* @return Fallback settings when explicitly supplied.
|
|
46
|
+
*/
|
|
47
|
+
export function parseChangesetProjectArgs(values) {
|
|
48
|
+
const options = {};
|
|
49
|
+
const versions = [];
|
|
50
|
+
const factories = {
|
|
51
|
+
'package-json': packageJsonVersion,
|
|
52
|
+
'composer-json': composerJsonVersion,
|
|
53
|
+
'wordpress-plugin': wordpressPluginVersion,
|
|
54
|
+
'wordpress-theme': wordpressThemeVersion,
|
|
55
|
+
'wordpress-stable-tag': wordpressStableTag,
|
|
56
|
+
};
|
|
57
|
+
for (const [kind, factory] of Object.entries(factories)) {
|
|
58
|
+
for (const file of getStrings(values, `version-${kind}`)) {
|
|
59
|
+
if (!file.trim()) {
|
|
60
|
+
throw new ValidationError(`--version-${kind} <file> must not be empty.`);
|
|
61
|
+
}
|
|
62
|
+
versions.push(factory({ file }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const value of getStrings(values, 'version-php-constant')) {
|
|
66
|
+
const separator = value.lastIndexOf('#');
|
|
67
|
+
const file = value.slice(0, separator);
|
|
68
|
+
const constant = value.slice(separator + 1);
|
|
69
|
+
if (separator < 1 ||
|
|
70
|
+
!file.trim() ||
|
|
71
|
+
!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(constant)) {
|
|
72
|
+
throw new ValidationError('--version-php-constant must be <file>#<constant>, for example plugin.php#PLUGIN_VERSION.');
|
|
73
|
+
}
|
|
74
|
+
versions.push(phpConstantVersion({ file, constant }));
|
|
75
|
+
}
|
|
76
|
+
const patterns = getStrings(values, 'version-git-tag');
|
|
77
|
+
if (patterns.length > 1) {
|
|
78
|
+
throw new ValidationError('--version-git-tag accepts one source pattern.');
|
|
79
|
+
}
|
|
80
|
+
for (const pattern of patterns) {
|
|
81
|
+
if (!pattern.trim() || !pattern.includes('{version}')) {
|
|
82
|
+
throw new ValidationError('--version-git-tag <pattern> must contain {version}.');
|
|
83
|
+
}
|
|
84
|
+
versions.push(gitTagVersion({ pattern }));
|
|
85
|
+
}
|
|
86
|
+
if (versions.length) {
|
|
87
|
+
options.versions = versions;
|
|
88
|
+
}
|
|
89
|
+
const strings = {
|
|
90
|
+
'version-from': 'versionFrom',
|
|
91
|
+
'base-branch': 'baseBranch',
|
|
92
|
+
remote: 'remote',
|
|
93
|
+
'changesets-dir': 'changesets',
|
|
94
|
+
'changelog-insert-after': 'changelogInsertAfter',
|
|
95
|
+
};
|
|
96
|
+
for (const [flag, key] of Object.entries(strings)) {
|
|
97
|
+
const value = getString(values, flag);
|
|
98
|
+
if (undefined !== value) {
|
|
99
|
+
if (!value.trim()) {
|
|
100
|
+
throw new ValidationError(`--${flag} must not be empty.`);
|
|
101
|
+
}
|
|
102
|
+
options[key] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (getBoolean(values, 'readme-changelog') &&
|
|
106
|
+
getBoolean(values, 'no-readme-changelog')) {
|
|
107
|
+
throw new ValidationError('--readme-changelog cannot be combined with --no-readme-changelog.');
|
|
108
|
+
}
|
|
109
|
+
if (getBoolean(values, 'readme-changelog') ||
|
|
110
|
+
getBoolean(values, 'no-readme-changelog')) {
|
|
111
|
+
options.readmeChangelog = getBoolean(values, 'readme-changelog');
|
|
112
|
+
}
|
|
113
|
+
return Object.keys(options).length ? { singleProject: options } : {};
|
|
114
|
+
}
|
|
@@ -22,7 +22,56 @@ declare const _default: {
|
|
|
22
22
|
summary: string;
|
|
23
23
|
help: string;
|
|
24
24
|
options: {
|
|
25
|
-
|
|
25
|
+
'version-package-json': {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly multiple: true;
|
|
28
|
+
};
|
|
29
|
+
'version-composer-json': {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly multiple: true;
|
|
32
|
+
};
|
|
33
|
+
'version-wordpress-plugin': {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
readonly multiple: true;
|
|
36
|
+
};
|
|
37
|
+
'version-wordpress-theme': {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly multiple: true;
|
|
40
|
+
};
|
|
41
|
+
'version-wordpress-stable-tag': {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly multiple: true;
|
|
44
|
+
};
|
|
45
|
+
'version-php-constant': {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly multiple: true;
|
|
48
|
+
};
|
|
49
|
+
'version-git-tag': {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly multiple: true;
|
|
52
|
+
};
|
|
53
|
+
'version-from': {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
};
|
|
56
|
+
'base-branch': {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
};
|
|
59
|
+
remote: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
};
|
|
62
|
+
'changesets-dir': {
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
};
|
|
65
|
+
'readme-changelog': {
|
|
66
|
+
readonly type: "boolean";
|
|
67
|
+
};
|
|
68
|
+
'no-readme-changelog': {
|
|
69
|
+
readonly type: "boolean";
|
|
70
|
+
};
|
|
71
|
+
'changelog-insert-after': {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
};
|
|
74
|
+
since: {
|
|
26
75
|
readonly type: "string";
|
|
27
76
|
};
|
|
28
77
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changesetProjectArgs, changesetProjectHelp, parseChangesetProjectArgs, } from "./changeset-project-args.js";
|
|
1
2
|
import { getChangesetStatus } from "../changeset-release.js";
|
|
2
3
|
import { changesetStatusArgs, parseChangesetStatusArgs, } from "./changeset-args.js";
|
|
3
4
|
export default {
|
|
@@ -8,12 +9,13 @@ export default {
|
|
|
8
9
|
--since <ref> Compare changed files with this git ref (for CI)
|
|
9
10
|
|
|
10
11
|
Exit status is 2 when a changed package has no changeset added since the comparison base.
|
|
11
|
-
An empty changeset added since the comparison base counts as an explicit no-release decision
|
|
12
|
-
options: changesetStatusArgs,
|
|
12
|
+
An empty changeset added since the comparison base counts as an explicit no-release decision.${changesetProjectHelp}`,
|
|
13
|
+
options: { ...changesetStatusArgs, ...changesetProjectArgs },
|
|
13
14
|
async run({ values, cwd, configFile, tagFormat, logger }) {
|
|
14
15
|
const { since } = parseChangesetStatusArgs(values);
|
|
15
16
|
const result = await getChangesetStatus({
|
|
16
17
|
cwd,
|
|
18
|
+
...parseChangesetProjectArgs(values),
|
|
17
19
|
...(configFile ? { configFile } : {}),
|
|
18
20
|
...(tagFormat ? { tagFormat } : {}),
|
|
19
21
|
...(since ? { since } : {}),
|
|
@@ -4,23 +4,72 @@ declare const _default: {
|
|
|
4
4
|
summary: string;
|
|
5
5
|
help: string;
|
|
6
6
|
options: {
|
|
7
|
-
|
|
7
|
+
'version-package-json': {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly multiple: true;
|
|
10
|
+
};
|
|
11
|
+
'version-composer-json': {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly multiple: true;
|
|
14
|
+
};
|
|
15
|
+
'version-wordpress-plugin': {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly multiple: true;
|
|
18
|
+
};
|
|
19
|
+
'version-wordpress-theme': {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly multiple: true;
|
|
22
|
+
};
|
|
23
|
+
'version-wordpress-stable-tag': {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly multiple: true;
|
|
26
|
+
};
|
|
27
|
+
'version-php-constant': {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly multiple: true;
|
|
30
|
+
};
|
|
31
|
+
'version-git-tag': {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly multiple: true;
|
|
34
|
+
};
|
|
35
|
+
'version-from': {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
};
|
|
38
|
+
'base-branch': {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
};
|
|
41
|
+
remote: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
};
|
|
44
|
+
'changesets-dir': {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
};
|
|
47
|
+
'readme-changelog': {
|
|
48
|
+
readonly type: "boolean";
|
|
49
|
+
};
|
|
50
|
+
'no-readme-changelog': {
|
|
51
|
+
readonly type: "boolean";
|
|
52
|
+
};
|
|
53
|
+
'changelog-insert-after': {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
};
|
|
56
|
+
push: {
|
|
8
57
|
readonly type: "boolean";
|
|
9
58
|
};
|
|
10
|
-
|
|
59
|
+
'dry-run': {
|
|
11
60
|
readonly type: "boolean";
|
|
12
61
|
};
|
|
13
|
-
|
|
62
|
+
untagged: {
|
|
14
63
|
readonly type: "boolean";
|
|
15
64
|
};
|
|
16
|
-
|
|
65
|
+
since: {
|
|
17
66
|
readonly type: "string";
|
|
18
67
|
};
|
|
19
|
-
|
|
68
|
+
package: {
|
|
20
69
|
readonly type: "string";
|
|
21
70
|
readonly multiple: true;
|
|
22
71
|
};
|
|
23
|
-
|
|
72
|
+
version: {
|
|
24
73
|
readonly type: "string";
|
|
25
74
|
};
|
|
26
75
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changesetProjectArgs, changesetProjectHelp, parseChangesetProjectArgs, } from "./changeset-project-args.js";
|
|
1
2
|
import { tagChangesets } from "../changeset-release.js";
|
|
2
3
|
import { parseChangesetTagArgs, changesetTagArgs } from "./changeset-args.js";
|
|
3
4
|
import { getChangesetTagSummary, getTagStatus } from "../summary.js";
|
|
@@ -12,8 +13,9 @@ export default {
|
|
|
12
13
|
--since <ref> Tag packages changed since this git ref
|
|
13
14
|
--package <name> Tag only this package, by identifier or path under
|
|
14
15
|
the configured root (repeatable)
|
|
15
|
-
--version <version> Fail unless the
|
|
16
|
-
the version to tag for packages versioned by git tags
|
|
16
|
+
--version <version> Fail unless the selected package is at this version;
|
|
17
|
+
the version to tag for packages versioned by git tags.
|
|
18
|
+
A sole root package is selected without --package
|
|
17
19
|
--push Push newly created tags to the configured remote
|
|
18
20
|
(default: origin), one at a time
|
|
19
21
|
|
|
@@ -22,12 +24,13 @@ safe. Before a tag is created, every configured version target must match the
|
|
|
22
24
|
version. With --json or --github-output, each tag comes with the title, notes
|
|
23
25
|
and pre-release flag of its release, for a workflow step that creates the
|
|
24
26
|
GitHub Release. --untagged lists only the releases that still need a tag, for
|
|
25
|
-
example to release each of them with a separate workflow
|
|
26
|
-
options: changesetTagArgs,
|
|
27
|
+
example to release each of them with a separate workflow.${changesetProjectHelp}`,
|
|
28
|
+
options: { ...changesetTagArgs, ...changesetProjectArgs },
|
|
27
29
|
async run({ values, cwd, configFile, tagFormat, logger }) {
|
|
28
30
|
const args = parseChangesetTagArgs(values);
|
|
29
31
|
const result = await tagChangesets({
|
|
30
32
|
cwd,
|
|
33
|
+
...parseChangesetProjectArgs(values),
|
|
31
34
|
...(configFile ? { configFile } : {}),
|
|
32
35
|
...(tagFormat ? { tagFormat } : {}),
|
|
33
36
|
...args,
|
|
@@ -16,23 +16,72 @@ declare const _default: {
|
|
|
16
16
|
summary: string;
|
|
17
17
|
help: string;
|
|
18
18
|
options: {
|
|
19
|
-
|
|
19
|
+
'version-package-json': {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly multiple: true;
|
|
22
|
+
};
|
|
23
|
+
'version-composer-json': {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly multiple: true;
|
|
26
|
+
};
|
|
27
|
+
'version-wordpress-plugin': {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly multiple: true;
|
|
30
|
+
};
|
|
31
|
+
'version-wordpress-theme': {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly multiple: true;
|
|
34
|
+
};
|
|
35
|
+
'version-wordpress-stable-tag': {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly multiple: true;
|
|
38
|
+
};
|
|
39
|
+
'version-php-constant': {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly multiple: true;
|
|
42
|
+
};
|
|
43
|
+
'version-git-tag': {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly multiple: true;
|
|
46
|
+
};
|
|
47
|
+
'version-from': {
|
|
48
|
+
readonly type: "string";
|
|
49
|
+
};
|
|
50
|
+
'base-branch': {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
};
|
|
53
|
+
remote: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
};
|
|
56
|
+
'changesets-dir': {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
};
|
|
59
|
+
'readme-changelog': {
|
|
60
|
+
readonly type: "boolean";
|
|
61
|
+
};
|
|
62
|
+
'no-readme-changelog': {
|
|
63
|
+
readonly type: "boolean";
|
|
64
|
+
};
|
|
65
|
+
'changelog-insert-after': {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
'dry-run': {
|
|
20
69
|
readonly type: "boolean";
|
|
21
70
|
};
|
|
22
|
-
|
|
71
|
+
date: {
|
|
23
72
|
readonly type: "string";
|
|
24
73
|
};
|
|
25
|
-
|
|
74
|
+
package: {
|
|
26
75
|
readonly type: "string";
|
|
27
76
|
readonly multiple: true;
|
|
28
77
|
};
|
|
29
|
-
|
|
78
|
+
'no-dependents': {
|
|
30
79
|
readonly type: "boolean";
|
|
31
80
|
};
|
|
32
|
-
|
|
81
|
+
prerelease: {
|
|
33
82
|
readonly type: "string";
|
|
34
83
|
};
|
|
35
|
-
|
|
84
|
+
snapshot: {
|
|
36
85
|
readonly type: "string";
|
|
37
86
|
};
|
|
38
87
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { changesetProjectArgs, changesetProjectHelp, parseChangesetProjectArgs, } from "./changeset-project-args.js";
|
|
1
2
|
import { versionChangesets } from "../changeset-release.js";
|
|
2
3
|
import { getChangesetVersionSummary } from "../summary.js";
|
|
3
4
|
import { parseChangesetVersionArgs, changesetVersionArgs, } from "./changeset-args.js";
|
|
@@ -26,12 +27,13 @@ since the pre-release consumes the changesets that the stable release needs.
|
|
|
26
27
|
The readme Stable tag keeps the last stable version.
|
|
27
28
|
|
|
28
29
|
With --snapshot, build and publish the versioned files without committing
|
|
29
|
-
them, for example to test a pull request
|
|
30
|
-
options: changesetVersionArgs,
|
|
30
|
+
them, for example to test a pull request.${changesetProjectHelp}`,
|
|
31
|
+
options: { ...changesetVersionArgs, ...changesetProjectArgs },
|
|
31
32
|
async run({ values, cwd, configFile, tagFormat, logger }) {
|
|
32
33
|
const args = parseChangesetVersionArgs(values);
|
|
33
34
|
const result = await versionChangesets({
|
|
34
35
|
cwd,
|
|
36
|
+
...parseChangesetProjectArgs(values),
|
|
35
37
|
...(configFile ? { configFile } : {}),
|
|
36
38
|
...(tagFormat ? { tagFormat } : {}),
|
|
37
39
|
...args,
|
|
@@ -27,10 +27,13 @@ declare const _default: {
|
|
|
27
27
|
'filename-format': {
|
|
28
28
|
type: "string";
|
|
29
29
|
};
|
|
30
|
+
'checksums-format': {
|
|
31
|
+
type: "string";
|
|
32
|
+
};
|
|
30
33
|
output: {
|
|
31
34
|
type: "string";
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
|
-
run({ values, positionals, cwd, logger, }: import("./command.ts").CommandContext): Promise<CommandOutcome<ChecksumsResult>>;
|
|
37
|
+
run({ values, positionals, cwd, configFile, logger, }: import("./command.ts").CommandContext): Promise<CommandOutcome<ChecksumsResult>>;
|
|
35
38
|
};
|
|
36
39
|
export default _default;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ValidationError } from "../errors.js";
|
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, basename, resolve } from 'node:path';
|
|
4
|
+
import { loadChangesetConfig } from "../changeset-config.js";
|
|
5
|
+
import { resolveManifestCodec, encodeIntegrity } from "../integrity.js";
|
|
6
|
+
import { CHECKSUMS_EXTENSION, createChecksums } from "../checksums.js";
|
|
7
|
+
import { isErrorCode, ignoreOwnFile, ignoreOwnSignature, loadFileRules, resolveFileSelection, } from "../file-selection.js";
|
|
4
8
|
import { FILENAME_FORMAT, formatFilename } from "../filename.js";
|
|
5
9
|
import { readPackageMeta } from "../package-meta.js";
|
|
6
10
|
import { getChecksumsSummary } from "../summary.js";
|
|
@@ -15,6 +19,7 @@ export default {
|
|
|
15
19
|
accepted as --source-dir <dir>
|
|
16
20
|
|
|
17
21
|
Options:
|
|
22
|
+
--checksums-format <name> wordpress-json (default) or sha256sum
|
|
18
23
|
--output <file> Manifest file (default: the --filename-format name
|
|
19
24
|
in the current directory)
|
|
20
25
|
--slug <slug> Plugin or theme slug (default: project directory name)
|
|
@@ -40,22 +45,27 @@ matches the ZIP contents.`,
|
|
|
40
45
|
version: { type: 'string' },
|
|
41
46
|
type: { type: 'string' },
|
|
42
47
|
'filename-format': { type: 'string' },
|
|
48
|
+
'checksums-format': { type: 'string' },
|
|
43
49
|
output: { type: 'string' },
|
|
44
50
|
...sourceDirArgs,
|
|
45
51
|
...fileSelectionArgs,
|
|
46
52
|
force: { type: 'boolean' },
|
|
47
53
|
},
|
|
48
|
-
async run({ values, positionals, cwd, logger, }) {
|
|
54
|
+
async run({ values, positionals, cwd, configFile, logger, }) {
|
|
49
55
|
const sourceDir = resolve(cwd, getSourceDirArg(values, positionals));
|
|
50
56
|
const slug = getString(values, 'slug') ?? basename(cwd);
|
|
51
57
|
await checkDirectory(sourceDir);
|
|
52
58
|
const meta = await readPackageMeta({ dir: sourceDir, slug });
|
|
53
59
|
const version = getString(values, 'version') ?? meta?.version ?? null;
|
|
54
60
|
const filename = formatFilename(getString(values, 'filename-format') ?? FILENAME_FORMAT, { slug, version });
|
|
61
|
+
const loaded = await loadChangesetConfig({ cwd, configFile });
|
|
62
|
+
const codec = resolveManifestCodec(getString(values, 'checksums-format') ?? loaded?.config.integrity?.codec);
|
|
55
63
|
const checksumsPath = resolveOutput({
|
|
56
64
|
cwd,
|
|
57
65
|
output: getString(values, 'output'),
|
|
58
|
-
filename:
|
|
66
|
+
filename: codec.id === 'wordpress-json'
|
|
67
|
+
? filename + CHECKSUMS_EXTENSION
|
|
68
|
+
: codec.filename,
|
|
59
69
|
});
|
|
60
70
|
const selection = resolveFileSelection({
|
|
61
71
|
cwd,
|
|
@@ -71,7 +81,18 @@ matches the ZIP contents.`,
|
|
|
71
81
|
type: getString(values, 'type') ?? meta?.type,
|
|
72
82
|
});
|
|
73
83
|
const files = Object.keys(manifest.files).length;
|
|
74
|
-
await
|
|
84
|
+
await mkdir(dirname(checksumsPath), { recursive: true });
|
|
85
|
+
try {
|
|
86
|
+
await writeFile(checksumsPath, await encodeIntegrity(codec, manifest), {
|
|
87
|
+
flag: getBoolean(values, 'force') ? 'w' : 'wx',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (isErrorCode(error, 'EEXIST')) {
|
|
92
|
+
throw new ValidationError(`${checksumsPath} already exists, pass --force to overwrite it.`);
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
75
96
|
logger.debug(`Hashed ${files} files in ${sourceDir}.`);
|
|
76
97
|
logger.info(checksumsPath);
|
|
77
98
|
logger.summary((context) => getChecksumsSummary(context, { checksumsPath, files }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ParseArgsOptionsConfig } from 'node:util';
|
|
2
2
|
import type { PromptTerminal } from '../changeset-prompt.ts';
|
|
3
3
|
import type { Logger } from '../logger.ts';
|
|
4
|
+
import type { SvnRunner } from '../svn.ts';
|
|
4
5
|
/**
|
|
5
6
|
* Parsed option values from node:util parseArgs().
|
|
6
7
|
*/
|
|
@@ -18,6 +19,8 @@ export interface CommandContext {
|
|
|
18
19
|
tagFormat?: string;
|
|
19
20
|
/** Logger for the command output. */
|
|
20
21
|
logger: Logger;
|
|
22
|
+
/** SVN command runner supplied by a wrapper, instead of spawning svn directly. */
|
|
23
|
+
svnRunner?: SvnRunner;
|
|
21
24
|
/** Terminal for interactive prompts, only when the CLI runs in one and prints no JSON. */
|
|
22
25
|
terminal?: PromptTerminal;
|
|
23
26
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { DeployInput } from '../deploy-options.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeployResult } from '../svn-deploy.ts';
|
|
3
|
+
import type { PackageDeployPlanItem } from '../package-deploy.ts';
|
|
4
|
+
import type { CommandOutcome, ParsedValues } from './command.ts';
|
|
5
|
+
import type { PackageDeployOutcome } from './package-deploys.ts';
|
|
6
|
+
/** Results of a single deploy, a configured plan or configured deploys. */
|
|
7
|
+
export type DeploySvnResult = DeployResult | {
|
|
8
|
+
packages: PackageDeployPlanItem[];
|
|
9
|
+
} | {
|
|
10
|
+
deploys: PackageDeployOutcome<DeployResult>[];
|
|
11
|
+
};
|
|
3
12
|
export interface DeployArgsInput {
|
|
4
13
|
/** Parsed CLI values. */
|
|
5
14
|
values: ParsedValues;
|
|
@@ -76,19 +85,6 @@ declare const _default: {
|
|
|
76
85
|
type: "string";
|
|
77
86
|
};
|
|
78
87
|
};
|
|
79
|
-
run({ values, positionals, cwd, configFile, tagFormat, logger }: import("./command.ts").CommandContext): Promise<
|
|
80
|
-
exitCode: number;
|
|
81
|
-
result: {
|
|
82
|
-
packages: import("../package-deploy.ts").PackageDeployPlanItem[];
|
|
83
|
-
};
|
|
84
|
-
} | {
|
|
85
|
-
exitCode: number;
|
|
86
|
-
result: {
|
|
87
|
-
deploys: import("./package-deploys.ts").PackageDeployOutcome<import("../svn-deploy.ts").DeployResult>[];
|
|
88
|
-
};
|
|
89
|
-
} | {
|
|
90
|
-
exitCode: number;
|
|
91
|
-
result: import("../svn-deploy.ts").DeployResult;
|
|
92
|
-
}>;
|
|
88
|
+
run({ values, positionals, cwd, configFile, tagFormat, logger, svnRunner, }: import("./command.ts").CommandContext): Promise<CommandOutcome<DeploySvnResult>>;
|
|
93
89
|
};
|
|
94
90
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolveDeployOptions } from "../deploy-options.js";
|
|
2
2
|
import { getSvnDeploys } from "../package-deploy.js";
|
|
3
3
|
import { SvnDeploy } from "../svn-deploy.js";
|
|
4
|
+
import { Svn } from "../svn.js";
|
|
4
5
|
import { fileSelectionArgs, getFileSelectionInput, getSourceDirArg, sourceDirArgs, } from "./args.js";
|
|
5
6
|
import { getBoolean, getString } from "./command.js";
|
|
6
7
|
import { getPackageDeployArgs, listPackageDeploys, packageDeployArgs, runPackageDeploys, } from "./package-deploys.js";
|
|
@@ -23,6 +24,26 @@ const TARGET_FLAGS = [
|
|
|
23
24
|
'svn-url',
|
|
24
25
|
'message',
|
|
25
26
|
];
|
|
27
|
+
/**
|
|
28
|
+
* Run an SVN deploy with the optional command runner supplied by a wrapper.
|
|
29
|
+
*
|
|
30
|
+
* @param input Deploy input.
|
|
31
|
+
* @param logger Logger for the deploy.
|
|
32
|
+
* @param runner Optional SVN command runner.
|
|
33
|
+
* @return Deploy result.
|
|
34
|
+
*/
|
|
35
|
+
async function runDeploy(input, logger, runner) {
|
|
36
|
+
const options = resolveDeployOptions(input);
|
|
37
|
+
const svn = runner
|
|
38
|
+
? new Svn({
|
|
39
|
+
runner,
|
|
40
|
+
username: options.svnUsername,
|
|
41
|
+
password: options.svnPassword,
|
|
42
|
+
logger,
|
|
43
|
+
})
|
|
44
|
+
: undefined;
|
|
45
|
+
return new SvnDeploy(options, logger, svn).run();
|
|
46
|
+
}
|
|
26
47
|
/**
|
|
27
48
|
* Map the parsed "deploy-svn" arguments to resolveDeployOptions() input.
|
|
28
49
|
* Flags that aren't passed stay undefined, so that the same defaults apply
|
|
@@ -135,7 +156,7 @@ Examples:
|
|
|
135
156
|
...packageDeployArgs,
|
|
136
157
|
'dry-run': { type: 'boolean' },
|
|
137
158
|
},
|
|
138
|
-
async run({ values, positionals, cwd, configFile, tagFormat, logger }) {
|
|
159
|
+
async run({ values, positionals, cwd, configFile, tagFormat, logger, svnRunner, }) {
|
|
139
160
|
const { ref, packages, list } = getPackageDeployArgs(values, positionals, TARGET_FLAGS);
|
|
140
161
|
if (ref) {
|
|
141
162
|
const deploys = await getSvnDeploys({
|
|
@@ -148,14 +169,13 @@ Examples:
|
|
|
148
169
|
});
|
|
149
170
|
return list
|
|
150
171
|
? listPackageDeploys(deploys, logger, ref)
|
|
151
|
-
: runPackageDeploys(deploys, (input) =>
|
|
172
|
+
: runPackageDeploys(deploys, (input) => runDeploy({
|
|
152
173
|
...input,
|
|
153
174
|
svnUsername: getString(values, 'svn-username'),
|
|
154
175
|
force: getBoolean(values, 'force'),
|
|
155
|
-
}
|
|
176
|
+
}, logger, svnRunner), logger, ref);
|
|
156
177
|
}
|
|
157
|
-
const
|
|
158
|
-
const result = await new SvnDeploy(options, logger).run();
|
|
178
|
+
const result = await runDeploy(getDeployInputFromArgs({ values, positionals, cwd }), logger, svnRunner);
|
|
159
179
|
return { exitCode: 0, result };
|
|
160
180
|
},
|
|
161
181
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PackageType } from '../checksums.ts';
|
|
2
|
+
import type { FileSelection } from '../file-selection.ts';
|
|
3
|
+
import type { ParsedValues } from './command.ts';
|
|
4
|
+
/** Release source, file selection and package metadata. */
|
|
5
|
+
export interface PackageSource {
|
|
6
|
+
sourceDir: string;
|
|
7
|
+
selection: FileSelection;
|
|
8
|
+
slug: string;
|
|
9
|
+
version: string | null;
|
|
10
|
+
type?: PackageType;
|
|
11
|
+
package?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the configured package to release, failing for the options that set the
|
|
15
|
+
* source directory and the files instead.
|
|
16
|
+
*
|
|
17
|
+
* @param values Parsed CLI values.
|
|
18
|
+
* @param positionals Positional arguments.
|
|
19
|
+
* @return The package identifier or path, or undefined without --package.
|
|
20
|
+
* @throws {ValidationError} For an empty --package, or --package with a source directory or file selection option.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPackageArg(values: ParsedValues, positionals: string[]): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get the files of a source directory from the CLI options.
|
|
25
|
+
*
|
|
26
|
+
* @param values Parsed CLI values.
|
|
27
|
+
* @param positionals Positional arguments.
|
|
28
|
+
* @param cwd Working directory.
|
|
29
|
+
* @return Source directory, file selection, slug and version.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getDirectorySource(values: ParsedValues, positionals: string[], cwd: string): Promise<PackageSource>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the directory of a configured package with the files config of its
|
|
34
|
+
* package group, which its deploys use too.
|
|
35
|
+
*
|
|
36
|
+
* @param values Parsed CLI values.
|
|
37
|
+
* @param cwd Repository root with the wp-release config.
|
|
38
|
+
* @param name Package identifier or path under the configured root.
|
|
39
|
+
* @param configFile Config file, instead of the conventional one.
|
|
40
|
+
* @return Source directory, file selection, slug, version and package.
|
|
41
|
+
* @throws {ValidationError} Without a config or for an unknown package.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getPackageSource(values: ParsedValues, cwd: string, name: string, configFile?: string): Promise<PackageSource>;
|