@jakubmazanec/carson-templates 2.0.0-next.dc4435e → 2.0.0-next.f3375f0
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 +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/package.json +7 -6
- package/src/main.ts +1 -1
- package/templates/projects/carson-templates/package.json.ejs +2 -2
- package/templates/projects/changesets-changelog/package.json.ejs +2 -2
- package/templates/projects/eslint-config/package.json.ejs +2 -2
- package/templates/projects/library/package.json.ejs +2 -2
- package/templates/workspace/.github/workflows/merge-to-main-branch.yaml.ejs +1 -1
- package/templates/workspace/.github/workflows/pull-request.yaml.ejs +12 -4
- package/templates/workspace/.github/workflows/release.yaml.ejs +27 -15
- package/templates/workspace/.github/workflows/update-pull-request.yaml.ejs +131 -0
- package/templates/workspace/package.json.ejs +2 -2
package/README.md
CHANGED
package/dist/main.js
CHANGED
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {type Project, type Workspace} from '@jakubmazanec/carson';\nimport fs from 'node:fs';\nimport {createRequire} from 'node:module';\nimport semver from 'semver';\n\nexport {default as lodash} from 'lodash';\nexport {default as semver} from 'semver';\n\nconst CARSON_PACKAGE_NAME = '@jakubmazanec/carson';\nconst TEMPLATE_PACKAGE_NAME = '@jakubmazanec/carson-templates';\nconst MAIN_BRANCH_NAMES = new Set(['main', 'master']);\nconst DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);\n\nlet require = createRequire(import.meta.url);\nlet carsonPackageVersion =\n semver\n .minVersion(\n (\n JSON.parse(\n fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {\n encoding: 'utf8',\n }),\n ) as {peerDependencies: Record<string, string>}\n ).peerDependencies[CARSON_PACKAGE_NAME] ?? '^1.0.0',\n )\n ?.format() ?? '1.0.0';\nlet isCarsonPackageVersionPrerelease = !!semver.prerelease(carsonPackageVersion)?.length;\nlet templatesPackageVersion = (\n JSON.parse(\n fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {\n encoding: 'utf8',\n }),\n ) as {version: string}\n).version;\nlet isTemplatesPackageVersionPrerelease = !!semver.prerelease(templatesPackageVersion)?.length;\n\nconst DEPENDENCY_VERSIONS: Record<string, string> = {\n '@changesets/cli': '^2.0.0',\n [CARSON_PACKAGE_NAME]: isCarsonPackageVersionPrerelease\n ? carsonPackageVersion\n : `^${carsonPackageVersion}`,\n [TEMPLATE_PACKAGE_NAME]: isTemplatesPackageVersionPrerelease\n ? templatesPackageVersion\n : `^${templatesPackageVersion}`,\n '@jest/globals': '^29.0.0',\n '@swc/cli': '^0.1.0',\n '@swc/core': '^1.0.0',\n '@testing-library/jest-dom': '^5.0.0',\n '@types/node': '^
|
|
1
|
+
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {type Project, type Workspace} from '@jakubmazanec/carson';\nimport fs from 'node:fs';\nimport {createRequire} from 'node:module';\nimport semver from 'semver';\n\nexport {default as lodash} from 'lodash';\nexport {default as semver} from 'semver';\n\nconst CARSON_PACKAGE_NAME = '@jakubmazanec/carson';\nconst TEMPLATE_PACKAGE_NAME = '@jakubmazanec/carson-templates';\nconst MAIN_BRANCH_NAMES = new Set(['main', 'master']);\nconst DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);\n\nlet require = createRequire(import.meta.url);\nlet carsonPackageVersion =\n semver\n .minVersion(\n (\n JSON.parse(\n fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {\n encoding: 'utf8',\n }),\n ) as {peerDependencies: Record<string, string>}\n ).peerDependencies[CARSON_PACKAGE_NAME] ?? '^1.0.0',\n )\n ?.format() ?? '1.0.0';\nlet isCarsonPackageVersionPrerelease = !!semver.prerelease(carsonPackageVersion)?.length;\nlet templatesPackageVersion = (\n JSON.parse(\n fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {\n encoding: 'utf8',\n }),\n ) as {version: string}\n).version;\nlet isTemplatesPackageVersionPrerelease = !!semver.prerelease(templatesPackageVersion)?.length;\n\nconst DEPENDENCY_VERSIONS: Record<string, string> = {\n '@changesets/cli': '^2.0.0',\n [CARSON_PACKAGE_NAME]: isCarsonPackageVersionPrerelease\n ? carsonPackageVersion\n : `^${carsonPackageVersion}`,\n [TEMPLATE_PACKAGE_NAME]: isTemplatesPackageVersionPrerelease\n ? templatesPackageVersion\n : `^${templatesPackageVersion}`,\n '@jest/globals': '^29.0.0',\n '@swc/cli': '^0.1.0',\n '@swc/core': '^1.0.0',\n '@testing-library/jest-dom': '^5.0.0',\n '@types/node': '^20.0.0',\n chokidar: '^3.0.0',\n 'cross-env': '^7.0.0',\n 'del-cli': '^5.0.0',\n eslint: '^8.0.0',\n jest: '^29.0.0',\n 'patch-package': '^6.0.0',\n prettier: '^3.0.0',\n 'prettier-plugin-packagejson': '^2.0.0',\n 'ts-jest': '^29.0.0',\n 'ts-node': '^10.0.0',\n turbo: '^1.0.0',\n typedoc: '^0.24.0',\n 'typedoc-plugin-markdown': '^3.0.0',\n typescript: '^5.0.0',\n};\n\nexport function getMainBranch(workspace: Workspace | Workspace<false>) {\n for (let branch of workspace.repository?.branches ?? []) {\n if (MAIN_BRANCH_NAMES.has(branch)) {\n return branch;\n }\n }\n\n return undefined;\n}\n\nexport function getDevelopmentBranch(workspace: Workspace | Workspace<false>) {\n for (let branch of workspace.repository?.branches ?? []) {\n if (DEVELOPMENT_BRANCH_NAMES.has(branch)) {\n return branch;\n }\n }\n\n return undefined;\n}\n\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]!.replace(/\\D/, ''));\n}\n\nexport function getDependencies(dependencies: string[], workspace: Workspace | Workspace<false>) {\n const result: Record<string, string> = {};\n\n for (const dependency of dependencies) {\n const version = DEPENDENCY_VERSIONS[dependency];\n\n if (version) {\n result[dependency] = version;\n }\n }\n\n const projectNames = workspace.projects.map((project) => project.name);\n\n for (const [dependencyName, dependencyVersion] of Object.entries(result)) {\n if (dependencyName === TEMPLATE_PACKAGE_NAME) {\n continue;\n }\n\n const installedDependency = workspace.allDependencies.find(\n (dependency) => dependencyName === dependency.name,\n );\n\n // if the dependency is already installed in the workspace, we might want to use that existing version\n if (installedDependency) {\n const version = [...installedDependency.exactVersions].sort().reverse()[0] as string;\n\n // if the dependency is actually a project in the workspace, we use existing version\n if (projectNames.includes(dependencyName)) {\n if (semver.prerelease(version)?.length) {\n result[dependencyName] = version;\n } else {\n result[dependencyName] = `^${version}`;\n }\n }\n\n // we use existing version only if major versions match; we don't want the user of this template to be able to overwrite any major version number and use potentially incompatible version\n if (getMajorVersion(version) === getMajorVersion(dependencyVersion)) {\n if (semver.prerelease(version)?.length) {\n result[dependencyName] = version;\n } else {\n result[dependencyName] = `^${version}`;\n }\n }\n }\n }\n\n return result;\n}\n\nexport function getReferences(\n workspace: Workspace | Workspace<false>,\n project: Project | Project<false>,\n) {\n let references = [];\n let currentProject = project;\n\n for (let dependency of workspace.allDependencies) {\n for (let project of workspace.projects) {\n if (dependency.name === project.name) {\n for (let dependencyProject of dependency.projects) {\n if (dependencyProject.name === currentProject.name) {\n references.push({\n path: `${currentProject.relativePath\n .split('/')\n .map(() => '..')\n .join('/')}/${project.relativePath}`,\n });\n }\n }\n }\n }\n }\n\n references.sort((a, b) => a.path.localeCompare(b.path));\n\n return references;\n}\n"],"names":["fs","createRequire","semver","default","lodash","CARSON_PACKAGE_NAME","TEMPLATE_PACKAGE_NAME","MAIN_BRANCH_NAMES","Set","DEVELOPMENT_BRANCH_NAMES","require","url","carsonPackageVersion","minVersion","JSON","parse","readFileSync","resolve","encoding","peerDependencies","format","isCarsonPackageVersionPrerelease","prerelease","length","templatesPackageVersion","version","isTemplatesPackageVersionPrerelease","DEPENDENCY_VERSIONS","chokidar","eslint","jest","prettier","turbo","typedoc","typescript","getMainBranch","workspace","branch","repository","branches","has","undefined","getDevelopmentBranch","getMajorVersion","Number","split","replace","getDependencies","dependencies","result","dependency","projectNames","projects","map","project","name","dependencyName","dependencyVersion","Object","entries","installedDependency","allDependencies","find","exactVersions","sort","reverse","includes","getReferences","references","currentProject","dependencyProject","push","path","relativePath","join","a","b","localeCompare"],"mappings":"AACA,OAAOA,QAAQ,UAAU;AACzB,SAAQC,aAAa,QAAO,cAAc;AAC1C,OAAOC,YAAY,SAAS;AAE5B,SAAQC,WAAWC,MAAM,QAAO,SAAS;AACzC,SAAQD,WAAWD,MAAM,QAAO,SAAS;AAEzC,MAAMG,sBAAsB;AAC5B,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB,IAAIC,IAAI;IAAC;IAAQ;CAAS;AACpD,MAAMC,2BAA2B,IAAID,IAAI;IAAC;IAAe;IAAW;CAAM;AAE1E,IAAIE,UAAUT,cAAc,YAAYU,GAAG;AAC3C,IAAIC,uBACFV,OACGW,UAAU,CACT,AACEC,KAAKC,KAAK,CACRf,GAAGgB,YAAY,CAACN,QAAQO,OAAO,CAAC,CAAC,EAAEX,sBAAsB,aAAa,CAAC,GAAG;IACxEY,UAAU;AACZ,IAEFC,gBAAgB,CAACd,oBAAoB,IAAI,WAE3Ce,YAAY;AAClB,IAAIC,mCAAmC,CAAC,CAACnB,OAAOoB,UAAU,CAACV,uBAAuBW;AAClF,IAAIC,0BAA0B,AAC5BV,KAAKC,KAAK,CACRf,GAAGgB,YAAY,CAACN,QAAQO,OAAO,CAAC,CAAC,EAAEX,sBAAsB,aAAa,CAAC,GAAG;IACxEY,UAAU;AACZ,IAEFO,OAAO;AACT,IAAIC,sCAAsC,CAAC,CAACxB,OAAOoB,UAAU,CAACE,0BAA0BD;AAExF,MAAMI,sBAA8C;IAClD,mBAAmB;IACnB,CAACtB,oBAAoB,EAAEgB,mCACnBT,uBACA,CAAC,CAAC,EAAEA,qBAAqB,CAAC;IAC9B,CAACN,sBAAsB,EAAEoB,sCACrBF,0BACA,CAAC,CAAC,EAAE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F;YACF;QACF;IACF;IAEAL,WAAWJ,IAAI,CAAC,CAACW,GAAGC,IAAMD,EAAEH,IAAI,CAACK,aAAa,CAACD,EAAEJ,IAAI;IAErD,OAAOJ;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/carson-templates",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.f3375f0",
|
|
4
4
|
"description": "Collection of Carson templates.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,21 +34,22 @@
|
|
|
34
34
|
"semver": "^7.3.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@jakubmazanec/carson": "0.3.0-next.
|
|
38
|
-
"@jakubmazanec/fs-utils": "
|
|
37
|
+
"@jakubmazanec/carson": "0.3.0-next.f3375f0",
|
|
38
|
+
"@jakubmazanec/fs-utils": "0.2.0-next.f3375f0",
|
|
39
39
|
"@jest/globals": "^29.5.0",
|
|
40
40
|
"@types/fs-extra": "^9.0.13",
|
|
41
41
|
"@types/lodash": "^4.14.195",
|
|
42
|
+
"@types/node": "^20.8.5",
|
|
42
43
|
"execa": "^8.0.1",
|
|
43
44
|
"fast-glob": "^3.2.11",
|
|
44
45
|
"fs-extra": "^10.0.1",
|
|
45
46
|
"zen-observable": "^0.10.0"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@jakubmazanec/carson": "0.3.0-next.
|
|
49
|
+
"@jakubmazanec/carson": "0.3.0-next.f3375f0"
|
|
49
50
|
},
|
|
50
|
-
"packageManager": "npm@
|
|
51
|
+
"packageManager": "npm@10.1.0",
|
|
51
52
|
"engines": {
|
|
52
|
-
"node": "
|
|
53
|
+
"node": "^20.8.0"
|
|
53
54
|
}
|
|
54
55
|
}
|
package/src/main.ts
CHANGED
|
@@ -46,7 +46,7 @@ const DEPENDENCY_VERSIONS: Record<string, string> = {
|
|
|
46
46
|
'@swc/cli': '^0.1.0',
|
|
47
47
|
'@swc/core': '^1.0.0',
|
|
48
48
|
'@testing-library/jest-dom': '^5.0.0',
|
|
49
|
-
'@types/node': '^
|
|
49
|
+
'@types/node': '^20.0.0',
|
|
50
50
|
chokidar: '^3.0.0',
|
|
51
51
|
'cross-env': '^7.0.0',
|
|
52
52
|
'del-cli': '^5.0.0',
|
|
@@ -19,9 +19,9 @@ let packageJson = {
|
|
|
19
19
|
test: 'jest --passWithNoTests',
|
|
20
20
|
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
21
21
|
},
|
|
22
|
-
packageManager: 'npm@
|
|
22
|
+
packageManager: 'npm@10.1.0',
|
|
23
23
|
engines: {
|
|
24
|
-
node: '
|
|
24
|
+
node: '^20.8.0',
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
27
|
-%>
|
|
@@ -24,9 +24,9 @@ let packageJson = {
|
|
|
24
24
|
test: 'jest --passWithNoTests',
|
|
25
25
|
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
26
26
|
},
|
|
27
|
-
packageManager: 'npm@
|
|
27
|
+
packageManager: 'npm@10.1.0',
|
|
28
28
|
engines: {
|
|
29
|
-
node: '
|
|
29
|
+
node: '^20.8.0',
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
-%>
|
|
@@ -26,9 +26,9 @@ let packageJson = lodash.merge(
|
|
|
26
26
|
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
27
27
|
},
|
|
28
28
|
devDependencies: developmentDependencies,
|
|
29
|
-
packageManager: 'npm@
|
|
29
|
+
packageManager: 'npm@10.1.0',
|
|
30
30
|
engines: {
|
|
31
|
-
node: '
|
|
31
|
+
node: '^20.8.0',
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
project.config.overrides?.packageJson ?? {},
|
|
@@ -10,18 +10,25 @@ on:
|
|
|
10
10
|
- development
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
|
-
|
|
13
|
+
check_pull_request:
|
|
14
|
+
name: Check pull request
|
|
15
|
+
if: ${{ github.actor != 'renovate[bot]' }}
|
|
14
16
|
runs-on: ubuntu-latest
|
|
15
17
|
timeout-minutes: 15
|
|
16
18
|
steps:
|
|
17
19
|
- uses: actions/checkout@v3
|
|
18
20
|
with:
|
|
19
|
-
token: ${{secrets.
|
|
21
|
+
token: ${{secrets.PAT}}
|
|
20
22
|
fetch-depth: 0
|
|
21
23
|
|
|
24
|
+
- name: Configure git
|
|
25
|
+
run: |
|
|
26
|
+
git config user.email "bot@mazanec.dev"
|
|
27
|
+
git config user.name "Bot"
|
|
28
|
+
|
|
22
29
|
- uses: actions/setup-node@v3
|
|
23
30
|
with:
|
|
24
|
-
node-version:
|
|
31
|
+
node-version: 20
|
|
25
32
|
|
|
26
33
|
- name: Install packages
|
|
27
34
|
run: npm ci
|
|
@@ -58,4 +65,5 @@ jobs:
|
|
|
58
65
|
git config --unset core.filemode
|
|
59
66
|
|
|
60
67
|
- name: Check for changesets
|
|
61
|
-
|
|
68
|
+
if: "github.actor != 'renovate[bot]'"
|
|
69
|
+
run: npx changeset status --since=origin/<%- getDevelopmentBranch(workspace) %>
|
|
@@ -7,11 +7,14 @@ name: Release
|
|
|
7
7
|
on: [push, workflow_dispatch]
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
-
|
|
10
|
+
release_main_branch:
|
|
11
11
|
name: Main branch release
|
|
12
|
+
if: ${{ github.ref_name == '<%- getMainBranch(workspace) %>' }}
|
|
12
13
|
runs-on: ubuntu-latest
|
|
13
14
|
timeout-minutes: 15
|
|
14
|
-
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
id-token: write
|
|
15
18
|
steps:
|
|
16
19
|
- name: Cancel previous runs
|
|
17
20
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
@@ -30,7 +33,7 @@ jobs:
|
|
|
30
33
|
|
|
31
34
|
- uses: actions/setup-node@v3
|
|
32
35
|
with:
|
|
33
|
-
node-version:
|
|
36
|
+
node-version: 20
|
|
34
37
|
registry-url: 'https://registry.npmjs.org'
|
|
35
38
|
|
|
36
39
|
- name: Install packages
|
|
@@ -43,7 +46,7 @@ jobs:
|
|
|
43
46
|
|
|
44
47
|
if [[ -n $git_status ]]; then
|
|
45
48
|
echo "You have uncommitted changes!"
|
|
46
|
-
git
|
|
49
|
+
git diff
|
|
47
50
|
git config --unset core.filemode
|
|
48
51
|
exit 1
|
|
49
52
|
fi
|
|
@@ -60,7 +63,7 @@ jobs:
|
|
|
60
63
|
|
|
61
64
|
if [[ -n $git_status ]]; then
|
|
62
65
|
echo "You have uncommitted changes!"
|
|
63
|
-
git
|
|
66
|
+
git diff
|
|
64
67
|
git config --unset core.filemode
|
|
65
68
|
exit 1
|
|
66
69
|
fi
|
|
@@ -96,6 +99,7 @@ jobs:
|
|
|
96
99
|
env:
|
|
97
100
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
98
101
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
102
|
+
NPM_CONFIG_PROVENANCE: 'true' # must be string, not boolean
|
|
99
103
|
|
|
100
104
|
- name: Update lockfile
|
|
101
105
|
run: |
|
|
@@ -131,11 +135,14 @@ jobs:
|
|
|
131
135
|
git merge <%- getMainBranch(workspace) %> --no-verify
|
|
132
136
|
git push -u origin <%- getDevelopmentBranch(workspace) %> --no-verify
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
release_development_branch:
|
|
135
139
|
name: Development branch release
|
|
140
|
+
if: ${{ github.ref_name == '<%- getDevelopmentBranch(workspace) %>' }}
|
|
136
141
|
runs-on: ubuntu-latest
|
|
137
142
|
timeout-minutes: 15
|
|
138
|
-
|
|
143
|
+
permissions:
|
|
144
|
+
contents: read
|
|
145
|
+
id-token: write
|
|
139
146
|
steps:
|
|
140
147
|
- name: Cancel previous runs
|
|
141
148
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
@@ -154,7 +161,7 @@ jobs:
|
|
|
154
161
|
|
|
155
162
|
- uses: actions/setup-node@v3
|
|
156
163
|
with:
|
|
157
|
-
node-version:
|
|
164
|
+
node-version: 20
|
|
158
165
|
registry-url: 'https://registry.npmjs.org'
|
|
159
166
|
|
|
160
167
|
- name: Install packages
|
|
@@ -167,7 +174,7 @@ jobs:
|
|
|
167
174
|
|
|
168
175
|
if [[ -n $git_status ]]; then
|
|
169
176
|
echo "You have uncommitted changes!"
|
|
170
|
-
git
|
|
177
|
+
git diff
|
|
171
178
|
git config --unset core.filemode
|
|
172
179
|
exit 1
|
|
173
180
|
fi
|
|
@@ -184,7 +191,7 @@ jobs:
|
|
|
184
191
|
|
|
185
192
|
if [[ -n $git_status ]]; then
|
|
186
193
|
echo "You have uncommitted changes!"
|
|
187
|
-
git
|
|
194
|
+
git diff
|
|
188
195
|
git config --unset core.filemode
|
|
189
196
|
exit 1
|
|
190
197
|
fi
|
|
@@ -223,12 +230,16 @@ jobs:
|
|
|
223
230
|
env:
|
|
224
231
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
225
232
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
233
|
+
NPM_CONFIG_PROVENANCE: 'true' # must be string, not boolean
|
|
226
234
|
|
|
227
|
-
|
|
235
|
+
release_feature_branch:
|
|
228
236
|
name: Feature branch release
|
|
237
|
+
if: ${{ github.ref_name != '<%- getMainBranch(workspace) %>' && github.ref_name != '<%- getDevelopmentBranch(workspace) %>' && github.actor != 'renovate[bot]' }}
|
|
229
238
|
runs-on: ubuntu-latest
|
|
230
239
|
timeout-minutes: 15
|
|
231
|
-
|
|
240
|
+
permissions:
|
|
241
|
+
contents: read
|
|
242
|
+
id-token: write
|
|
232
243
|
steps:
|
|
233
244
|
- name: Cancel previous runs
|
|
234
245
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
@@ -247,7 +258,7 @@ jobs:
|
|
|
247
258
|
|
|
248
259
|
- uses: actions/setup-node@v3
|
|
249
260
|
with:
|
|
250
|
-
node-version:
|
|
261
|
+
node-version: 20
|
|
251
262
|
registry-url: 'https://registry.npmjs.org'
|
|
252
263
|
|
|
253
264
|
- name: Install packages
|
|
@@ -260,7 +271,7 @@ jobs:
|
|
|
260
271
|
|
|
261
272
|
if [[ -n $git_status ]]; then
|
|
262
273
|
echo "You have uncommitted changes!"
|
|
263
|
-
git
|
|
274
|
+
git diff
|
|
264
275
|
git config --unset core.filemode
|
|
265
276
|
exit 1
|
|
266
277
|
fi
|
|
@@ -277,7 +288,7 @@ jobs:
|
|
|
277
288
|
|
|
278
289
|
if [[ -n $git_status ]]; then
|
|
279
290
|
echo "You have uncommitted changes!"
|
|
280
|
-
git
|
|
291
|
+
git diff
|
|
281
292
|
git config --unset core.filemode
|
|
282
293
|
exit 1
|
|
283
294
|
fi
|
|
@@ -306,3 +317,4 @@ jobs:
|
|
|
306
317
|
env:
|
|
307
318
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
308
319
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
320
|
+
NPM_CONFIG_PROVENANCE: 'true' # must be string, not boolean
|
|
@@ -0,0 +1,131 @@
|
|
|
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: [development]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
update_pull_request:
|
|
13
|
+
name: Update pull request
|
|
14
|
+
if: ${{ github.actor == 'renovate[bot]' && contains(github.head_ref, 'renovate/') }}
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
timeout-minutes: 15
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v3
|
|
19
|
+
with:
|
|
20
|
+
ref: ${{ github.head_ref }}
|
|
21
|
+
token: ${{secrets.PAT}}
|
|
22
|
+
fetch-depth: 0
|
|
23
|
+
|
|
24
|
+
- name: Configure git
|
|
25
|
+
run: |
|
|
26
|
+
git config user.email "bot@mazanec.dev"
|
|
27
|
+
git config user.name "Bot"
|
|
28
|
+
|
|
29
|
+
- uses: actions/setup-node@v3
|
|
30
|
+
with:
|
|
31
|
+
node-version: 20
|
|
32
|
+
|
|
33
|
+
- name: Install packages
|
|
34
|
+
run: npm ci
|
|
35
|
+
|
|
36
|
+
- name: Generate changeset
|
|
37
|
+
uses: actions/github-script@v6
|
|
38
|
+
with:
|
|
39
|
+
script: |
|
|
40
|
+
let { promises: fs } = require('fs');
|
|
41
|
+
|
|
42
|
+
async function getPackagesNames(files) {
|
|
43
|
+
let names = [];
|
|
44
|
+
|
|
45
|
+
for (let file of files) {
|
|
46
|
+
let data = JSON.parse(await fs.readFile(file, 'utf8'));
|
|
47
|
+
|
|
48
|
+
if (!data.private) {
|
|
49
|
+
names.push(data.name);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return names;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function createChangeset(fileName, packageBumps, packages) {
|
|
57
|
+
let message = '';
|
|
58
|
+
|
|
59
|
+
for (let [packageName, bump] of packageBumps) {
|
|
60
|
+
message =
|
|
61
|
+
message + `Dependency \`${packageName}\` updated to version \`${bump}\`.\n`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
message = message.replace('\n', ' ');
|
|
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
|
+
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let { stdout: shortHash } = await exec.getExecOutput(
|
|
116
|
+
'git rev-parse --short HEAD',
|
|
117
|
+
);
|
|
118
|
+
let fileName = `.changeset/renovate-${shortHash.trim()}.md`;
|
|
119
|
+
let packageBumps = await getBumps(files);
|
|
120
|
+
|
|
121
|
+
await createChangeset(fileName, packageBumps, packageNames);
|
|
122
|
+
|
|
123
|
+
- name: Update Carson
|
|
124
|
+
run: |
|
|
125
|
+
npm install
|
|
126
|
+
|
|
127
|
+
- name: Commit and push changes
|
|
128
|
+
run: |
|
|
129
|
+
git add . --all
|
|
130
|
+
git commit -m"Update"
|
|
131
|
+
git push --force
|
|
@@ -46,9 +46,9 @@ let packageJson = lodash.merge(
|
|
|
46
46
|
uninstall: 'del-cli ./**/node_modules ./package-lock.json',
|
|
47
47
|
},
|
|
48
48
|
devDependencies: developmentDependencies,
|
|
49
|
-
packageManager: 'npm@
|
|
49
|
+
packageManager: 'npm@10.1.0',
|
|
50
50
|
engines: {
|
|
51
|
-
node: '
|
|
51
|
+
node: '^20.8.0',
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
workspace.config.overrides?.packageJson ?? {},
|