@wpelevator/wp-release 0.15.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 +246 -37
- 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 +1 -0
- package/dist/cli.js +2 -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/package-source.d.ts +43 -0
- package/dist/commands/package-source.js +101 -0
- package/dist/commands/verify.d.ts +7 -1
- package/dist/commands/verify.js +53 -17
- package/dist/commands/zip.d.ts +20 -8
- package/dist/commands/zip.js +109 -124
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- 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/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
|
@@ -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 }));
|
|
@@ -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>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { basename, resolve } from 'node:path';
|
|
2
|
+
import { ValidationError } from "../errors.js";
|
|
3
|
+
import { resolveFileSelection } from "../file-selection.js";
|
|
4
|
+
import { getPackageFiles } from "../package-deploy.js";
|
|
5
|
+
import { readPackageMeta } from "../package-meta.js";
|
|
6
|
+
import { checkDirectory, getFileSelectionInput, getSourceDirArg, } from "./args.js";
|
|
7
|
+
import { getBoolean, getString, getStrings } from "./command.js";
|
|
8
|
+
/** Options of a source directory and its files, which --package takes from the config. */
|
|
9
|
+
const SOURCE_FLAGS = [
|
|
10
|
+
'source-dir',
|
|
11
|
+
'distignore',
|
|
12
|
+
'no-distignore',
|
|
13
|
+
'exclude',
|
|
14
|
+
'exclude-gitattributes',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Get the configured package to release, failing for the options that set the
|
|
18
|
+
* source directory and the files instead.
|
|
19
|
+
*
|
|
20
|
+
* @param values Parsed CLI values.
|
|
21
|
+
* @param positionals Positional arguments.
|
|
22
|
+
* @return The package identifier or path, or undefined without --package.
|
|
23
|
+
* @throws {ValidationError} For an empty --package, or --package with a source directory or file selection option.
|
|
24
|
+
*/
|
|
25
|
+
export function getPackageArg(values, positionals) {
|
|
26
|
+
const name = getString(values, 'package')?.trim();
|
|
27
|
+
const conflicts = SOURCE_FLAGS.filter((flag) => undefined !== getString(values, flag) ||
|
|
28
|
+
getBoolean(values, flag) ||
|
|
29
|
+
getStrings(values, flag).length);
|
|
30
|
+
if ('' === name) {
|
|
31
|
+
throw new ValidationError('--package <name> must not be empty.');
|
|
32
|
+
}
|
|
33
|
+
if (name && (positionals.length || conflicts.length)) {
|
|
34
|
+
throw new ValidationError(`--package takes the directory and files of the package from the config, so it can't be combined with ${positionals.length
|
|
35
|
+
? 'a source directory'
|
|
36
|
+
: conflicts.map((flag) => `--${flag}`).join(', ')}.`);
|
|
37
|
+
}
|
|
38
|
+
return name;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Describe the files of a directory with the slug and the version from the
|
|
42
|
+
* options, or from the plugin or theme headers.
|
|
43
|
+
*
|
|
44
|
+
* @param values Parsed CLI values.
|
|
45
|
+
* @param sourceDir Directory to release.
|
|
46
|
+
* @param selection File selection.
|
|
47
|
+
* @param slug Default slug.
|
|
48
|
+
* @return Source directory, file selection, slug, version and type.
|
|
49
|
+
*/
|
|
50
|
+
async function describeSource(values, sourceDir, selection, slug) {
|
|
51
|
+
const name = getString(values, 'slug') ?? slug;
|
|
52
|
+
const meta = await readPackageMeta({ dir: sourceDir, slug: name });
|
|
53
|
+
return {
|
|
54
|
+
sourceDir,
|
|
55
|
+
selection,
|
|
56
|
+
slug: name,
|
|
57
|
+
version: getString(values, 'version') ?? meta?.version ?? null,
|
|
58
|
+
...(meta ? { type: meta.type } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the files of a source directory from the CLI options.
|
|
63
|
+
*
|
|
64
|
+
* @param values Parsed CLI values.
|
|
65
|
+
* @param positionals Positional arguments.
|
|
66
|
+
* @param cwd Working directory.
|
|
67
|
+
* @return Source directory, file selection, slug and version.
|
|
68
|
+
*/
|
|
69
|
+
export async function getDirectorySource(values, positionals, cwd) {
|
|
70
|
+
const sourceDir = resolve(cwd, getSourceDirArg(values, positionals));
|
|
71
|
+
await checkDirectory(sourceDir);
|
|
72
|
+
return describeSource(values, sourceDir, resolveFileSelection({
|
|
73
|
+
cwd,
|
|
74
|
+
sourceDir,
|
|
75
|
+
...getFileSelectionInput(values),
|
|
76
|
+
}), basename(cwd));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the directory of a configured package with the files config of its
|
|
80
|
+
* package group, which its deploys use too.
|
|
81
|
+
*
|
|
82
|
+
* @param values Parsed CLI values.
|
|
83
|
+
* @param cwd Repository root with the wp-release config.
|
|
84
|
+
* @param name Package identifier or path under the configured root.
|
|
85
|
+
* @param configFile Config file, instead of the conventional one.
|
|
86
|
+
* @return Source directory, file selection, slug, version and package.
|
|
87
|
+
* @throws {ValidationError} Without a config or for an unknown package.
|
|
88
|
+
*/
|
|
89
|
+
export async function getPackageSource(values, cwd, name, configFile) {
|
|
90
|
+
const pkg = await getPackageFiles({
|
|
91
|
+
cwd,
|
|
92
|
+
package: name,
|
|
93
|
+
...(configFile ? { configFile } : {}),
|
|
94
|
+
});
|
|
95
|
+
const source = await describeSource(values, pkg.directory, resolveFileSelection({
|
|
96
|
+
cwd,
|
|
97
|
+
sourceDir: pkg.directory,
|
|
98
|
+
...pkg.files,
|
|
99
|
+
}), basename(pkg.directory));
|
|
100
|
+
return { ...source, package: pkg.name };
|
|
101
|
+
}
|
|
@@ -12,6 +12,12 @@ declare const _default: {
|
|
|
12
12
|
checksums: {
|
|
13
13
|
type: "string";
|
|
14
14
|
};
|
|
15
|
+
'checksums-format': {
|
|
16
|
+
type: "string";
|
|
17
|
+
};
|
|
18
|
+
'checksums-file': {
|
|
19
|
+
type: "string";
|
|
20
|
+
};
|
|
15
21
|
zip: {
|
|
16
22
|
type: "string";
|
|
17
23
|
};
|
|
@@ -28,6 +34,6 @@ declare const _default: {
|
|
|
28
34
|
type: "string";
|
|
29
35
|
};
|
|
30
36
|
};
|
|
31
|
-
run({ values, positionals, cwd, logger }: import("./command.ts").CommandContext): Promise<CommandOutcome<unknown>>;
|
|
37
|
+
run({ values, positionals, cwd, configFile, logger }: import("./command.ts").CommandContext): Promise<CommandOutcome<unknown>>;
|
|
32
38
|
};
|
|
33
39
|
export default _default;
|