@jakubmazanec/carson-templates 2.0.0-next.439463c → 2.0.0-next.75b0d46

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-next.439463c",
3
+ "version": "2.0.0-next.75b0d46",
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-next.439463c",
37
+ "@jakubmazanec/carson": "0.3.0-next.75b0d46",
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-next.439463c"
48
+ "@jakubmazanec/carson": "0.3.0-next.75b0d46"
49
49
  },
50
50
  "packageManager": "npm@8.19.4",
51
51
  "engines": {
@@ -10,7 +10,8 @@ on:
10
10
  - development
11
11
 
12
12
  jobs:
13
- pull_request_check:
13
+ check_pull_request:
14
+ name: Check pull request
14
15
  runs-on: ubuntu-latest
15
16
  timeout-minutes: 15
16
17
  steps:
@@ -19,6 +20,11 @@ jobs:
19
20
  token: ${{secrets.GITHUB_TOKEN}}
20
21
  fetch-depth: 0
21
22
 
23
+ - name: Configure git
24
+ run: |
25
+ git config user.email "bot@mazanec.dev"
26
+ git config user.name "Bot"
27
+
22
28
  - uses: actions/setup-node@v3
23
29
  with:
24
30
  node-version: 16
@@ -27,6 +33,7 @@ jobs:
27
33
  run: npm ci
28
34
 
29
35
  - name: Check for changes
36
+ if: "github.actor != 'renovate[bot]'"
30
37
  run: |
31
38
  git config core.filemode false
32
39
  git_status=$(git status --porcelain)
@@ -44,6 +51,7 @@ jobs:
44
51
  run: npm test
45
52
 
46
53
  - name: Check for changes
54
+ if: "github.actor != 'renovate[bot]'"
47
55
  run: |
48
56
  git config core.filemode false
49
57
  git_status=$(git status --porcelain)
@@ -58,4 +66,5 @@ jobs:
58
66
  git config --unset core.filemode
59
67
 
60
68
  - name: Check for changesets
61
- run: npx changeset status --since=origin/development
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
@@ -43,7 +43,7 @@ jobs:
43
43
 
44
44
  if [[ -n $git_status ]]; then
45
45
  echo "You have uncommitted changes!"
46
- git status --porcelain
46
+ git diff
47
47
  git config --unset core.filemode
48
48
  exit 1
49
49
  fi
@@ -60,7 +60,7 @@ jobs:
60
60
 
61
61
  if [[ -n $git_status ]]; then
62
62
  echo "You have uncommitted changes!"
63
- git status --porcelain
63
+ git diff
64
64
  git config --unset core.filemode
65
65
  exit 1
66
66
  fi
@@ -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
@@ -167,7 +167,7 @@ jobs:
167
167
 
168
168
  if [[ -n $git_status ]]; then
169
169
  echo "You have uncommitted changes!"
170
- git status --porcelain
170
+ git diff
171
171
  git config --unset core.filemode
172
172
  exit 1
173
173
  fi
@@ -184,7 +184,7 @@ jobs:
184
184
 
185
185
  if [[ -n $git_status ]]; then
186
186
  echo "You have uncommitted changes!"
187
- git status --porcelain
187
+ git diff
188
188
  git config --unset core.filemode
189
189
  exit 1
190
190
  fi
@@ -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
@@ -260,7 +260,7 @@ jobs:
260
260
 
261
261
  if [[ -n $git_status ]]; then
262
262
  echo "You have uncommitted changes!"
263
- git status --porcelain
263
+ git diff
264
264
  git config --unset core.filemode
265
265
  exit 1
266
266
  fi
@@ -277,7 +277,7 @@ jobs:
277
277
 
278
278
  if [[ -n $git_status ]]; then
279
279
  echo "You have uncommitted changes!"
280
- git status --porcelain
280
+ git diff
281
281
  git config --unset core.filemode
282
282
  exit 1
283
283
  fi
@@ -306,202 +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: Check for changes
340
- run: |
341
- git config core.filemode false
342
- git_status=$(git status --porcelain)
343
-
344
- if [[ -n $git_status ]]; then
345
- echo "You have uncommitted changes!"
346
- git status --porcelain
347
- git config --unset core.filemode
348
- exit 1
349
- fi
350
-
351
- git config --unset core.filemode
352
-
353
- - name: Run tests
354
- run: npm test
355
-
356
- - name: Check for changes
357
- run: |
358
- git config core.filemode false
359
- git_status=$(git status --porcelain)
360
-
361
- if [[ -n $git_status ]]; then
362
- echo "You have uncommitted changes!"
363
- git status --porcelain
364
- git config --unset core.filemode
365
- exit 1
366
- fi
367
-
368
- git config --unset core.filemode
369
-
370
- - name: Build packages
371
- run: npm run build
372
-
373
- - name: Generate changeset
374
- uses: actions/github-script@v6
375
- with:
376
- script: |
377
- let { promises: fs } = require('fs');
378
-
379
- async function getPackagesNames(files) {
380
- let names = [];
381
-
382
- for (let file of files) {
383
- let data = JSON.parse(await fs.readFile(file, 'utf8'));
384
-
385
- if (!data.private) {
386
- names.push(data.name);
387
- }
388
- }
389
-
390
- return names;
391
- }
392
-
393
- async function createChangeset(fileName, packageBumps, packages) {
394
- let message = '';
395
-
396
- for (let [packageName, bump] of packageBumps) {
397
- message =
398
- message + `Dependency \`${packageName}\` updated to \`${bump}\`.\n`;
399
- }
400
-
401
- let header = packages
402
- .map((packageName) => `'${packageName}': patch`)
403
- .join('\n');
404
-
405
- await fs.writeFile(fileName, `---\n${header}\n---\n${message.trim()}\n`);
406
- }
407
-
408
- async function getBumps(files) {
409
- let bumps = new Map();
410
-
411
- for (let file of files) {
412
- let { stdout: changes } = await exec.getExecOutput('git', ['show', file]);
413
-
414
- for (let change of changes.split('\n')) {
415
- if (!change.startsWith('+ ')) {
416
- continue;
417
- }
418
-
419
- let match = change.match(/"(.*?)"/g);
420
-
421
- bumps.set(match[0].replace(/"/g, ''), match[1].replace(/"/g, ''));
422
- }
423
- }
424
-
425
- return bumps;
426
- }
427
-
428
- let branch = await exec.getExecOutput('git branch --show-current');
429
-
430
- if (!branch.stdout.startsWith('renovate/')) {
431
- console.log('Not a renovate branch, skipping...');
432
-
433
- return;
434
- }
435
-
436
- let diffOutput = await exec.getExecOutput('git diff --name-only HEAD~1');
437
- let diffFiles = diffOutput.stdout.split('\n');
438
-
439
- if (diffFiles.find((diffFile) => diffFile.startsWith('.changeset'))) {
440
- console.log('Changeset already exists, skipping...');
441
-
442
- return;
443
- }
444
-
445
- let files = diffFiles
446
- .filter((file) => file !== 'package.json') // skip root package.json
447
- .filter((file) => file.includes('package.json'));
448
- let packageNames = await getPackagesNames(files);
449
-
450
- if (!packageNames.length) {
451
- console.log('No package.json changes to published packages, skipping...');
452
-
453
- await exec.exec('npx', ['changeset', '--empty']);
454
- await exec.exec('git', ['add', '.', '--all']);
455
- await exec.exec('git commit -C HEAD --amend --no-edit');
456
- await exec.exec('git push --force');
457
-
458
- return;
459
- }
460
-
461
- let { stdout: shortHash } = await exec.getExecOutput(
462
- 'git rev-parse --short HEAD',
463
- );
464
- let fileName = `.changeset/renovate-${shortHash.trim()}.md`;
465
- let packageBumps = await getBumps(files);
466
-
467
- await createChangeset(fileName, packageBumps, packageNames);
468
- await exec.exec('git', ['add', '.', '--all']);
469
- await exec.exec('git commit -C HEAD --amend --no-edit');
470
- await exec.exec('git push --force');
471
-
472
- - name: Update Carson
473
- uses: actions/github-script@v6
474
- with:
475
- script: |
476
- let branch = await exec.getExecOutput('git branch --show-current');
477
-
478
- if (!branch.stdout.startsWith('renovate/')) {
479
- console.log('Not a renovate branch, skipping...');
480
-
481
- return;
482
- }
483
-
484
- await exec.exec('npm', ['install']);
485
- await exec.exec('git', ['add', '.', '--all']);
486
- await exec.exec('git commit -m"Run Carson update [skip actions]"');
487
- await exec.exec('git push --force');
488
-
489
- - name: Authenticate to npm registry
490
- run: |
491
- echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
492
- env:
493
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
494
-
495
- - name: Version packages
496
- run: |
497
- npx changeset version --snapshot unstable --snapshot-prerelease-template "{tag}.{commit}"
498
- git status
499
- env:
500
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
501
-
502
- - name: Publish packages
503
- run: |
504
- npx changeset publish --tag unstable --no-git-tag
505
- env:
506
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
507
- 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 -m"Add changeset [skip actions]"');
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 -m"Add changeset [skip actions]"');
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 -m"Run Carson update [skip actions]"
135
+ git push --force