ic-mops 0.28.0-pre.1 → 0.28.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/commands/add.ts +1 -1
- package/commands/install-all.ts +1 -1
- package/commands/publish.ts +27 -5
- package/dist/commands/add.js +1 -1
- package/dist/commands/install-all.js +1 -1
- package/dist/commands/publish.js +23 -5
- package/dist/notify-installs.js +4 -2
- package/dist/package.json +1 -1
- package/notify-installs.ts +4 -2
- package/package.json +1 -1
package/commands/add.ts
CHANGED
|
@@ -90,7 +90,7 @@ export async function add(name: string, {verbose = false, dev = false} = {}) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
writeConfig(config);
|
|
93
|
-
notifyInstalls(Object.keys(installedPackages));
|
|
93
|
+
await notifyInstalls(Object.keys(installedPackages));
|
|
94
94
|
|
|
95
95
|
logUpdate.clear();
|
|
96
96
|
console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
|
package/commands/install-all.ts
CHANGED
package/commands/publish.ts
CHANGED
|
@@ -233,6 +233,14 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
|
233
233
|
// parse changelog
|
|
234
234
|
console.log('Parsing CHANGELOG.md...');
|
|
235
235
|
let changelog = parseChangelog(config.package.version);
|
|
236
|
+
if (!changelog && config.package.repository) {
|
|
237
|
+
console.log('Fetching release notes from GitHub...');
|
|
238
|
+
changelog = await fetchGitHubReleaseNotes(config.package.repository, config.package.version);
|
|
239
|
+
}
|
|
240
|
+
if (changelog) {
|
|
241
|
+
console.log('Changelog:');
|
|
242
|
+
console.log(chalk.gray(changelog));
|
|
243
|
+
}
|
|
236
244
|
|
|
237
245
|
// test
|
|
238
246
|
let reporter = new SilentReporter;
|
|
@@ -342,17 +350,31 @@ function parseChangelog(version: string): string {
|
|
|
342
350
|
let str = fs.readFileSync(changelogFile, 'utf-8');
|
|
343
351
|
let changelog = findChangelogEntry(str, version);
|
|
344
352
|
|
|
345
|
-
if (changelog) {
|
|
346
|
-
console.log('Changelog:');
|
|
347
|
-
console.log(chalk.gray(changelog));
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
353
|
+
if (!changelog) {
|
|
350
354
|
console.log(chalk.yellow('No changelog entry found'));
|
|
351
355
|
}
|
|
352
356
|
|
|
353
357
|
return changelog || '';
|
|
354
358
|
}
|
|
355
359
|
|
|
360
|
+
async function fetchGitHubReleaseNotes(repo: string, version: string): Promise<string> {
|
|
361
|
+
let repoPath = new URL(repo).pathname;
|
|
362
|
+
let res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/${version}`);
|
|
363
|
+
let release = await res.json();
|
|
364
|
+
|
|
365
|
+
if (release.message === 'Not Found') {
|
|
366
|
+
res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/v${version}`);
|
|
367
|
+
release = await res.json();
|
|
368
|
+
|
|
369
|
+
if (release.message === 'Not Found') {
|
|
370
|
+
console.log(chalk.yellow(`No GitHub release found with name ${version} or v${version}`));
|
|
371
|
+
return '';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return release.body;
|
|
376
|
+
}
|
|
377
|
+
|
|
356
378
|
function findChangelogEntry(changelog: string, version: string): string {
|
|
357
379
|
let tree = fromMarkdown(changelog);
|
|
358
380
|
let found = false;
|
package/dist/commands/add.js
CHANGED
|
@@ -80,7 +80,7 @@ export async function add(name, { verbose = false, dev = false } = {}) {
|
|
|
80
80
|
throw Error(`Invalid config file: [${depsProp}] not found`);
|
|
81
81
|
}
|
|
82
82
|
writeConfig(config);
|
|
83
|
-
notifyInstalls(Object.keys(installedPackages));
|
|
83
|
+
await notifyInstalls(Object.keys(installedPackages));
|
|
84
84
|
logUpdate.clear();
|
|
85
85
|
console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
|
|
86
86
|
}
|
|
@@ -25,7 +25,7 @@ export async function installAll({ verbose = false, silent = false } = {}) {
|
|
|
25
25
|
installedPackages = { ...installedPackages, ...res };
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
notifyInstalls(Object.keys(installedPackages));
|
|
28
|
+
await notifyInstalls(Object.keys(installedPackages));
|
|
29
29
|
if (!silent) {
|
|
30
30
|
logUpdate.clear();
|
|
31
31
|
console.log(chalk.green('All packages installed'));
|
package/dist/commands/publish.js
CHANGED
|
@@ -208,6 +208,14 @@ export async function publish(options = {}) {
|
|
|
208
208
|
// parse changelog
|
|
209
209
|
console.log('Parsing CHANGELOG.md...');
|
|
210
210
|
let changelog = parseChangelog(config.package.version);
|
|
211
|
+
if (!changelog && config.package.repository) {
|
|
212
|
+
console.log('Fetching release notes from GitHub...');
|
|
213
|
+
changelog = await fetchGitHubReleaseNotes(config.package.repository, config.package.version);
|
|
214
|
+
}
|
|
215
|
+
if (changelog) {
|
|
216
|
+
console.log('Changelog:');
|
|
217
|
+
console.log(chalk.gray(changelog));
|
|
218
|
+
}
|
|
211
219
|
// test
|
|
212
220
|
let reporter = new SilentReporter;
|
|
213
221
|
if (options.test) {
|
|
@@ -298,15 +306,25 @@ function parseChangelog(version) {
|
|
|
298
306
|
}
|
|
299
307
|
let str = fs.readFileSync(changelogFile, 'utf-8');
|
|
300
308
|
let changelog = findChangelogEntry(str, version);
|
|
301
|
-
if (changelog) {
|
|
302
|
-
console.log('Changelog:');
|
|
303
|
-
console.log(chalk.gray(changelog));
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
309
|
+
if (!changelog) {
|
|
306
310
|
console.log(chalk.yellow('No changelog entry found'));
|
|
307
311
|
}
|
|
308
312
|
return changelog || '';
|
|
309
313
|
}
|
|
314
|
+
async function fetchGitHubReleaseNotes(repo, version) {
|
|
315
|
+
let repoPath = new URL(repo).pathname;
|
|
316
|
+
let res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/${version}`);
|
|
317
|
+
let release = await res.json();
|
|
318
|
+
if (release.message === 'Not Found') {
|
|
319
|
+
res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/v${version}`);
|
|
320
|
+
release = await res.json();
|
|
321
|
+
if (release.message === 'Not Found') {
|
|
322
|
+
console.log(chalk.yellow(`No GitHub release found with name ${version} or v${version}`));
|
|
323
|
+
return '';
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return release.body;
|
|
327
|
+
}
|
|
310
328
|
function findChangelogEntry(changelog, version) {
|
|
311
329
|
let tree = fromMarkdown(changelog);
|
|
312
330
|
let found = false;
|
package/dist/notify-installs.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { mainActor } from './mops.js';
|
|
2
2
|
import { resolvePackages } from './resolve-packages.js';
|
|
3
3
|
export async function notifyInstalls(names) {
|
|
4
|
-
let actor = await mainActor();
|
|
5
4
|
let resolvedPackages = await resolvePackages();
|
|
6
5
|
let packages = names.map(name => [name, resolvedPackages[name]]);
|
|
7
|
-
|
|
6
|
+
if (packages.length) {
|
|
7
|
+
let actor = await mainActor();
|
|
8
|
+
await actor.notifyInstalls(packages);
|
|
9
|
+
}
|
|
8
10
|
}
|
package/dist/package.json
CHANGED
package/notify-installs.ts
CHANGED
|
@@ -2,8 +2,10 @@ import {mainActor} from './mops.js';
|
|
|
2
2
|
import {resolvePackages} from './resolve-packages.js';
|
|
3
3
|
|
|
4
4
|
export async function notifyInstalls(names: string[]) {
|
|
5
|
-
let actor = await mainActor();
|
|
6
5
|
let resolvedPackages = await resolvePackages();
|
|
7
6
|
let packages: [string, string][] = names.map(name => [name, resolvedPackages[name] as string]);
|
|
8
|
-
|
|
7
|
+
if (packages.length) {
|
|
8
|
+
let actor = await mainActor();
|
|
9
|
+
await actor.notifyInstalls(packages);
|
|
10
|
+
}
|
|
9
11
|
}
|