@peiyanlu/release 0.0.13 → 0.0.14

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/dist/cli.mjs CHANGED
@@ -108,15 +108,15 @@ const MSG = {
108
108
  },
109
109
  NPM: {
110
110
  START: "Publishing npm package",
111
- END: (url) => `NPM package published: ${underline(dim(url))}`
111
+ END: (url) => url ? `Published npm package: ${underline(dim(url))}` : "NPM publish skipped"
112
112
  },
113
113
  GIT: {
114
114
  START: "Creating git commit, tag & push",
115
- END: "Git commit, tag & push completed"
115
+ END: (push) => push ? "Git commit, tag & push completed" : "Git commit, tag & push skipped"
116
116
  },
117
117
  GITHUB: {
118
118
  START: "Creating GitHub release",
119
- END: (url) => `GitHub release created: ${underline(dim(url))}`
119
+ END: (url) => url ? `Created GitHub release: ${underline(dim(url))}` : "GitHub release skipped"
120
120
  }
121
121
  },
122
122
  PROMPT: {
@@ -629,7 +629,7 @@ const parsePreset = async () => {
629
629
  {{#each commits}}
630
630
  {{> commit root=@root}}
631
631
  {{/each}}
632
- {{/each}}`.trim() + eol(2);
632
+ {{/each}}`.trim();
633
633
  return preset;
634
634
  };
635
635
  const createGenerator = async ({ getPkgDir, tagPrefix }) => {
@@ -649,14 +649,15 @@ const getChangelog = async ({ getPkgDir, tagPrefix }) => {
649
649
  const generateChangelog = async ({ getPkgDir, tagPrefix }) => {
650
650
  const infile = join(getPkgDir(), "CHANGELOG.md");
651
651
  if (!existsSync(infile)) await writeFile(infile, "");
652
- const originalChangelog = readFileSync(infile, "utf-8");
652
+ const exist = readFileSync(infile, "utf-8");
653
653
  const generator = await createGenerator({
654
654
  getPkgDir,
655
655
  tagPrefix
656
656
  });
657
657
  const writeStream = createWriteStream(infile);
658
658
  for await (const chunk of generator.write()) writeStream.write(chunk);
659
- writeStream.write(originalChangelog);
659
+ if (exist.trim().length) writeStream.write(eol(2));
660
+ writeStream.write(exist);
660
661
  writeStream.end();
661
662
  await finished(writeStream);
662
663
  };
@@ -674,14 +675,18 @@ const runGitPrompts = async (ctx, config) => {
674
675
  return Promise.resolve(commit);
675
676
  })();
676
677
  },
677
- tag: () => {
678
- return shouldPrompt(tag) ? confirm({ message: question(MSG.PROMPT.GIT_TAG(currentTag), "git") }) : (() => {
678
+ tag: ({ results: { commit } }) => {
679
+ return shouldPrompt(tag) ? commit ? confirm({ message: question(MSG.PROMPT.GIT_TAG(currentTag), "git") }) : (() => {
680
+ return Promise.resolve(false);
681
+ })() : (() => {
679
682
  logs.push(yellow`git.tag`);
680
683
  return Promise.resolve(tag);
681
684
  })();
682
685
  },
683
- push: () => {
684
- return shouldPrompt(push) ? confirm({ message: question(MSG.PROMPT.GIT_PUSH, "git") }) : (() => {
686
+ push: ({ results: { commit, tag } }) => {
687
+ return shouldPrompt(push) ? commit || tag ? confirm({ message: question(MSG.PROMPT.GIT_PUSH, "git") }) : (() => {
688
+ return Promise.resolve(false);
689
+ })() : (() => {
685
690
  logs.push(yellow`git.push`);
686
691
  return Promise.resolve(push);
687
692
  })();
@@ -1145,7 +1150,8 @@ var Action = class {
1145
1150
  title: MSG.TASK.GIT.START,
1146
1151
  task: async () => {
1147
1152
  await commitAndTag(ctx, config);
1148
- return success(MSG.TASK.GIT.END, dryRun);
1153
+ const { git: { push } } = config;
1154
+ return success(MSG.TASK.GIT.END(Boolean(push)), dryRun);
1149
1155
  }
1150
1156
  }]).catch((err) => abortOnError(err, ctx));
1151
1157
  await runLifeCycleHook(hooks, "after:push", dryRun);
@@ -1165,7 +1171,8 @@ var Action = class {
1165
1171
  await publishNpm(ctx, config);
1166
1172
  } else throw err;
1167
1173
  });
1168
- const url = getPackageUrl(name, next);
1174
+ const { npm: { publish } } = config;
1175
+ const url = publish ? getPackageUrl(name, next) : void 0;
1169
1176
  return success(MSG.TASK.NPM.END(url), dryRun);
1170
1177
  }
1171
1178
  }]).catch((err) => abortOnError(err, ctx, false));
@@ -1180,9 +1187,10 @@ var Action = class {
1180
1187
  await tasks([{
1181
1188
  title: MSG.TASK.GITHUB.START,
1182
1189
  task: async () => {
1183
- const { github: { owner, repo }, git: { currentTag } } = ctx;
1184
1190
  await createRelease(ctx, config);
1185
- const url = getGithubReleaseUrl(owner, repo, currentTag);
1191
+ const { github: { owner, repo }, git: { currentTag } } = ctx;
1192
+ const { github: { release } } = config;
1193
+ const url = release ? getGithubReleaseUrl(owner, repo, currentTag) : void 0;
1186
1194
  return success(MSG.TASK.GITHUB.END(url), dryRun);
1187
1195
  }
1188
1196
  }]).catch((err) => abortOnError(err, ctx, false));
package/dist/index.d.mts CHANGED
@@ -38,6 +38,7 @@ interface ReleaseConfig {
38
38
  git: {
39
39
  /**
40
40
  * 是否创建 Git 提交
41
+ * 影响创建 Tag 和推送
41
42
  */
42
43
  commit: boolean | undefined;
43
44
  /**
package/dist/index.mjs CHANGED
@@ -174,7 +174,7 @@ const parsePreset = async () => {
174
174
  {{#each commits}}
175
175
  {{> commit root=@root}}
176
176
  {{/each}}
177
- {{/each}}`.trim() + eol(2);
177
+ {{/each}}`.trim();
178
178
  return preset;
179
179
  };
180
180
  const createGenerator = async ({ getPkgDir, tagPrefix }) => {
@@ -194,14 +194,15 @@ const getChangelog = async ({ getPkgDir, tagPrefix }) => {
194
194
  const generateChangelog = async ({ getPkgDir, tagPrefix }) => {
195
195
  const infile = join(getPkgDir(), "CHANGELOG.md");
196
196
  if (!existsSync(infile)) await writeFile(infile, "");
197
- const originalChangelog = readFileSync(infile, "utf-8");
197
+ const exist = readFileSync(infile, "utf-8");
198
198
  const generator = await createGenerator({
199
199
  getPkgDir,
200
200
  tagPrefix
201
201
  });
202
202
  const writeStream = createWriteStream(infile);
203
203
  for await (const chunk of generator.write()) writeStream.write(chunk);
204
- writeStream.write(originalChangelog);
204
+ if (exist.trim().length) writeStream.write(eol(2));
205
+ writeStream.write(exist);
205
206
  writeStream.end();
206
207
  await finished(writeStream);
207
208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peiyanlu/release",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Release project tool.",
5
5
  "license": "MIT",
6
6
  "type": "module",