@jakubmazanec/carson-templates 0.1.0-2d1145f → 0.1.0-2f12db0
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/main.d.ts +8 -4
- package/dist/main.js +97 -11
- package/dist/main.js.map +1 -1
- package/package.json +5 -4
- package/src/main.ts +105 -13
- package/templates/projects/carson-templates/package.json.create.ejs +3 -0
- package/templates/projects/carson-templates/package.json.ejs +0 -1
- package/templates/projects/carson-templates/tsconfig.json.ejs +1 -21
- package/templates/projects/changesets-changelog/package.json.create.ejs +3 -0
- package/templates/projects/changesets-changelog/package.json.ejs +0 -1
- package/templates/projects/changesets-changelog/tsconfig.json.ejs +1 -21
- package/templates/projects/eslint-config/package.json.create.ejs +3 -0
- package/templates/projects/eslint-config/package.json.ejs +0 -1
- package/templates/projects/eslint-config/tsconfig.json.ejs +1 -21
- package/templates/projects/library/package.json.create.ejs +3 -0
- package/templates/projects/library/package.json.ejs +3 -4
- package/templates/projects/library/tsconfig.json.ejs +1 -21
- package/templates/workspace/.eslintrc.cjs.ejs +0 -3
- package/templates/workspace/.github/workflows/{merge-to-main.yaml.ejs → merge-to-main-branch.yaml.ejs} +10 -10
- package/templates/workspace/.github/workflows/pull-request.yaml.ejs +29 -1
- package/templates/workspace/.github/workflows/release.yaml.ejs +122 -62
- package/templates/workspace/package.json.ejs +62 -43
- package/templates/workspace/turbo.json.ejs +48 -40
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { type Workspace } from '@jakubmazanec/carson';
|
|
1
|
+
import { type Project, type Workspace } from '@jakubmazanec/carson';
|
|
2
2
|
export { default as lodash } from 'lodash';
|
|
3
|
+
export { default as semver } from 'semver';
|
|
4
|
+
export declare function getMainBranch(workspace: Workspace | Workspace<false>): string | undefined;
|
|
5
|
+
export declare function getDevelopmentBranch(workspace: Workspace | Workspace<false>): string | undefined;
|
|
3
6
|
export declare function getMajorVersion(version: string): number;
|
|
4
|
-
export declare function getDependencies(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
export declare function getDependencies(dependencies: string[], workspace: Workspace | Workspace<false>): Record<string, string>;
|
|
8
|
+
export declare function getReferences(workspace: Workspace | Workspace<false>, project: Project | Project<false>): {
|
|
9
|
+
path: string;
|
|
10
|
+
}[];
|
package/dist/main.js
CHANGED
|
@@ -1,30 +1,116 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
1
2
|
export { default as lodash } from 'lodash';
|
|
3
|
+
export { default as semver } from 'semver';
|
|
4
|
+
const MAIN_BRANCH_NAMES = new Set([
|
|
5
|
+
'main',
|
|
6
|
+
'master'
|
|
7
|
+
]);
|
|
8
|
+
const DEVELOPMENT_BRANCH_NAMES = new Set([
|
|
9
|
+
'development',
|
|
10
|
+
'develop',
|
|
11
|
+
'dev'
|
|
12
|
+
]);
|
|
13
|
+
const DEPENDENCY_VERSIONS = {
|
|
14
|
+
'@changesets/cli': '^2.0.0',
|
|
15
|
+
'@jakubmazanec/carson': '^0.0.0',
|
|
16
|
+
'@jakubmazanec/carson-templates': '^0.0.0',
|
|
17
|
+
'@jest/globals': '^29.0.0',
|
|
18
|
+
'@swc/cli': '^0.1.0',
|
|
19
|
+
'@swc/core': '^1.0.0',
|
|
20
|
+
'@testing-library/jest-dom': '^5.0.0',
|
|
21
|
+
'@types/node': '^16.0.0',
|
|
22
|
+
chokidar: '^3.0.0',
|
|
23
|
+
'cross-env': '^7.0.0',
|
|
24
|
+
'del-cli': '^5.0.0',
|
|
25
|
+
eslint: '^8.0.0',
|
|
26
|
+
jest: '^29.0.0',
|
|
27
|
+
'patch-package': '^6.0.0',
|
|
28
|
+
prettier: '^2.0.0',
|
|
29
|
+
'prettier-plugin-packagejson': '^2.0.0',
|
|
30
|
+
'ts-jest': '^29.0.0',
|
|
31
|
+
'ts-node': '^10.0.0',
|
|
32
|
+
turbo: '^1.0.0',
|
|
33
|
+
typedoc: '^0.24.0',
|
|
34
|
+
'typedoc-plugin-markdown': '^3.0.0',
|
|
35
|
+
typescript: '^5.0.0'
|
|
36
|
+
};
|
|
37
|
+
export function getMainBranch(workspace) {
|
|
38
|
+
var _workspace_repository;
|
|
39
|
+
for (let branch of ((_workspace_repository = workspace.repository) === null || _workspace_repository === void 0 ? void 0 : _workspace_repository.branches) ?? []){
|
|
40
|
+
if (MAIN_BRANCH_NAMES.has(branch)) {
|
|
41
|
+
return branch;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
export function getDevelopmentBranch(workspace) {
|
|
47
|
+
var _workspace_repository;
|
|
48
|
+
for (let branch of ((_workspace_repository = workspace.repository) === null || _workspace_repository === void 0 ? void 0 : _workspace_repository.branches) ?? []){
|
|
49
|
+
if (DEVELOPMENT_BRANCH_NAMES.has(branch)) {
|
|
50
|
+
return branch;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
2
55
|
export function getMajorVersion(version) {
|
|
3
56
|
return Number(version.split('.')[0].replace(/\D/, ''));
|
|
4
57
|
}
|
|
5
|
-
export function getDependencies(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
58
|
+
export function getDependencies(dependencies, workspace) {
|
|
59
|
+
const result = {};
|
|
60
|
+
for (const dependency of dependencies){
|
|
61
|
+
const version = DEPENDENCY_VERSIONS[dependency];
|
|
62
|
+
if (version) {
|
|
63
|
+
result[dependency] = version;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const projectNames = workspace.projects.map((project)=>project.name);
|
|
67
|
+
for (const [dependencyName, dependencyVersion] of Object.entries(result)){
|
|
68
|
+
const installedDependency = workspace.allDependencies.find((dependency)=>dependencyName === dependency.name);
|
|
12
69
|
// if the dependency is already installed in the workspace, we might want to use that existing version
|
|
13
70
|
if (installedDependency) {
|
|
14
|
-
|
|
71
|
+
const version = [
|
|
15
72
|
...installedDependency.exactVersions
|
|
16
73
|
].sort().reverse()[0];
|
|
17
74
|
// if the dependency is actually a project in the workspace, we use existing version
|
|
18
75
|
if (projectNames.includes(dependencyName)) {
|
|
19
|
-
|
|
76
|
+
var _semver_prerelease;
|
|
77
|
+
if ((_semver_prerelease = semver.prerelease(version)) === null || _semver_prerelease === void 0 ? void 0 : _semver_prerelease.length) {
|
|
78
|
+
result[dependencyName] = version;
|
|
79
|
+
} else {
|
|
80
|
+
result[dependencyName] = `^${version}`;
|
|
81
|
+
}
|
|
20
82
|
}
|
|
21
83
|
// 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
|
|
22
84
|
if (getMajorVersion(version) === getMajorVersion(dependencyVersion)) {
|
|
23
|
-
|
|
85
|
+
var _semver_prerelease1;
|
|
86
|
+
if ((_semver_prerelease1 = semver.prerelease(version)) === null || _semver_prerelease1 === void 0 ? void 0 : _semver_prerelease1.length) {
|
|
87
|
+
result[dependencyName] = version;
|
|
88
|
+
} else {
|
|
89
|
+
result[dependencyName] = `^${version}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
export function getReferences(workspace, project) {
|
|
97
|
+
let references = [];
|
|
98
|
+
let currentProject = project;
|
|
99
|
+
for (let dependency of workspace.allDependencies){
|
|
100
|
+
for (let project of workspace.projects){
|
|
101
|
+
if (dependency.name === project.name) {
|
|
102
|
+
for (let dependencyProject of dependency.projects){
|
|
103
|
+
if (dependencyProject.name === currentProject.name) {
|
|
104
|
+
references.push({
|
|
105
|
+
path: `${currentProject.relativePath.split('/').map(()=>'..').join('/')}/${project.relativePath}`
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
24
109
|
}
|
|
25
110
|
}
|
|
26
111
|
}
|
|
27
|
-
|
|
112
|
+
references.sort((a, b)=>a.path.localeCompare(b.path));
|
|
113
|
+
return references;
|
|
28
114
|
}
|
|
29
115
|
|
|
30
116
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {type Workspace} from '@jakubmazanec/carson';\n\nexport {default as lodash} from 'lodash';\n\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]!.replace(/\\D/, ''));\n}\n\nexport function getDependencies(
|
|
1
|
+
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {type Project, type Workspace} from '@jakubmazanec/carson';\nimport semver from 'semver';\n\nexport {default as lodash} from 'lodash';\nexport {default as semver} from 'semver';\n\nconst MAIN_BRANCH_NAMES = new Set(['main', 'master']);\nconst DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);\n\nconst DEPENDENCY_VERSIONS: Record<string, string> = {\n '@changesets/cli': '^2.0.0',\n '@jakubmazanec/carson': '^0.0.0',\n '@jakubmazanec/carson-templates': '^0.0.0',\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': '^16.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: '^2.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 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":["semver","default","lodash","MAIN_BRANCH_NAMES","Set","DEVELOPMENT_BRANCH_NAMES","DEPENDENCY_VERSIONS","chokidar","eslint","jest","prettier","turbo","typedoc","typescript","getMainBranch","workspace","branch","repository","branches","has","undefined","getDevelopmentBranch","getMajorVersion","version","Number","split","replace","getDependencies","dependencies","result","dependency","projectNames","projects","map","project","name","dependencyName","dependencyVersion","Object","entries","installedDependency","allDependencies","find","exactVersions","sort","reverse","includes","prerelease","length","getReferences","references","currentProject","dependencyProject","push","path","relativePath","join","a","b","localeCompare"],"mappings":"AACA,OAAOA,YAAY,SAAS;AAE5B,SAAQC,WAAWC,MAAM,QAAO,SAAS;AACzC,SAAQD,WAAWD,MAAM,QAAO,SAAS;AAEzC,MAAMG,oBAAoB,IAAIC,IAAI;IAAC;IAAQ;CAAS;AACpD,MAAMC,2BAA2B,IAAID,IAAI;IAAC;IAAe;IAAW;CAAM;AAE1E,MAAME,sBAA8C;IAClD,mBAAmB;IACnB,wBAAwB;IACxB,kCAAkC;IAClC,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,6BAA6B;IAC7B,eAAe;IACfC,UAAU;IACV,aAAa;IACb,WAAW;IACXC,QAAQ;IACRC,MAAM;IACN,iBAAiB;IACjBC,UAAU;IACV,+BAA+B;IAC/B,WAAW;IACX,WAAW;IACXC,OAAO;IACPC,SAAS;IACT,2BAA2B;IAC3BC,YAAY;AACd;AAEA,OAAO,SAASC,cAAcC,SAAuC;QAChDA;IAAnB,KAAK,IAAIC,UAAUD,EAAAA,wBAAAA,UAAUE,UAAU,cAApBF,4CAAAA,sBAAsBG,QAAQ,KAAI,EAAE,CAAE;QACvD,IAAIf,kBAAkBgB,GAAG,CAACH,SAAS;YACjC,OAAOA;QACT;IACF;IAEA,OAAOI;AACT;AAEA,OAAO,SAASC,qBAAqBN,SAAuC;QACvDA;IAAnB,KAAK,IAAIC,UAAUD,EAAAA,wBAAAA,UAAUE,UAAU,cAApBF,4CAAAA,sBAAsBG,QAAQ,KAAI,EAAE,CAAE;QACvD,IAAIb,yBAAyBc,GAAG,CAACH,SAAS;YACxC,OAAOA;QACT;IACF;IAEA,OAAOI;AACT;AAEA,OAAO,SAASE,gBAAgBC,OAAe;IAC7C,OAAOC,OAAOD,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAEC,OAAO,CAAC,MAAM;AACrD;AAEA,OAAO,SAASC,gBAAgBC,YAAsB,EAAEb,SAAuC;IAC7F,MAAMc,SAAiC,CAAC;IAExC,KAAK,MAAMC,cAAcF,aAAc;QACrC,MAAML,UAAUjB,mBAAmB,CAACwB,WAAW;QAE/C,IAAIP,SAAS;YACXM,MAAM,CAACC,WAAW,GAAGP;QACvB;IACF;IAEA,MAAMQ,eAAehB,UAAUiB,QAAQ,CAACC,GAAG,CAAC,CAACC,UAAYA,QAAQC,IAAI;IAErE,KAAK,MAAM,CAACC,gBAAgBC,kBAAkB,IAAIC,OAAOC,OAAO,CAACV,QAAS;QACxE,MAAMW,sBAAsBzB,UAAU0B,eAAe,CAACC,IAAI,CACxD,CAACZ,aAAeM,mBAAmBN,WAAWK,IAAI;QAGpD,sGAAsG;QACtG,IAAIK,qBAAqB;YACvB,MAAMjB,UAAU;mBAAIiB,oBAAoBG,aAAa;aAAC,CAACC,IAAI,GAAGC,OAAO,EAAE,CAAC,EAAE;YAE1E,oFAAoF;YACpF,IAAId,aAAae,QAAQ,CAACV,iBAAiB;oBACrCpC;gBAAJ,KAAIA,qBAAAA,OAAO+C,UAAU,CAACxB,sBAAlBvB,yCAAAA,mBAA4BgD,MAAM,EAAE;oBACtCnB,MAAM,CAACO,eAAe,GAAGb;gBAC3B,OAAO;oBACLM,MAAM,CAACO,eAAe,GAAG,CAAC,CAAC,EAAEb,QAAQ,CAAC;gBACxC;YACF;YAEA,0LAA0L;YAC1L,IAAID,gBAAgBC,aAAaD,gBAAgBe,oBAAoB;oBAC/DrC;gBAAJ,KAAIA,sBAAAA,OAAO+C,UAAU,CAACxB,sBAAlBvB,0CAAAA,oBAA4BgD,MAAM,EAAE;oBACtCnB,MAAM,CAACO,eAAe,GAAGb;gBAC3B,OAAO;oBACLM,MAAM,CAACO,eAAe,GAAG,CAAC,CAAC,EAAEb,QAAQ,CAAC;gBACxC;YACF;QACF;IACF;IAEA,OAAOM;AACT;AAEA,OAAO,SAASoB,cACdlC,SAAuC,EACvCmB,OAAiC;IAEjC,IAAIgB,aAAa,EAAE;IACnB,IAAIC,iBAAiBjB;IAErB,KAAK,IAAIJ,cAAcf,UAAU0B,eAAe,CAAE;QAChD,KAAK,IAAIP,WAAWnB,UAAUiB,QAAQ,CAAE;YACtC,IAAIF,WAAWK,IAAI,KAAKD,QAAQC,IAAI,EAAE;gBACpC,KAAK,IAAIiB,qBAAqBtB,WAAWE,QAAQ,CAAE;oBACjD,IAAIoB,kBAAkBjB,IAAI,KAAKgB,eAAehB,IAAI,EAAE;wBAClDe,WAAWG,IAAI,CAAC;4BACdC,MAAM,CAAC,EAAEH,eAAeI,YAAY,CACjC9B,KAAK,CAAC,KACNQ,GAAG,CAAC,IAAM,MACVuB,IAAI,CAAC,KAAK,CAAC,EAAEtB,QAAQqB,YAAY,CAAC,CAAC;wBACxC;oBACF;gBACF;YACF;QACF;IACF;IAEAL,WAAWN,IAAI,CAAC,CAACa,GAAGC,IAAMD,EAAEH,IAAI,CAACK,aAAa,CAACD,EAAEJ,IAAI;IAErD,OAAOJ;AACT"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakubmazanec/carson-templates",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-2f12db0",
|
|
4
4
|
"description": "Collection of Carson templates.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "
|
|
7
|
+
"url": "git@github.com:jakubmazanec/js-tools.git",
|
|
8
8
|
"directory": "packages/carson-templates"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"typecheck": "tsc --project tsconfig.typecheck.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jakubmazanec/carson": "0.1.0-
|
|
34
|
-
"lodash": "^4.17.21"
|
|
33
|
+
"@jakubmazanec/carson": "0.1.0-2f12db0",
|
|
34
|
+
"lodash": "^4.17.21",
|
|
35
|
+
"semver": "^7.3.6"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@jest/globals": "^29.5.0",
|
package/src/main.ts
CHANGED
|
@@ -1,39 +1,131 @@
|
|
|
1
|
-
import {type Workspace} from '@jakubmazanec/carson';
|
|
1
|
+
import {type Project, type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
import semver from 'semver';
|
|
2
3
|
|
|
3
4
|
export {default as lodash} from 'lodash';
|
|
5
|
+
export {default as semver} from 'semver';
|
|
6
|
+
|
|
7
|
+
const MAIN_BRANCH_NAMES = new Set(['main', 'master']);
|
|
8
|
+
const DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);
|
|
9
|
+
|
|
10
|
+
const DEPENDENCY_VERSIONS: Record<string, string> = {
|
|
11
|
+
'@changesets/cli': '^2.0.0',
|
|
12
|
+
'@jakubmazanec/carson': '^0.0.0',
|
|
13
|
+
'@jakubmazanec/carson-templates': '^0.0.0',
|
|
14
|
+
'@jest/globals': '^29.0.0',
|
|
15
|
+
'@swc/cli': '^0.1.0',
|
|
16
|
+
'@swc/core': '^1.0.0',
|
|
17
|
+
'@testing-library/jest-dom': '^5.0.0',
|
|
18
|
+
'@types/node': '^16.0.0',
|
|
19
|
+
chokidar: '^3.0.0',
|
|
20
|
+
'cross-env': '^7.0.0',
|
|
21
|
+
'del-cli': '^5.0.0',
|
|
22
|
+
eslint: '^8.0.0',
|
|
23
|
+
jest: '^29.0.0',
|
|
24
|
+
'patch-package': '^6.0.0',
|
|
25
|
+
prettier: '^2.0.0',
|
|
26
|
+
'prettier-plugin-packagejson': '^2.0.0',
|
|
27
|
+
'ts-jest': '^29.0.0',
|
|
28
|
+
'ts-node': '^10.0.0',
|
|
29
|
+
turbo: '^1.0.0',
|
|
30
|
+
typedoc: '^0.24.0',
|
|
31
|
+
'typedoc-plugin-markdown': '^3.0.0',
|
|
32
|
+
typescript: '^5.0.0',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function getMainBranch(workspace: Workspace | Workspace<false>) {
|
|
36
|
+
for (let branch of workspace.repository?.branches ?? []) {
|
|
37
|
+
if (MAIN_BRANCH_NAMES.has(branch)) {
|
|
38
|
+
return branch;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getDevelopmentBranch(workspace: Workspace | Workspace<false>) {
|
|
46
|
+
for (let branch of workspace.repository?.branches ?? []) {
|
|
47
|
+
if (DEVELOPMENT_BRANCH_NAMES.has(branch)) {
|
|
48
|
+
return branch;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
4
54
|
|
|
5
55
|
export function getMajorVersion(version: string) {
|
|
6
56
|
return Number(version.split('.')[0]!.replace(/\D/, ''));
|
|
7
57
|
}
|
|
8
58
|
|
|
9
|
-
export function getDependencies(
|
|
10
|
-
|
|
11
|
-
workspace: Workspace | Workspace<false>,
|
|
12
|
-
) {
|
|
13
|
-
let dependencies = {...defaultDependencies};
|
|
59
|
+
export function getDependencies(dependencies: string[], workspace: Workspace | Workspace<false>) {
|
|
60
|
+
const result: Record<string, string> = {};
|
|
14
61
|
|
|
15
|
-
|
|
62
|
+
for (const dependency of dependencies) {
|
|
63
|
+
const version = DEPENDENCY_VERSIONS[dependency];
|
|
16
64
|
|
|
17
|
-
|
|
18
|
-
|
|
65
|
+
if (version) {
|
|
66
|
+
result[dependency] = version;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const projectNames = workspace.projects.map((project) => project.name);
|
|
71
|
+
|
|
72
|
+
for (const [dependencyName, dependencyVersion] of Object.entries(result)) {
|
|
73
|
+
const installedDependency = workspace.allDependencies.find(
|
|
19
74
|
(dependency) => dependencyName === dependency.name,
|
|
20
75
|
);
|
|
21
76
|
|
|
22
77
|
// if the dependency is already installed in the workspace, we might want to use that existing version
|
|
23
78
|
if (installedDependency) {
|
|
24
|
-
|
|
79
|
+
const version = [...installedDependency.exactVersions].sort().reverse()[0] as string;
|
|
25
80
|
|
|
26
81
|
// if the dependency is actually a project in the workspace, we use existing version
|
|
27
82
|
if (projectNames.includes(dependencyName)) {
|
|
28
|
-
|
|
83
|
+
if (semver.prerelease(version)?.length) {
|
|
84
|
+
result[dependencyName] = version;
|
|
85
|
+
} else {
|
|
86
|
+
result[dependencyName] = `^${version}`;
|
|
87
|
+
}
|
|
29
88
|
}
|
|
30
89
|
|
|
31
90
|
// 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
|
|
32
91
|
if (getMajorVersion(version) === getMajorVersion(dependencyVersion)) {
|
|
33
|
-
|
|
92
|
+
if (semver.prerelease(version)?.length) {
|
|
93
|
+
result[dependencyName] = version;
|
|
94
|
+
} else {
|
|
95
|
+
result[dependencyName] = `^${version}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function getReferences(
|
|
105
|
+
workspace: Workspace | Workspace<false>,
|
|
106
|
+
project: Project | Project<false>,
|
|
107
|
+
) {
|
|
108
|
+
let references = [];
|
|
109
|
+
let currentProject = project;
|
|
110
|
+
|
|
111
|
+
for (let dependency of workspace.allDependencies) {
|
|
112
|
+
for (let project of workspace.projects) {
|
|
113
|
+
if (dependency.name === project.name) {
|
|
114
|
+
for (let dependencyProject of dependency.projects) {
|
|
115
|
+
if (dependencyProject.name === currentProject.name) {
|
|
116
|
+
references.push({
|
|
117
|
+
path: `${currentProject.relativePath
|
|
118
|
+
.split('/')
|
|
119
|
+
.map(() => '..')
|
|
120
|
+
.join('/')}/${project.relativePath}`,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
34
124
|
}
|
|
35
125
|
}
|
|
36
126
|
}
|
|
37
127
|
|
|
38
|
-
|
|
128
|
+
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
129
|
+
|
|
130
|
+
return references;
|
|
39
131
|
}
|
|
@@ -2,26 +2,6 @@
|
|
|
2
2
|
to: 'tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
<%
|
|
6
|
-
let references = [];
|
|
7
|
-
let currentProject = project;
|
|
8
|
-
|
|
9
|
-
for (let dependency of workspace.allDependencies) {
|
|
10
|
-
for (let project of workspace.projects) {
|
|
11
|
-
if (dependency.name === project.name) {
|
|
12
|
-
for (let dependencyProject of dependency.projects) {
|
|
13
|
-
if (dependencyProject.name === currentProject.name) {
|
|
14
|
-
references.push({
|
|
15
|
-
path: currentProject.relativePath.split('/').map(() => '..').join('/') + '/' + project.relativePath
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
24
|
-
-%>
|
|
25
5
|
{
|
|
26
6
|
"extends": "../../tsconfig.options.json",
|
|
27
7
|
"compilerOptions": {
|
|
@@ -30,5 +10,5 @@ references.sort((a, b) => a.path.localeCompare(b.path));
|
|
|
30
10
|
"rootDir": "./src"
|
|
31
11
|
},
|
|
32
12
|
"include": ["./src/**/*"],
|
|
33
|
-
"references": <%- JSON.stringify(
|
|
13
|
+
"references": <%- JSON.stringify(getReferences(workspace, project), null, 2) %>
|
|
34
14
|
}
|
|
@@ -2,26 +2,6 @@
|
|
|
2
2
|
to: 'tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
<%
|
|
6
|
-
let references = [];
|
|
7
|
-
let currentProject = project;
|
|
8
|
-
|
|
9
|
-
for (let dependency of workspace.allDependencies) {
|
|
10
|
-
for (let project of workspace.projects) {
|
|
11
|
-
if (dependency.name === project.name) {
|
|
12
|
-
for (let dependencyProject of dependency.projects) {
|
|
13
|
-
if (dependencyProject.name === currentProject.name) {
|
|
14
|
-
references.push({
|
|
15
|
-
path: currentProject.relativePath.split('/').map(() => '..').join('/') + '/' + project.relativePath
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
24
|
-
-%>
|
|
25
5
|
{
|
|
26
6
|
"extends": "../../tsconfig.options.json",
|
|
27
7
|
"compilerOptions": {
|
|
@@ -30,5 +10,5 @@ references.sort((a, b) => a.path.localeCompare(b.path));
|
|
|
30
10
|
"rootDir": "./src"
|
|
31
11
|
},
|
|
32
12
|
"include": ["./src/**/*"],
|
|
33
|
-
"references": <%- JSON.stringify(
|
|
13
|
+
"references": <%- JSON.stringify(getReferences(workspace, project), null, 2) %>
|
|
34
14
|
}
|
|
@@ -2,26 +2,6 @@
|
|
|
2
2
|
to: 'tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
<%
|
|
6
|
-
let references = [];
|
|
7
|
-
let currentProject = project;
|
|
8
|
-
|
|
9
|
-
for (let dependency of workspace.allDependencies) {
|
|
10
|
-
for (let project of workspace.projects) {
|
|
11
|
-
if (dependency.name === project.name) {
|
|
12
|
-
for (let dependencyProject of dependency.projects) {
|
|
13
|
-
if (dependencyProject.name === currentProject.name) {
|
|
14
|
-
references.push({
|
|
15
|
-
path: currentProject.relativePath.split('/').map(() => '..').join('/') + '/' + project.relativePath
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
24
|
-
-%>
|
|
25
5
|
{
|
|
26
6
|
"extends": "../../tsconfig.options.json",
|
|
27
7
|
"compilerOptions": {
|
|
@@ -30,5 +10,5 @@ references.sort((a, b) => a.path.localeCompare(b.path));
|
|
|
30
10
|
"rootDir": "./src"
|
|
31
11
|
},
|
|
32
12
|
"include": ["./src/**/*"],
|
|
33
|
-
"references": <%- JSON.stringify(
|
|
13
|
+
"references": <%- JSON.stringify(getReferences(workspace, project), null, 2) %>
|
|
34
14
|
}
|
|
@@ -3,14 +3,13 @@ to: 'package.json'
|
|
|
3
3
|
strategy: merge
|
|
4
4
|
---
|
|
5
5
|
<%
|
|
6
|
-
let developmentDependencies = getDependencies(
|
|
7
|
-
'@jest/globals'
|
|
8
|
-
|
|
6
|
+
let developmentDependencies = getDependencies([
|
|
7
|
+
'@jest/globals',
|
|
8
|
+
], workspace);
|
|
9
9
|
let packageJson = lodash.merge(
|
|
10
10
|
{
|
|
11
11
|
repository: {
|
|
12
12
|
type: 'git',
|
|
13
|
-
url: workspace.repository?.url ?? '',
|
|
14
13
|
directory: project.relativePath,
|
|
15
14
|
},
|
|
16
15
|
type: 'module',
|
|
@@ -2,26 +2,6 @@
|
|
|
2
2
|
to: 'tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
<%
|
|
6
|
-
let references = [];
|
|
7
|
-
let currentProject = project;
|
|
8
|
-
|
|
9
|
-
for (let dependency of workspace.allDependencies) {
|
|
10
|
-
for (let project of workspace.projects) {
|
|
11
|
-
if (dependency.name === project.name) {
|
|
12
|
-
for (let dependencyProject of dependency.projects) {
|
|
13
|
-
if (dependencyProject.name === currentProject.name) {
|
|
14
|
-
references.push({
|
|
15
|
-
path: currentProject.relativePath.split('/').map(() => '..').join('/') + '/' + project.relativePath
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
24
|
-
-%>
|
|
25
5
|
{
|
|
26
6
|
"extends": "../../tsconfig.options.json",
|
|
27
7
|
"compilerOptions": {
|
|
@@ -30,5 +10,5 @@ references.sort((a, b) => a.path.localeCompare(b.path));
|
|
|
30
10
|
"rootDir": "./src"
|
|
31
11
|
},
|
|
32
12
|
"include": ["./src/**/*"],
|
|
33
|
-
"references": <%- JSON.stringify(
|
|
13
|
+
"references": <%- JSON.stringify(getReferences(workspace, project), null, 2) %>
|
|
34
14
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
to: '.github/workflows/merge-to-main.yaml'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
name: Merge development to main
|
|
5
|
+
name: Merge development branch to main branch
|
|
6
6
|
|
|
7
7
|
on: [workflow_dispatch]
|
|
8
8
|
|
|
@@ -31,23 +31,23 @@ jobs:
|
|
|
31
31
|
run: npm ci
|
|
32
32
|
|
|
33
33
|
- name: Check for changesets
|
|
34
|
-
run: npx changeset status --since=origin
|
|
34
|
+
run: npx changeset status --since=origin/<%- getMainBranch(workspace) %>
|
|
35
35
|
|
|
36
36
|
- name: Checkout development branch
|
|
37
37
|
run: |
|
|
38
38
|
git fetch -p origin
|
|
39
|
-
git checkout
|
|
40
|
-
git branch --set-upstream-to=origin
|
|
41
|
-
git reset --hard origin
|
|
39
|
+
git checkout <%- getDevelopmentBranch(workspace) %>
|
|
40
|
+
git branch --set-upstream-to=origin/<%- getDevelopmentBranch(workspace) %> <%- getDevelopmentBranch(workspace) %>
|
|
41
|
+
git reset --hard origin/<%- getDevelopmentBranch(workspace) %>
|
|
42
42
|
git pull
|
|
43
43
|
|
|
44
44
|
- name: Checkout main branch
|
|
45
45
|
run: |
|
|
46
|
-
git checkout -B
|
|
47
|
-
git branch --set-upstream-to=origin
|
|
48
|
-
git reset --hard origin
|
|
46
|
+
git checkout -B <%- getMainBranch(workspace) %>
|
|
47
|
+
git branch --set-upstream-to=origin/<%- getMainBranch(workspace) %> <%- getMainBranch(workspace) %>
|
|
48
|
+
git reset --hard origin/<%- getMainBranch(workspace) %>
|
|
49
49
|
|
|
50
50
|
- name: Merge and commit
|
|
51
51
|
run: |
|
|
52
|
-
git merge
|
|
53
|
-
git push -u origin
|
|
52
|
+
git merge <%- getDevelopmentBranch(workspace) %> --no-verify
|
|
53
|
+
git push -u origin <%- getMainBranch(workspace) %> --no-verify
|
|
@@ -26,8 +26,36 @@ jobs:
|
|
|
26
26
|
- name: Install packages
|
|
27
27
|
run: npm ci
|
|
28
28
|
|
|
29
|
+
- name: Check for changes
|
|
30
|
+
run: |
|
|
31
|
+
git config core.filemode false
|
|
32
|
+
git_status=$(git status --porcelain)
|
|
33
|
+
|
|
34
|
+
if [[ -n $git_status ]]; then
|
|
35
|
+
echo "You have uncommitted changes!"
|
|
36
|
+
git status
|
|
37
|
+
git config --unset core.filemode
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
git config --unset core.filemode
|
|
42
|
+
|
|
29
43
|
- name: Run tests
|
|
30
|
-
run: npm
|
|
44
|
+
run: npm test
|
|
45
|
+
|
|
46
|
+
- name: Check for changes
|
|
47
|
+
run: |
|
|
48
|
+
git config core.filemode false
|
|
49
|
+
git_status=$(git status --porcelain)
|
|
50
|
+
|
|
51
|
+
if [[ -n $git_status ]]; then
|
|
52
|
+
echo "You have uncommitted changes!"
|
|
53
|
+
git status --porcelain
|
|
54
|
+
git config --unset core.filemode
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
git config --unset core.filemode
|
|
31
59
|
|
|
32
60
|
- name: Check for changesets
|
|
33
61
|
run: npx changeset status --since=origin/development
|
|
@@ -2,30 +2,6 @@
|
|
|
2
2
|
to: '.github/workflows/release.yaml'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
<%
|
|
6
|
-
const MAIN_BRANCH_NAMES = new Set(['main', 'master']);
|
|
7
|
-
const DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);
|
|
8
|
-
|
|
9
|
-
function getMainBranch() {
|
|
10
|
-
for (let branch of workspace.repository?.branches ?? []) {
|
|
11
|
-
if (MAIN_BRANCH_NAMES.has(branch)) {
|
|
12
|
-
return branch;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getDevelopmentBranch() {
|
|
20
|
-
for (let branch of workspace.repository?.branches ?? []) {
|
|
21
|
-
if (DEVELOPMENT_BRANCH_NAMES.has(branch)) {
|
|
22
|
-
return branch;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
-%>
|
|
29
5
|
name: Release
|
|
30
6
|
|
|
31
7
|
on: [push, workflow_dispatch]
|
|
@@ -35,7 +11,7 @@ jobs:
|
|
|
35
11
|
name: Main branch release
|
|
36
12
|
runs-on: ubuntu-latest
|
|
37
13
|
timeout-minutes: 15
|
|
38
|
-
if: "github.ref_name == '<%- getMainBranch() %>'"
|
|
14
|
+
if: "github.ref_name == '<%- getMainBranch(workspace) %>'"
|
|
39
15
|
steps:
|
|
40
16
|
- name: Cancel previous runs
|
|
41
17
|
uses: styfle/cancel-workflow-action@0.11.0
|
|
@@ -57,21 +33,49 @@ jobs:
|
|
|
57
33
|
node-version: 16
|
|
58
34
|
registry-url: 'https://registry.npmjs.org'
|
|
59
35
|
|
|
60
|
-
- name: Authenticate to npm registry
|
|
61
|
-
run: |
|
|
62
|
-
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
63
|
-
env:
|
|
64
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
65
|
-
|
|
66
36
|
- name: Install packages
|
|
67
37
|
run: npm ci
|
|
68
38
|
|
|
39
|
+
- name: Check for changes
|
|
40
|
+
run: |
|
|
41
|
+
git config core.filemode false
|
|
42
|
+
git_status=$(git status --porcelain)
|
|
43
|
+
|
|
44
|
+
if [[ -n $git_status ]]; then
|
|
45
|
+
echo "You have uncommitted changes!"
|
|
46
|
+
git status --porcelain
|
|
47
|
+
git config --unset core.filemode
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
git config --unset core.filemode
|
|
52
|
+
|
|
69
53
|
- name: Run tests
|
|
70
|
-
run: npm
|
|
54
|
+
run: npm test
|
|
55
|
+
|
|
56
|
+
- name: Check for changes
|
|
57
|
+
run: |
|
|
58
|
+
git config core.filemode false
|
|
59
|
+
git_status=$(git status --porcelain)
|
|
60
|
+
|
|
61
|
+
if [[ -n $git_status ]]; then
|
|
62
|
+
echo "You have uncommitted changes!"
|
|
63
|
+
git status --porcelain
|
|
64
|
+
git config --unset core.filemode
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
git config --unset core.filemode
|
|
71
69
|
|
|
72
70
|
- name: Build packages
|
|
73
71
|
run: npm run build
|
|
74
72
|
|
|
73
|
+
- name: Authenticate to npm registry
|
|
74
|
+
run: |
|
|
75
|
+
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
76
|
+
env:
|
|
77
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
78
|
+
|
|
75
79
|
- name: Version packages
|
|
76
80
|
run: |
|
|
77
81
|
npx changeset version
|
|
@@ -111,34 +115,34 @@ jobs:
|
|
|
111
115
|
- name: Checkout main branch
|
|
112
116
|
run: |
|
|
113
117
|
git fetch -p origin
|
|
114
|
-
git checkout <%- getMainBranch() %>
|
|
115
|
-
git branch --set-upstream-to=origin/<%- getMainBranch() %> <%- getMainBranch() %>
|
|
116
|
-
git reset --hard origin/<%- getMainBranch() %>
|
|
118
|
+
git checkout <%- getMainBranch(workspace) %>
|
|
119
|
+
git branch --set-upstream-to=origin/<%- getMainBranch(workspace) %> <%- getMainBranch(workspace) %>
|
|
120
|
+
git reset --hard origin/<%- getMainBranch(workspace) %>
|
|
117
121
|
git pull
|
|
118
122
|
|
|
119
123
|
- name: Checkout development branch
|
|
120
124
|
run: |
|
|
121
|
-
git checkout -B <%- getDevelopmentBranch() %>
|
|
122
|
-
git branch --set-upstream-to=origin/<%- getDevelopmentBranch() %> <%- getDevelopmentBranch() %>
|
|
123
|
-
git reset --hard origin/<%- getDevelopmentBranch() %>
|
|
125
|
+
git checkout -B <%- getDevelopmentBranch(workspace) %>
|
|
126
|
+
git branch --set-upstream-to=origin/<%- getDevelopmentBranch(workspace) %> <%- getDevelopmentBranch(workspace) %>
|
|
127
|
+
git reset --hard origin/<%- getDevelopmentBranch(workspace) %>
|
|
124
128
|
|
|
125
129
|
- name: Merge and commit
|
|
126
130
|
run: |
|
|
127
|
-
git merge <%- getMainBranch() %> --no-verify
|
|
128
|
-
git push -u origin <%- getDevelopmentBranch() %> --no-verify
|
|
131
|
+
git merge <%- getMainBranch(workspace) %> --no-verify
|
|
132
|
+
git push -u origin <%- getDevelopmentBranch(workspace) %> --no-verify
|
|
129
133
|
|
|
130
134
|
development_branch_release:
|
|
131
135
|
name: Development branch release
|
|
132
136
|
runs-on: ubuntu-latest
|
|
133
137
|
timeout-minutes: 15
|
|
134
|
-
if: "github.ref_name == '<%- getDevelopmentBranch() %>'"
|
|
138
|
+
if: "github.ref_name == '<%- getDevelopmentBranch(workspace) %>'"
|
|
135
139
|
steps:
|
|
136
140
|
- name: Cancel previous runs
|
|
137
|
-
uses: styfle/cancel-workflow-action@0.
|
|
141
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
138
142
|
with:
|
|
139
143
|
access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
140
144
|
|
|
141
|
-
- uses: actions/checkout@
|
|
145
|
+
- uses: actions/checkout@v3
|
|
142
146
|
with:
|
|
143
147
|
token: ${{ secrets.PAT }}
|
|
144
148
|
fetch-depth: 0
|
|
@@ -148,22 +152,44 @@ jobs:
|
|
|
148
152
|
git config user.email "bot@mazanec.dev"
|
|
149
153
|
git config user.name "Bot"
|
|
150
154
|
|
|
151
|
-
- uses: actions/setup-node@
|
|
155
|
+
- uses: actions/setup-node@v3
|
|
152
156
|
with:
|
|
153
157
|
node-version: 16
|
|
154
158
|
registry-url: 'https://registry.npmjs.org'
|
|
155
159
|
|
|
156
|
-
- name: Authenticate to npm registry
|
|
157
|
-
run: |
|
|
158
|
-
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
159
|
-
env:
|
|
160
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
161
|
-
|
|
162
160
|
- name: Install packages
|
|
163
161
|
run: npm ci
|
|
164
162
|
|
|
163
|
+
- name: Check for changes
|
|
164
|
+
run: |
|
|
165
|
+
git config core.filemode false
|
|
166
|
+
git_status=$(git status --porcelain)
|
|
167
|
+
|
|
168
|
+
if [[ -n $git_status ]]; then
|
|
169
|
+
echo "You have uncommitted changes!"
|
|
170
|
+
git status --porcelain
|
|
171
|
+
git config --unset core.filemode
|
|
172
|
+
exit 1
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
git config --unset core.filemode
|
|
176
|
+
|
|
165
177
|
- name: Run tests
|
|
166
|
-
run: npm
|
|
178
|
+
run: npm test
|
|
179
|
+
|
|
180
|
+
- name: Check for changes
|
|
181
|
+
run: |
|
|
182
|
+
git config core.filemode false
|
|
183
|
+
git_status=$(git status --porcelain)
|
|
184
|
+
|
|
185
|
+
if [[ -n $git_status ]]; then
|
|
186
|
+
echo "You have uncommitted changes!"
|
|
187
|
+
git status --porcelain
|
|
188
|
+
git config --unset core.filemode
|
|
189
|
+
exit 1
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
git config --unset core.filemode
|
|
167
193
|
|
|
168
194
|
- name: Build packages
|
|
169
195
|
run: npm run build
|
|
@@ -178,6 +204,12 @@ jobs:
|
|
|
178
204
|
git push --force
|
|
179
205
|
continue-on-error: true
|
|
180
206
|
|
|
207
|
+
- name: Authenticate to npm registry
|
|
208
|
+
run: |
|
|
209
|
+
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
210
|
+
env:
|
|
211
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
212
|
+
|
|
181
213
|
- name: Version packages
|
|
182
214
|
run: |
|
|
183
215
|
npx changeset version --snapshot next --snapshot-prerelease-template "{tag}.{commit}"
|
|
@@ -196,14 +228,14 @@ jobs:
|
|
|
196
228
|
name: Feature branch release
|
|
197
229
|
runs-on: ubuntu-latest
|
|
198
230
|
timeout-minutes: 15
|
|
199
|
-
if: "github.ref_name != '<%- getMainBranch() %>' && github.ref_name != '<%- getDevelopmentBranch() %>'"
|
|
231
|
+
if: "github.ref_name != '<%- getMainBranch(workspace) %>' && github.ref_name != '<%- getDevelopmentBranch(workspace) %>'"
|
|
200
232
|
steps:
|
|
201
233
|
- name: Cancel previous runs
|
|
202
|
-
uses: styfle/cancel-workflow-action@0.
|
|
234
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
203
235
|
with:
|
|
204
236
|
access_token: ${{ secrets.GITHUB_TOKEN }}
|
|
205
237
|
|
|
206
|
-
- uses: actions/checkout@
|
|
238
|
+
- uses: actions/checkout@v3
|
|
207
239
|
with:
|
|
208
240
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
209
241
|
fetch-depth: 0
|
|
@@ -213,26 +245,54 @@ jobs:
|
|
|
213
245
|
git config user.email "bot@mazanec.dev"
|
|
214
246
|
git config user.name "Bot"
|
|
215
247
|
|
|
216
|
-
- uses: actions/setup-node@
|
|
248
|
+
- uses: actions/setup-node@v3
|
|
217
249
|
with:
|
|
218
250
|
node-version: 16
|
|
219
251
|
registry-url: 'https://registry.npmjs.org'
|
|
220
252
|
|
|
221
|
-
- name: Authenticate to npm registry
|
|
222
|
-
run: |
|
|
223
|
-
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
224
|
-
env:
|
|
225
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
226
|
-
|
|
227
253
|
- name: Install packages
|
|
228
254
|
run: npm ci
|
|
229
255
|
|
|
256
|
+
- name: Check for changes
|
|
257
|
+
run: |
|
|
258
|
+
git config core.filemode false
|
|
259
|
+
git_status=$(git status --porcelain)
|
|
260
|
+
|
|
261
|
+
if [[ -n $git_status ]]; then
|
|
262
|
+
echo "You have uncommitted changes!"
|
|
263
|
+
git status --porcelain
|
|
264
|
+
git config --unset core.filemode
|
|
265
|
+
exit 1
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
git config --unset core.filemode
|
|
269
|
+
|
|
230
270
|
- name: Run tests
|
|
231
|
-
run: npm
|
|
271
|
+
run: npm test
|
|
272
|
+
|
|
273
|
+
- name: Check for changes
|
|
274
|
+
run: |
|
|
275
|
+
git config core.filemode false
|
|
276
|
+
git_status=$(git status --porcelain)
|
|
277
|
+
|
|
278
|
+
if [[ -n $git_status ]]; then
|
|
279
|
+
echo "You have uncommitted changes!"
|
|
280
|
+
git status --porcelain
|
|
281
|
+
git config --unset core.filemode
|
|
282
|
+
exit 1
|
|
283
|
+
fi
|
|
284
|
+
|
|
285
|
+
git config --unset core.filemode
|
|
232
286
|
|
|
233
287
|
- name: Build packages
|
|
234
288
|
run: npm run build
|
|
235
289
|
|
|
290
|
+
- name: Authenticate to npm registry
|
|
291
|
+
run: |
|
|
292
|
+
echo "//registry.npmjs.com/:_authToken=NPM_TOKEN" > .npmrc
|
|
293
|
+
env:
|
|
294
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
295
|
+
|
|
236
296
|
- name: Version packages
|
|
237
297
|
run: |
|
|
238
298
|
npx changeset version --snapshot --snapshot-prerelease-template "{commit}"
|
|
@@ -3,48 +3,67 @@ to: 'package.json'
|
|
|
3
3
|
strategy: merge
|
|
4
4
|
---
|
|
5
5
|
<%
|
|
6
|
-
let developmentDependencies = getDependencies(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
let developmentDependencies = getDependencies(
|
|
7
|
+
[
|
|
8
|
+
'@changesets/cli',
|
|
9
|
+
'@jakubmazanec/carson',
|
|
10
|
+
'@jakubmazanec/carson-templates',
|
|
11
|
+
'@swc/cli',
|
|
12
|
+
'@swc/core',
|
|
13
|
+
'@testing-library/jest-dom',
|
|
14
|
+
'@types/node',
|
|
15
|
+
'chokidar',
|
|
16
|
+
'cross-env',
|
|
17
|
+
'del-cli',
|
|
18
|
+
'eslint',
|
|
19
|
+
'jest',
|
|
20
|
+
'patch-package',
|
|
21
|
+
'prettier',
|
|
22
|
+
'prettier-plugin-packagejson',
|
|
23
|
+
'ts-jest',
|
|
24
|
+
'ts-node',
|
|
25
|
+
'turbo',
|
|
26
|
+
'typedoc',
|
|
27
|
+
'typedoc-plugin-markdown',
|
|
28
|
+
'typescript',
|
|
29
|
+
],
|
|
30
|
+
workspace,
|
|
31
|
+
);
|
|
32
|
+
let packageJson = lodash.merge(
|
|
33
|
+
{
|
|
34
|
+
private: true,
|
|
35
|
+
scripts: {
|
|
36
|
+
build: 'turbo run build --no-daemon',
|
|
37
|
+
changeset: 'changeset',
|
|
38
|
+
clean: 'turbo run clean --no-daemon',
|
|
39
|
+
document: 'turbo run document --no-daemon',
|
|
40
|
+
format: 'turbo run format --no-daemon && prettier ./*.* --write --ignore-unknown',
|
|
41
|
+
lint: 'turbo run lint --no-daemon',
|
|
42
|
+
prepare: 'patch-package',
|
|
43
|
+
reinstall: 'npm run uninstall && npm install',
|
|
44
|
+
test: 'turbo run test --no-daemon',
|
|
45
|
+
typecheck: 'turbo run typecheck --no-daemon',
|
|
46
|
+
uninstall: 'del-cli ./**/node_modules ./package-lock.json',
|
|
47
|
+
},
|
|
48
|
+
devDependencies: developmentDependencies,
|
|
49
|
+
packageManager: 'npm@8.19.4',
|
|
50
|
+
engines: {
|
|
51
|
+
node: '>=16.20.0',
|
|
52
|
+
},
|
|
44
53
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
workspace.config.overrides?.packageJson ?? {},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (workspace.projects.find((project) => project.name === '@jakubmazanec/carson')) {
|
|
58
|
+
packageJson.scripts.prepare +=
|
|
59
|
+
' && turbo run build --no-daemon --filter=@jakubmazanec/carson --filter=@jakubmazanec/carson-templates';
|
|
50
60
|
}
|
|
61
|
+
|
|
62
|
+
packageJson.scripts.prepare += ' && carson update workspace';
|
|
63
|
+
-%>
|
|
64
|
+
<%- JSON.stringify(packageJson) %>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
@@ -2,45 +2,53 @@
|
|
|
2
2
|
to: 'turbo.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
5
|
+
<%
|
|
6
|
+
let turboConfig = {
|
|
7
|
+
$schema: 'https://turborepo.org/schema.json',
|
|
8
|
+
pipeline: {
|
|
9
|
+
build: {
|
|
10
|
+
dependsOn: ['^build', 'clean', 'codegen'],
|
|
11
|
+
outputs: ['build/**', 'dist/**'],
|
|
12
|
+
},
|
|
13
|
+
clean: {
|
|
14
|
+
cache: false,
|
|
15
|
+
},
|
|
16
|
+
codegen: {
|
|
17
|
+
cache: false,
|
|
18
|
+
},
|
|
19
|
+
document: {
|
|
20
|
+
dependsOn: ['^build', 'codegen'],
|
|
21
|
+
outputs: ['docs/**'],
|
|
22
|
+
},
|
|
23
|
+
format: {
|
|
24
|
+
cache: false,
|
|
25
|
+
},
|
|
26
|
+
lint: {
|
|
27
|
+
dependsOn: ['^build', 'codegen'],
|
|
28
|
+
outputs: [],
|
|
29
|
+
},
|
|
30
|
+
test: {
|
|
31
|
+
dependsOn: ['^build', 'clean', 'typecheck', 'lint'],
|
|
32
|
+
outputs: ['coverage/**'],
|
|
33
|
+
},
|
|
34
|
+
typecheck: {
|
|
35
|
+
dependsOn: ['^build', 'codegen'],
|
|
36
|
+
outputs: [],
|
|
37
|
+
},
|
|
37
38
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
]
|
|
39
|
+
globalDependencies: [
|
|
40
|
+
'.editorconfig',
|
|
41
|
+
'.eslintrc.cjs',
|
|
42
|
+
'.prettierignore',
|
|
43
|
+
'prettier.config.js',
|
|
44
|
+
'tsconfig.options.json',
|
|
45
|
+
'tsconfig.typecheck.json',
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (workspace.projects.find((project) => project.name === '@jakubmazanec/eslint-config')) {
|
|
50
|
+
turboConfig.pipeline.lint.dependsOn = ['@jakubmazanec/eslint-config#build', '^build', 'codegen'];
|
|
46
51
|
}
|
|
52
|
+
-%>
|
|
53
|
+
<%- JSON.stringify(turboConfig, null, 2) %>
|
|
54
|
+
|