@jakubmazanec/carson-templates 2.0.0-unstable.d49edce → 2.0.0-unstable.d62cd2d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/carson-templates",
3
- "version": "2.0.0-unstable.d49edce",
3
+ "version": "2.0.0-unstable.d62cd2d",
4
4
  "description": "Collection of Carson templates.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "semver": "^7.3.6"
35
35
  },
36
36
  "devDependencies": {
37
- "@jakubmazanec/carson": "0.3.0-unstable.d49edce",
37
+ "@jakubmazanec/carson": "0.3.0-unstable.d62cd2d",
38
38
  "@jakubmazanec/fs-utils": "^0.1.0",
39
39
  "@jest/globals": "^29.5.0",
40
40
  "@types/fs-extra": "^9.0.13",
@@ -45,7 +45,7 @@
45
45
  "zen-observable": "^0.10.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@jakubmazanec/carson": "0.3.0-unstable.d49edce"
48
+ "@jakubmazanec/carson": "0.3.0-unstable.d62cd2d"
49
49
  },
50
50
  "packageManager": "npm@8.19.4",
51
51
  "engines": {
@@ -10,17 +10,21 @@ on:
10
10
  - development
11
11
 
12
12
  jobs:
13
- pull_request_check:
13
+ check_pull_request:
14
14
  name: Check pull request
15
15
  runs-on: ubuntu-latest
16
16
  timeout-minutes: 15
17
- if: "github.actor != 'renovate[bot]'"
18
17
  steps:
19
18
  - uses: actions/checkout@v3
20
19
  with:
21
20
  token: ${{secrets.GITHUB_TOKEN}}
22
21
  fetch-depth: 0
23
22
 
23
+ - name: Configure git
24
+ run: |
25
+ git config user.email "bot@mazanec.dev"
26
+ git config user.name "Bot"
27
+
24
28
  - uses: actions/setup-node@v3
25
29
  with:
26
30
  node-version: 16
@@ -29,6 +33,7 @@ jobs:
29
33
  run: npm ci
30
34
 
31
35
  - name: Check for changes
36
+ if: "github.actor != 'renovate[bot]'"
32
37
  run: |
33
38
  git config core.filemode false
34
39
  git_status=$(git status --porcelain)
@@ -46,6 +51,7 @@ jobs:
46
51
  run: npm test
47
52
 
48
53
  - name: Check for changes
54
+ if: "github.actor != 'renovate[bot]'"
49
55
  run: |
50
56
  git config core.filemode false
51
57
  git_status=$(git status --porcelain)
@@ -60,25 +66,5 @@ jobs:
60
66
  git config --unset core.filemode
61
67
 
62
68
  - name: Check for changesets
63
- run: npx changeset status --since=origin/development
64
-
65
- renovate_pull_request_check:
66
- name: Check Renovate bot pull request
67
- runs-on: ubuntu-latest
68
- timeout-minutes: 15
69
- if: "github.actor == 'renovate[bot]'"
70
- steps:
71
- - uses: actions/checkout@v3
72
- with:
73
- token: ${{secrets.GITHUB_TOKEN}}
74
- fetch-depth: 0
75
-
76
- - uses: actions/setup-node@v3
77
- with:
78
- node-version: 16
79
-
80
- - name: Install packages
81
- run: npm ci
82
-
83
- - name: Run tests
84
- run: npm test
69
+ if: "github.actor != 'renovate[bot]'"
70
+ run: npx changeset status --since=origin/<%- getDevelopmentBranch(workspace) %>
@@ -7,7 +7,7 @@ name: Release
7
7
  on: [push, workflow_dispatch]
8
8
 
9
9
  jobs:
10
- main_branch_release:
10
+ release_main_branch:
11
11
  name: Main branch release
12
12
  runs-on: ubuntu-latest
13
13
  timeout-minutes: 15
@@ -131,7 +131,7 @@ jobs:
131
131
  git merge <%- getMainBranch(workspace) %> --no-verify
132
132
  git push -u origin <%- getDevelopmentBranch(workspace) %> --no-verify
133
133
 
134
- development_branch_release:
134
+ release_development_branch:
135
135
  name: Development branch release
136
136
  runs-on: ubuntu-latest
137
137
  timeout-minutes: 15
@@ -224,7 +224,7 @@ jobs:
224
224
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
225
225
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
226
226
 
227
- feature_branch_release:
227
+ release_feature_branch:
228
228
  name: Feature branch release
229
229
  runs-on: ubuntu-latest
230
230
  timeout-minutes: 15
@@ -306,174 +306,3 @@ jobs:
306
306
  env:
307
307
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
308
308
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
309
-
310
- renovate_bot_release:
311
- name: Renovate bot release
312
- runs-on: ubuntu-latest
313
- timeout-minutes: 15
314
- if: "github.ref_name != '<%- getMainBranch(workspace) %>' && github.ref_name != '<%- getDevelopmentBranch(workspace) %>' && github.actor == 'renovate[bot]'"
315
- steps:
316
- - name: Cancel previous runs
317
- uses: styfle/cancel-workflow-action@0.11.0
318
- with:
319
- access_token: ${{ secrets.GITHUB_TOKEN }}
320
-
321
- - uses: actions/checkout@v3
322
- with:
323
- token: ${{ secrets.GITHUB_TOKEN }}
324
- fetch-depth: 0
325
-
326
- - name: Configure git
327
- run: |
328
- git config user.email "bot@mazanec.dev"
329
- git config user.name "Bot"
330
-
331
- - uses: actions/setup-node@v3
332
- with:
333
- node-version: 16
334
- registry-url: 'https://registry.npmjs.org'
335
-
336
- - name: Install packages
337
- run: npm ci
338
-
339
- - name: Run tests
340
- run: npm test
341
-
342
- - name: Build packages
343
- run: npm run build
344
-
345
- - name: Generate changeset
346
- uses: actions/github-script@v6
347
- with:
348
- script: |
349
- let { promises: fs } = require('fs');
350
-
351
- async function getPackagesNames(files) {
352
- let names = [];
353
-
354
- for (let file of files) {
355
- let data = JSON.parse(await fs.readFile(file, 'utf8'));
356
-
357
- if (!data.private) {
358
- names.push(data.name);
359
- }
360
- }
361
-
362
- return names;
363
- }
364
-
365
- async function createChangeset(fileName, packageBumps, packages) {
366
- let message = '';
367
-
368
- for (let [packageName, bump] of packageBumps) {
369
- message =
370
- message + `Dependency \`${packageName}\` updated to \`${bump}\`.\n`;
371
- }
372
-
373
- let header = packages
374
- .map((packageName) => `'${packageName}': patch`)
375
- .join('\n');
376
-
377
- await fs.writeFile(fileName, `---\n${header}\n---\n${message.trim()}\n`);
378
- }
379
-
380
- async function getBumps(files) {
381
- let bumps = new Map();
382
-
383
- for (let file of files) {
384
- let { stdout: changes } = await exec.getExecOutput('git', ['show', file]);
385
-
386
- for (let change of changes.split('\n')) {
387
- if (!change.startsWith('+ ')) {
388
- continue;
389
- }
390
-
391
- let match = change.match(/"(.*?)"/g);
392
-
393
- bumps.set(match[0].replace(/"/g, ''), match[1].replace(/"/g, ''));
394
- }
395
- }
396
-
397
- return bumps;
398
- }
399
-
400
- let branch = await exec.getExecOutput('git branch --show-current');
401
-
402
- if (!branch.stdout.startsWith('renovate/')) {
403
- console.log('Not a renovate branch, skipping...');
404
-
405
- return;
406
- }
407
-
408
- let diffOutput = await exec.getExecOutput('git diff --name-only HEAD~1');
409
- let diffFiles = diffOutput.stdout.split('\n');
410
-
411
- if (diffFiles.find((diffFile) => diffFile.startsWith('.changeset'))) {
412
- console.log('Changeset already exists, skipping...');
413
-
414
- return;
415
- }
416
-
417
- let files = diffFiles
418
- .filter((file) => file !== 'package.json') // skip root package.json
419
- .filter((file) => file.includes('package.json'));
420
- let packageNames = await getPackagesNames(files);
421
-
422
- if (!packageNames.length) {
423
- console.log('No package.json changes to published packages, skipping...');
424
-
425
- await exec.exec('npx', ['changeset', '--empty']);
426
- await exec.exec('git', ['add', '.', '--all']);
427
- await exec.exec('git commit -C HEAD --amend --no-edit');
428
- await exec.exec('git push --force');
429
-
430
- return;
431
- }
432
-
433
- let { stdout: shortHash } = await exec.getExecOutput(
434
- 'git rev-parse --short HEAD',
435
- );
436
- let fileName = `.changeset/renovate-${shortHash.trim()}.md`;
437
- let packageBumps = await getBumps(files);
438
-
439
- await createChangeset(fileName, packageBumps, packageNames);
440
- await exec.exec('git', ['add', '.', '--all']);
441
- await exec.exec('git commit -C HEAD --amend --no-edit');
442
- await exec.exec('git push --force');
443
-
444
- - name: Update Carson
445
- uses: actions/github-script@v6
446
- with:
447
- script: |
448
- let branch = await exec.getExecOutput('git branch --show-current');
449
-
450
- if (!branch.stdout.startsWith('renovate/')) {
451
- console.log('Not a renovate branch, skipping...');
452
-
453
- return;
454
- }
455
-
456
- await exec.exec('npm', ['install']);
457
- await exec.exec('git', ['add', '.', '--all']);
458
- await exec.exec('git commit -C HEAD --amend --no-edit');
459
- await exec.exec('git push --force');
460
-
461
- - name: Authenticate to npm registry
462
- run: |
463
- echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
464
- env:
465
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
466
-
467
- - name: Version packages
468
- run: |
469
- npx changeset version --snapshot unstable --snapshot-prerelease-template "{tag}.{commit}"
470
- git status
471
- env:
472
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
473
-
474
- - name: Publish packages
475
- run: |
476
- npx changeset publish --tag unstable --no-git-tag
477
- env:
478
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
479
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,135 @@
1
+ ---
2
+ to: '.github/workflows/update-pull-request.yaml'
3
+ strategy: overwrite
4
+ ---
5
+ name: Update pull request
6
+
7
+ on:
8
+ pull_request_target:
9
+ branches:
10
+ - development
11
+
12
+ jobs:
13
+ update_pull_request:
14
+ name: Update pull request
15
+ if: github.actor == 'renovate[bot]'
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 15
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ with:
21
+ ref: ${{ github.head_ref }}
22
+ token: ${{secrets.GITHUB_TOKEN}}
23
+ fetch-depth: 0
24
+
25
+ - name: Configure git
26
+ run: |
27
+ git config user.email "bot@mazanec.dev"
28
+ git config user.name "Bot"
29
+
30
+ - uses: actions/setup-node@v3
31
+ with:
32
+ node-version: 16
33
+
34
+ - name: Install packages
35
+ run: npm ci
36
+
37
+ - name: Generate changeset
38
+ uses: actions/github-script@v6
39
+ if: ${{ github.actor == 'renovate[bot]' }}
40
+ with:
41
+ script: |
42
+ let { promises: fs } = require('fs');
43
+
44
+ async function getPackagesNames(files) {
45
+ let names = [];
46
+
47
+ for (let file of files) {
48
+ let data = JSON.parse(await fs.readFile(file, 'utf8'));
49
+
50
+ if (!data.private) {
51
+ names.push(data.name);
52
+ }
53
+ }
54
+
55
+ return names;
56
+ }
57
+
58
+ async function createChangeset(fileName, packageBumps, packages) {
59
+ let message = '';
60
+
61
+ for (let [packageName, bump] of packageBumps) {
62
+ message =
63
+ message + `Dependency \`${packageName}\` updated to \`${bump}\`.\n`;
64
+ }
65
+
66
+ let header = packages
67
+ .map((packageName) => `'${packageName}': patch`)
68
+ .join('\n');
69
+
70
+ await fs.writeFile(fileName, `---\n${header}\n---\n${message.trim()}\n`);
71
+ }
72
+
73
+ async function getBumps(files) {
74
+ let bumps = new Map();
75
+
76
+ for (let file of files) {
77
+ let { stdout: changes } = await exec.getExecOutput('git', ['show', file]);
78
+
79
+ for (let change of changes.split('\n')) {
80
+ if (!change.startsWith('+ ')) {
81
+ continue;
82
+ }
83
+
84
+ let match = change.match(/"(.*?)"/g);
85
+
86
+ bumps.set(match[0].replace(/"/g, ''), match[1].replace(/"/g, ''));
87
+ }
88
+ }
89
+
90
+ return bumps;
91
+ }
92
+
93
+ let diffOutput = await exec.getExecOutput('git diff --name-only HEAD~1');
94
+ let diffFiles = diffOutput.stdout.split('\n');
95
+
96
+ if (diffFiles.find((diffFile) => diffFile.startsWith('.changeset'))) {
97
+ console.log('Changeset already exists, skipping...');
98
+
99
+ return;
100
+ }
101
+
102
+ let files = diffFiles
103
+ .filter((file) => file !== 'package.json') // skip root package.json
104
+ .filter((file) => file.includes('package.json'));
105
+ let packageNames = await getPackagesNames(files);
106
+
107
+ if (!packageNames.length) {
108
+ console.log('No package.json changes to published packages, skipping...');
109
+
110
+ await exec.exec('npx', ['changeset', '--empty']);
111
+ await exec.exec('git', ['add', '.', '--all']);
112
+ await exec.exec('git commit -C HEAD --amend --no-edit');
113
+ await exec.exec('git push --force');
114
+
115
+ return;
116
+ }
117
+
118
+ let { stdout: shortHash } = await exec.getExecOutput(
119
+ 'git rev-parse --short HEAD',
120
+ );
121
+ let fileName = `.changeset/renovate-${shortHash.trim()}.md`;
122
+ let packageBumps = await getBumps(files);
123
+
124
+ await createChangeset(fileName, packageBumps, packageNames);
125
+ await exec.exec('git', ['add', '.', '--all']);
126
+ await exec.exec('git commit -C HEAD --amend --no-edit');
127
+ await exec.exec('git push --force');
128
+
129
+ - name: Update Carson
130
+ if: ${{ github.actor == 'renovate[bot]' }}
131
+ run: |
132
+ npm install
133
+ git add . --all
134
+ git commit -C HEAD --amend --no-edit
135
+ git push --force