@wpelevator/wp-release 0.1.1 → 0.3.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 CHANGED
@@ -56,6 +56,7 @@ Each concept has one name, written in the syntax of each interface:
56
56
  | Git tag to compare | `--git-tag <tag>` | | `gitTag` | Git tag checked by `version-check`. |
57
57
  | SVN tag to create | `--svn-tag <version>` | `svn-tag` | `svnTag` | Tag written by `deploy-svn`, distinct from a git tag. |
58
58
  | SVN repository | `--svn-url <url>` | `svn-url` | `svnUrl` | Deploy destination. |
59
+ | SVN credentials | `--svn-username <name>`, `SVN_USERNAME` and `SVN_PASSWORD` env vars | `svn-username`, `svn-password` | `svnUsername`, `svnPassword` | Needed only to commit. There's no password flag, since it would show in the process list; the action inputs and library options fall back to the env vars. |
59
60
  | Assets sync | `--no-assets` to skip | `assets: false` to skip | `assets` | Booleans are positive in the library and the action; `--no-assets` is only the CLI negation, never `noAssets` or a `no-assets` input. |
60
61
 
61
62
  CLI JSON results use camelCase keys like `zipPath`, and GitHub Action outputs use kebab-case like `zip-path`. Library classes are named after the capability (`SvnDeploy`, `Svn`) without repeating "release".
@@ -152,8 +153,8 @@ wp-release version-check --constant MY_PLUGIN_VERSION --git-tag v1.2.0
152
153
  | Flag | Default | Writes |
153
154
  |---|---|---|
154
155
  | `--trunk` | off | Sync the full source directory to `trunk/` |
155
- | `--readme-only` | off | Sync only the readme to `trunk/`, for updates between releases such as bumping `Tested up to` |
156
- | `--svn-tag <version>` | off | Copy `trunk/` to `tags/<version>`; requires `--trunk`. A leading `v` is stripped, so `v1.2.0` creates `tags/1.2.0`. |
156
+ | `--readme-only` | off | Sync only the readme to `trunk/`, for updates between releases such as bumping `Tested up to`. Can't be combined with `--svn-tag`. |
157
+ | `--svn-tag <version>` | off | Copy `trunk/` to `tags/<version>`. Without `--trunk`, the tag is copied from the repository's current `trunk/`. A leading `v` is stripped, so `v1.2.0` creates `tags/1.2.0`. |
157
158
  | `--assets-dir <dir>` | not set | Sync this directory with banners, icons and screenshots to the SVN `assets/` directory. There's no default directory, so assets are only deployed when this is set, and it must exist. |
158
159
  | `--no-assets` | | Skip the `--assets-dir` sync for one run, for example when a config always passes `--assets-dir`. |
159
160
 
@@ -176,9 +177,9 @@ wp-release deploy-svn --from-zip my-plugin.1.2.0.zip --trunk --svn-tag 1.2.0
176
177
  How a deploy works:
177
178
 
178
179
  1. The options are validated, including the slug, version and readme name, before they're used in URLs or paths.
179
- 2. With `--trunk`, the files must be a plugin whose `Version` header matches the version, and with `--svn-tag` the readme `Stable tag` must match too. `--readme-only` needs the readme. Nothing is checked out when a check fails.
180
+ 2. With `--trunk`, the files must be a plugin whose `Version` header matches the version, and with `--svn-tag` the readme `Stable tag` must match too. A tag-only run doesn't check the files, since it tags whatever is in `trunk/`. `--readme-only` needs the readme. Nothing is checked out when a check fails.
180
181
  3. The repository is checked out sparsely into a new temporary directory, with only the directories that the flags write to. A missing `assets/` (or `trunk/`, `tags/`) directory is created. The deploy stops when `tags/<version>` exists, unless `--force` replaces it.
181
- 4. The files are synced in Node.js, without `rsync`: new and changed files are copied, files that are no longer selected are deleted, and `svn add` and `svn delete` stage them, including files that svn ignores by default. `trunk/` is then copied to the tag with `svn copy`.
182
+ 4. The files are synced in Node.js, without `rsync`: new and changed files are copied, files that are no longer selected are deleted, and `svn add` and `svn delete` stage them, including files that svn ignores by default. `trunk/` is then copied to the tag with `svn copy`, from the working copy when trunk was written and from the repository otherwise.
182
183
  5. Asset images get `svn:mime-type` set for PNG, JPEG, GIF and SVG, the formats that WordPress.org documents for plugin assets. Other formats keep the type that svn assigns.
183
184
  6. When `svn status` is empty, the deploy ends without a commit. A dry run logs the status and stops before the commit. Otherwise the changes are committed, and the temporary directory is always removed.
184
185
 
@@ -188,10 +189,9 @@ Credentials are only needed for the commit, not for dry runs, no-op runs or `fil
188
189
 
189
190
  Validation:
190
191
 
191
- - `--trunk` and `--readme-only` can't be combined.
192
- - `--readme-only` is rejected when `GITHUB_REF` is a tag, since a readme-only update from a release tag usually means the build was forgotten.
193
- - Pre-release versions like `1.0.0-rc.1` are never tagged.
192
+ - `--readme-only` can't be combined with `--svn-tag`, since a tag is a release snapshot that a readme update never changes.
194
193
  - `--version` defaults to `--svn-tag`, then the `Version` header of the deployed files; when `--version` and `--svn-tag` are both set they must match.
194
+ - Pre-release versions like `1.0.0-rc.1` can be tagged, but syncing one to `trunk/` warns, since trunk is for the development version.
195
195
  - `--trunk` without `--svn-tag` works but warns, because trunk then differs from the stable tag that WordPress.org serves downloads from.
196
196
 
197
197
  ### Exit codes
@@ -28,7 +28,6 @@ export function getDeployInputFromArgs(input) {
28
28
  ...getFileSelectionInput(values),
29
29
  svnUrl: getString(values, 'svn-url'),
30
30
  svnUsername: getString(values, 'svn-username'),
31
- gitRef: process.env.GITHUB_REF,
32
31
  message: getString(values, 'message'),
33
32
  force: flag('force'),
34
33
  dryRun: flag('dry-run'),
@@ -44,9 +43,9 @@ export default {
44
43
 
45
44
  Writes (none by default, assets only with --assets-dir):
46
45
  --trunk Sync the full source directory to trunk/
47
- --readme-only Sync only the readme to trunk/ (not with --trunk)
48
- --svn-tag <version> Copy trunk/ to tags/<version> (requires --trunk).
49
- A leading "v" is stripped.
46
+ --readme-only Sync only the readme to trunk/ (not with --svn-tag)
47
+ --svn-tag <version> Copy trunk/ to tags/<version>, with or without
48
+ --trunk. A leading "v" is stripped.
50
49
  --assets-dir <dir> Sync this directory with banners, icons and
51
50
  screenshots to assets/
52
51
  --no-assets Don't sync --assets-dir for this run
@@ -37,8 +37,6 @@ export interface DeployInput {
37
37
  svnUsername?: string;
38
38
  /** SVN password, defaults to the SVN_PASSWORD env var. */
39
39
  svnPassword?: string;
40
- /** Git ref of the run, like refs/tags/1.2.0. */
41
- gitRef?: string;
42
40
  /** SVN commit message. */
43
41
  message?: string;
44
42
  /** Replace an existing tag. */
@@ -65,7 +63,6 @@ export interface DeployOptions extends FileSelection {
65
63
  svnUsername: string | null;
66
64
  /** Never logged or printed. */
67
65
  svnPassword: string | null;
68
- gitRef: string | null;
69
66
  message: string | null;
70
67
  force: boolean;
71
68
  dryRun: boolean;
@@ -62,15 +62,9 @@ function isValidFilename(name) {
62
62
  */
63
63
  export function getDeployOptionErrors(options) {
64
64
  const errors = [];
65
- const { trunk, readmeOnly, svnTag, version, assets, assetsDir, slug } = options;
66
- if (svnTag && !trunk) {
67
- errors.push('--svn-tag requires --trunk, since the tag is copied from trunk.');
68
- }
69
- if (trunk && readmeOnly) {
70
- errors.push('Use either --trunk or --readme-only, not both.');
71
- }
72
- if (svnTag && isPrerelease(svnTag)) {
73
- errors.push(`Pre-release version ${svnTag} can't be tagged on WordPress.org.`);
65
+ const { readmeOnly, svnTag, version, assets, assetsDir, slug } = options;
66
+ if (readmeOnly && svnTag) {
67
+ errors.push("--readme-only can't be combined with --svn-tag, since a tag is a release snapshot that a readme update never changes.");
74
68
  }
75
69
  if (svnTag && !isValidVersion(svnTag)) {
76
70
  errors.push(`SVN tag "${svnTag}" isn't a valid version, use only letters, digits, dots, dashes, plus signs and underscores.`);
@@ -81,9 +75,6 @@ export function getDeployOptionErrors(options) {
81
75
  if (svnTag && version && svnTag !== version) {
82
76
  errors.push(`SVN tag ${svnTag} doesn't match version ${version}.`);
83
77
  }
84
- if (readmeOnly && isTagRef(options.gitRef)) {
85
- errors.push(`--readme-only isn't allowed when running for tag ${options.gitRef}. Did you mean --trunk --svn-tag?`);
86
- }
87
78
  if (assets && !assetsDir) {
88
79
  errors.push('Syncing assets requires --assets-dir.');
89
80
  }
@@ -155,7 +146,6 @@ export function resolveDeployOptions(input = {}) {
155
146
  svnUrl: (input.svnUrl || SVN_URL).replace('{slug}', slug),
156
147
  svnUsername: input.svnUsername || process.env.SVN_USERNAME || null,
157
148
  svnPassword: input.svnPassword || process.env.SVN_PASSWORD || null,
158
- gitRef: input.gitRef || null,
159
149
  message: input.message || null,
160
150
  force: Boolean(input.force),
161
151
  dryRun: Boolean(input.dryRun),
@@ -134,7 +134,9 @@ export declare class SvnDeploy {
134
134
  */
135
135
  setAssetMimeTypes(): Promise<void>;
136
136
  /**
137
- * Copy trunk to the SVN tag, replacing an existing tag with force.
137
+ * Copy trunk to the SVN tag, replacing an existing tag with force. Trunk
138
+ * is copied from the working copy when this run writes to it, and from the
139
+ * repository otherwise, so that tagging doesn't need a trunk checkout.
138
140
  */
139
141
  copyTag(): Promise<void>;
140
142
  /**
@@ -198,6 +200,12 @@ export declare class SvnDeploy {
198
200
  * @return Rules description, empty without rules.
199
201
  */
200
202
  describeRules(): string;
203
+ /**
204
+ * Get the repository URL of trunk.
205
+ *
206
+ * @return Trunk URL without a double slash.
207
+ */
208
+ getTrunkUrl(): string;
201
209
  /**
202
210
  * Get the path of the tag in the working copy.
203
211
  *
@@ -277,7 +277,9 @@ export class SvnDeploy {
277
277
  }
278
278
  }
279
279
  /**
280
- * Copy trunk to the SVN tag, replacing an existing tag with force.
280
+ * Copy trunk to the SVN tag, replacing an existing tag with force. Trunk
281
+ * is copied from the working copy when this run writes to it, and from the
282
+ * repository otherwise, so that tagging doesn't need a trunk checkout.
281
283
  */
282
284
  async copyTag() {
283
285
  const tagPath = this.getTagPath();
@@ -288,7 +290,7 @@ export class SvnDeploy {
288
290
  }
289
291
  if (tagPath) {
290
292
  await this.svn.copy({
291
- from: 'trunk',
293
+ from: this.needsFiles() ? 'trunk' : this.getTrunkUrl(),
292
294
  to: tagPath,
293
295
  cwd: workingCopy,
294
296
  });
@@ -458,6 +460,14 @@ export class SvnDeploy {
458
460
  ];
459
461
  return rules.filter(Boolean).join(', ');
460
462
  }
463
+ /**
464
+ * Get the repository URL of trunk.
465
+ *
466
+ * @return Trunk URL without a double slash.
467
+ */
468
+ getTrunkUrl() {
469
+ return `${this.options.svnUrl.replace(/\/+$/, '')}/trunk`;
470
+ }
461
471
  /**
462
472
  * Get the path of the tag in the working copy.
463
473
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpelevator/wp-release",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Package, checksum, verify and version-check WordPress plugins and themes, and deploy plugins to WordPress.org SVN",
5
5
  "license": "MIT",
6
6
  "repository": {