@jakubmazanec/carson-templates 0.1.0-7dbb232 → 0.1.0-8a0a4d5

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 CHANGED
@@ -1,9 +1,10 @@
1
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(defaultDependencies: Record<string, string>, workspace: Workspace | Workspace<false>): {
5
- [x: string]: string;
6
- };
7
+ export declare function getDependencies(dependencies: string[], workspace: Workspace | Workspace<false>): Record<string, string>;
7
8
  export declare function getReferences(workspace: Workspace | Workspace<false>, project: Project | Project<false>): {
8
9
  path: string;
9
10
  }[];
package/dist/main.js CHANGED
@@ -1,30 +1,97 @@
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(defaultDependencies, workspace) {
6
- let dependencies = {
7
- ...defaultDependencies
8
- };
9
- let projectNames = workspace.projects.map((project)=>project.name);
10
- for (let [dependencyName, dependencyVersion] of Object.entries(dependencies)){
11
- let installedDependency = workspace.allDependencies.find((dependency)=>dependencyName === dependency.name);
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
- let version = [
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
- dependencies[dependencyName] = `^${version}`;
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
- dependencies[dependencyName] = `^${version}`;
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
+ }
24
91
  }
25
92
  }
26
93
  }
27
- return dependencies;
94
+ return result;
28
95
  }
29
96
  export function getReferences(workspace, project) {
30
97
  let references = [];
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {type Project, 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(\n defaultDependencies: Record<string, string>,\n workspace: Workspace | Workspace<false>,\n) {\n let dependencies = {...defaultDependencies};\n\n let projectNames = workspace.projects.map((project) => project.name);\n\n for (let [dependencyName, dependencyVersion] of Object.entries(dependencies)) {\n let 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 let 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 dependencies[dependencyName] = `^${version}`;\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 dependencies[dependencyName] = `^${version}`;\n }\n }\n }\n\n return dependencies;\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":["default","lodash","getMajorVersion","version","Number","split","replace","getDependencies","defaultDependencies","workspace","dependencies","projectNames","projects","map","project","name","dependencyName","dependencyVersion","Object","entries","installedDependency","allDependencies","find","dependency","exactVersions","sort","reverse","includes","getReferences","references","currentProject","dependencyProject","push","path","relativePath","join","a","b","localeCompare"],"mappings":"AAEA,SAAQA,WAAWC,MAAM,QAAO,SAAS;AAEzC,OAAO,SAASC,gBAAgBC,OAAe;IAC7C,OAAOC,OAAOD,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAEC,OAAO,CAAC,MAAM;AACrD;AAEA,OAAO,SAASC,gBACdC,mBAA2C,EAC3CC,SAAuC;IAEvC,IAAIC,eAAe;QAAC,GAAGF,mBAAmB;IAAA;IAE1C,IAAIG,eAAeF,UAAUG,QAAQ,CAACC,GAAG,CAAC,CAACC,UAAYA,QAAQC,IAAI;IAEnE,KAAK,IAAI,CAACC,gBAAgBC,kBAAkB,IAAIC,OAAOC,OAAO,CAACT,cAAe;QAC5E,IAAIU,sBAAsBX,UAAUY,eAAe,CAACC,IAAI,CACtD,CAACC,aAAeP,mBAAmBO,WAAWR,IAAI;QAGpD,sGAAsG;QACtG,IAAIK,qBAAqB;YACvB,IAAIjB,UAAU;mBAAIiB,oBAAoBI,aAAa;aAAC,CAACC,IAAI,GAAGC,OAAO,EAAE,CAAC,EAAE;YAExE,oFAAoF;YACpF,IAAIf,aAAagB,QAAQ,CAACX,iBAAiB;gBACzCN,YAAY,CAACM,eAAe,GAAG,CAAC,CAAC,EAAEb,QAAQ,CAAC;YAC9C;YAEA,0LAA0L;YAC1L,IAAID,gBAAgBC,aAAaD,gBAAgBe,oBAAoB;gBACnEP,YAAY,CAACM,eAAe,GAAG,CAAC,CAAC,EAAEb,QAAQ,CAAC;YAC9C;QACF;IACF;IAEA,OAAOO;AACT;AAEA,OAAO,SAASkB,cACdnB,SAAuC,EACvCK,OAAiC;IAEjC,IAAIe,aAAa,EAAE;IACnB,IAAIC,iBAAiBhB;IAErB,KAAK,IAAIS,cAAcd,UAAUY,eAAe,CAAE;QAChD,KAAK,IAAIP,WAAWL,UAAUG,QAAQ,CAAE;YACtC,IAAIW,WAAWR,IAAI,KAAKD,QAAQC,IAAI,EAAE;gBACpC,KAAK,IAAIgB,qBAAqBR,WAAWX,QAAQ,CAAE;oBACjD,IAAImB,kBAAkBhB,IAAI,KAAKe,eAAef,IAAI,EAAE;wBAClDc,WAAWG,IAAI,CAAC;4BACdC,MAAM,CAAC,EAAEH,eAAeI,YAAY,CACjC7B,KAAK,CAAC,KACNQ,GAAG,CAAC,IAAM,MACVsB,IAAI,CAAC,KAAK,CAAC,EAAErB,QAAQoB,YAAY,CAAC,CAAC;wBACxC;oBACF;gBACF;YACF;QACF;IACF;IAEAL,WAAWJ,IAAI,CAAC,CAACW,GAAGC,IAAMD,EAAEH,IAAI,CAACK,aAAa,CAACD,EAAEJ,IAAI;IAErD,OAAOJ;AACT"}
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":"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"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@jakubmazanec/carson-templates",
3
- "version": "0.1.0-7dbb232",
3
+ "version": "0.1.0-8a0a4d5",
4
4
  "description": "Collection of Carson templates.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/jakubmazanec/js-tools",
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-7dbb232",
34
- "lodash": "^4.17.21"
33
+ "@jakubmazanec/carson": "0.1.0-8a0a4d5",
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,41 +1,104 @@
1
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
- defaultDependencies: Record<string, string>,
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> = {};
61
+
62
+ for (const dependency of dependencies) {
63
+ const version = DEPENDENCY_VERSIONS[dependency];
14
64
 
15
- let projectNames = workspace.projects.map((project) => project.name);
65
+ if (version) {
66
+ result[dependency] = version;
67
+ }
68
+ }
69
+
70
+ const projectNames = workspace.projects.map((project) => project.name);
16
71
 
17
- for (let [dependencyName, dependencyVersion] of Object.entries(dependencies)) {
18
- let installedDependency = workspace.allDependencies.find(
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
- let version = [...installedDependency.exactVersions].sort().reverse()[0] as string;
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
- dependencies[dependencyName] = `^${version}`;
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
- dependencies[dependencyName] = `^${version}`;
92
+ if (semver.prerelease(version)?.length) {
93
+ result[dependencyName] = version;
94
+ } else {
95
+ result[dependencyName] = `^${version}`;
96
+ }
34
97
  }
35
98
  }
36
99
  }
37
100
 
38
- return dependencies;
101
+ return result;
39
102
  }
40
103
 
41
104
  export function getReferences(
@@ -6,6 +6,9 @@ strategy: create
6
6
  "name": "<%- project.name %>",
7
7
  "version": "0.0.0",
8
8
  "description": "",
9
+ "repository": {
10
+ "url": "<%- workspace.repository?.url ?? '' %>"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": "Jakub Mazanec <jakub@mazanec.dev>",
11
14
  "sideEffects": false
@@ -2,36 +2,34 @@
2
2
  to: 'package.json'
3
3
  strategy: merge
4
4
  ---
5
- {
6
- "repository": {
7
- "type": "git",
8
- "url": "<%- workspace.repository?.url ?? '' %>",
9
- "directory": "<%- project.relativePath %>"
5
+ <%
6
+ let packageJson = {
7
+ repository: {
8
+ type: 'git',
9
+ directory: '<%- project.relativePath %>',
10
10
  },
11
- "type": "module",
12
- "exports": {
13
- ".": "./dist/main.js",
14
- "./package.json": "./package.json"
11
+ type: 'module',
12
+ exports: {
13
+ '.': './dist/main.js',
14
+ './package.json': './package.json',
15
15
  },
16
- "files": [
17
- "dist",
18
- "src",
19
- "templates"
20
- ],
21
- "scripts": {
22
- "build": "swc src -d dist && tsc",
23
- "clean": "del-cli dist *.tsbuildinfo",
24
- "document": "typedoc --options typedoc.config.cjs",
25
- "format": "prettier . --write --ignore-unknown --ignore-path ../../.prettierignore",
26
- "lint": "eslint .",
27
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
28
- "typecheck": "tsc --project tsconfig.typecheck.json"
16
+ files: ['dist', 'src', 'templates'],
17
+ scripts: {
18
+ build: 'swc src -d dist && tsc',
19
+ clean: 'del-cli coverage dist *.tsbuildinfo',
20
+ document: 'typedoc --options typedoc.config.cjs',
21
+ format: 'prettier . --write --ignore-unknown --ignore-path ../../.prettierignore',
22
+ lint: 'eslint .',
23
+ test: 'cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests',
24
+ typecheck: 'tsc --project tsconfig.typecheck.json',
29
25
  },
30
- "devDependencies": {
31
- "@jest/globals": "^29.5.0"
26
+ devDependencies: {
27
+ '@jest/globals': '^29.5.0',
32
28
  },
33
- "packageManager": "npm@8.19.4",
34
- "engines": {
35
- "node": ">=16.20.0"
36
- }
37
- }
29
+ packageManager: 'npm@8.19.4',
30
+ engines: {
31
+ node: '>=16.20.0',
32
+ },
33
+ };
34
+ -%>
35
+ <%- JSON.stringify(packageJson) %>
@@ -6,6 +6,9 @@ strategy: create
6
6
  "name": "<%- project.name %>",
7
7
  "version": "0.0.0",
8
8
  "description": "",
9
+ "repository": {
10
+ "url": "<%- workspace.repository?.url ?? '' %>"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": "Jakub Mazanec <jakub@mazanec.dev>",
11
14
  "sideEffects": false
@@ -2,28 +2,27 @@
2
2
  to: 'package.json'
3
3
  strategy: merge
4
4
  ---
5
- {
6
- "repository": {
7
- "type": "git",
8
- "url": "<%- workspace.repository?.url ?? '' %>",
9
- "directory": "<%- project.relativePath %>"
5
+ <%
6
+ let packageJson = {
7
+ repository: {
8
+ type: 'git',
9
+ directory: '<%- project.relativePath %>',
10
10
  },
11
- "type": "commonjs",
12
- "exports": "./dist/main.js",
13
- "files": [
14
- "dist",
15
- "src"
16
- ],
17
- "scripts": {
18
- "build": "swc src -d dist && tsc",
19
- "clean": "del-cli dist *.tsbuildinfo",
20
- "format": "prettier . --write --ignore-unknown --ignore-path ../../.prettierignore",
21
- "lint": "eslint .",
22
- "test": "jest --passWithNoTests",
23
- "typecheck": "tsc --project tsconfig.typecheck.json"
11
+ type: 'commonjs',
12
+ exports: './dist/main.js',
13
+ files: ['dist', 'src'],
14
+ scripts: {
15
+ build: 'swc src -d dist && tsc',
16
+ clean: 'del-cli coverage dist *.tsbuildinfo',
17
+ format: 'prettier . --write --ignore-unknown --ignore-path ../../.prettierignore',
18
+ lint: 'eslint .',
19
+ test: 'jest --passWithNoTests',
20
+ typecheck: 'tsc --project tsconfig.typecheck.json',
24
21
  },
25
- "packageManager": "npm@8.19.4",
26
- "engines": {
27
- "node": ">=16.20.0"
28
- }
29
- }
22
+ packageManager: 'npm@8.19.4',
23
+ engines: {
24
+ node: '>=16.20.0',
25
+ },
26
+ };
27
+ -%>
28
+ <%- JSON.stringify(packageJson) %>
@@ -6,6 +6,9 @@ strategy: create
6
6
  "name": "<%- project.name %>",
7
7
  "version": "0.0.0",
8
8
  "description": "",
9
+ "repository": {
10
+ "url": "<%- workspace.repository?.url ?? '' %>"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": "Jakub Mazanec <jakub@mazanec.dev>",
11
14
  "sideEffects": false
@@ -2,33 +2,32 @@
2
2
  to: 'package.json'
3
3
  strategy: merge
4
4
  ---
5
- {
6
- "repository": {
7
- "type": "git",
8
- "url": "<%- workspace.repository?.url ?? '' %>",
9
- "directory": "<%- project.relativePath %>"
5
+ <%
6
+ let packageJson = {
7
+ repository: {
8
+ type: 'git',
9
+ directory: '<%- project.relativePath %>',
10
10
  },
11
- "type": "commonjs",
12
- "exports": {
13
- ".": "./dist/main.js",
14
- "./nextjs": "./dist/presets/nextjs.js",
15
- "./nodejs": "./dist/presets/nodejs.js",
16
- "./prettier": "./dist/presets/prettier.js"
11
+ type: 'commonjs',
12
+ exports: {
13
+ '.': './dist/main.js',
14
+ './nextjs': './dist/presets/nextjs.js',
15
+ './nodejs': './dist/presets/nodejs.js',
16
+ './prettier': './dist/presets/prettier.js',
17
17
  },
18
- "files": [
19
- "dist",
20
- "src"
21
- ],
22
- "scripts": {
23
- "build": "swc src -d dist && tsc",
24
- "clean": "del-cli dist *.tsbuildinfo",
25
- "format": "prettier . --write --ignore-unknown --ignore-path ../../.prettierignore",
26
- "lint": "eslint .",
27
- "test": "jest --passWithNoTests",
28
- "typecheck": "tsc --project tsconfig.typecheck.json"
18
+ files: ['dist', 'src'],
19
+ scripts: {
20
+ build: 'swc src -d dist && tsc',
21
+ clean: 'del-cli coverage dist *.tsbuildinfo',
22
+ format: 'prettier . --write --ignore-unknown --ignore-path ../../.prettierignore',
23
+ lint: 'eslint .',
24
+ test: 'jest --passWithNoTests',
25
+ typecheck: 'tsc --project tsconfig.typecheck.json',
29
26
  },
30
- "packageManager": "npm@8.19.4",
31
- "engines": {
32
- "node": ">=16.20.0"
33
- }
34
- }
27
+ packageManager: 'npm@8.19.4',
28
+ engines: {
29
+ node: '>=16.20.0',
30
+ },
31
+ };
32
+ -%>
33
+ <%- JSON.stringify(packageJson) %>
@@ -6,6 +6,9 @@ strategy: create
6
6
  "name": "<%- project.name %>",
7
7
  "version": "0.0.0",
8
8
  "description": "",
9
+ "repository": {
10
+ "url": "<%- workspace.repository?.url ?? '' %>"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": "Jakub Mazanec <jakub@mazanec.dev>",
11
14
  "sideEffects": false
@@ -3,14 +3,13 @@ to: 'package.json'
3
3
  strategy: merge
4
4
  ---
5
5
  <%
6
- let developmentDependencies = getDependencies({
7
- '@jest/globals': '^29.0.0',
8
- }, workspace);
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',
@@ -18,7 +17,7 @@ let packageJson = lodash.merge(
18
17
  files: ['dist', 'src'],
19
18
  scripts: {
20
19
  build: 'swc src -d dist && tsc',
21
- clean: 'del-cli dist *.tsbuildinfo',
20
+ clean: 'del-cli coverage dist *.tsbuildinfo',
22
21
  document: 'typedoc --options typedoc.config.cjs',
23
22
  format:
24
23
  'prettier . --write --ignore-unknown --ignore-path ../../.prettierignore',
@@ -9,9 +9,6 @@ module.exports = {
9
9
  '@jakubmazanec/eslint-config/nodejs',
10
10
  '@jakubmazanec/eslint-config/prettier',
11
11
  ],
12
- rules: {
13
- 'no-await-in-loop': 'off',
14
- },
15
12
  ignorePatterns: [
16
13
  '.next/',
17
14
  'bin/',
@@ -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/main
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 development
40
- git branch --set-upstream-to=origin/development development
41
- git reset --hard origin/development
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 main
47
- git branch --set-upstream-to=origin/main main
48
- git reset --hard origin/main
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 development --no-verify
53
- git push -u origin main --no-verify
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 run test
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 run test
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.9.1
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@v2
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@v2
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 run test
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.9.1
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@v2
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@v2
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 run test
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
- '@changesets/cli': '^2.0.0',
8
- '@jakubmazanec/carson': '^0.0.0',
9
- '@jakubmazanec/carson-templates': '^0.0.0',
10
- '@swc/cli': '^0.1.0',
11
- '@swc/core': '^1.0.0',
12
- '@testing-library/jest-dom': '^5.0.0',
13
- '@types/node': '^16.0.0',
14
- chokidar: '^3.0.0',
15
- 'cross-env': '^7.0.0',
16
- 'del-cli': '^5.0.0',
17
- eslint: '^8.0.0',
18
- jest: '^29.0.0',
19
- 'patch-package': '^6.0.0',
20
- prettier: '^2.0.0',
21
- 'prettier-plugin-packagejson': '^2.0.0',
22
- 'ts-jest': '^29.0.0',
23
- 'ts-node': '^10.0.0',
24
- turbo: '^1.0.0',
25
- typedoc: '^0.24.0',
26
- 'typedoc-plugin-markdown': '^3.0.0',
27
- typescript: '^5.0.0',
28
- }, workspace);
29
- -%>
30
- {
31
- "private": true,
32
- "scripts": {
33
- "build": "turbo run build --no-daemon",
34
- "changeset": "changeset",
35
- "clean": "turbo run clean --no-daemon",
36
- "document": "turbo run document --no-daemon",
37
- "format": "turbo run format --no-daemon && prettier ./*.* --write --ignore-unknown",
38
- "lint": "turbo run lint --no-daemon",
39
- "prepare": "patch-package && carson update workspace",
40
- "reinstall": "npm run uninstall && npm install",
41
- "test": "turbo run test --no-daemon",
42
- "typecheck": "turbo run typecheck --no-daemon",
43
- "uninstall": "del-cli ./**/node_modules ./package-lock.json"
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
- "devDependencies": <%- JSON.stringify(developmentDependencies, null, 2) %>,
46
- "packageManager": "npm@8.19.4",
47
- "engines": {
48
- "node": ">=16.20.0"
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
+
@@ -7,7 +7,7 @@ let turboConfig = {
7
7
  $schema: 'https://turborepo.org/schema.json',
8
8
  pipeline: {
9
9
  build: {
10
- dependsOn: ['^build', 'clean', 'codegen'],
10
+ dependsOn: ['^build', 'codegen'],
11
11
  outputs: ['build/**', 'dist/**'],
12
12
  },
13
13
  clean: {
@@ -16,6 +16,11 @@ let turboConfig = {
16
16
  codegen: {
17
17
  cache: false,
18
18
  },
19
+ develop: {
20
+ dependsOn: ['codegen'],
21
+ cache: false,
22
+ persistent: true,
23
+ },
19
24
  document: {
20
25
  dependsOn: ['^build', 'codegen'],
21
26
  outputs: ['docs/**'],
@@ -28,7 +33,7 @@ let turboConfig = {
28
33
  outputs: [],
29
34
  },
30
35
  test: {
31
- dependsOn: ['^build', 'clean', 'typecheck', 'lint'],
36
+ dependsOn: ['^build', 'typecheck', 'lint'],
32
37
  outputs: ['coverage/**'],
33
38
  },
34
39
  typecheck: {