@jakubmazanec/carson-templates 0.1.0-5f6d70c → 0.1.0-7dbb232

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,6 +1,9 @@
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
3
  export declare function getMajorVersion(version: string): number;
4
4
  export declare function getDependencies(defaultDependencies: Record<string, string>, workspace: Workspace | Workspace<false>): {
5
5
  [x: string]: string;
6
6
  };
7
+ export declare function getReferences(workspace: Workspace | Workspace<false>, project: Project | Project<false>): {
8
+ path: string;
9
+ }[];
package/dist/main.js CHANGED
@@ -26,5 +26,24 @@ export function getDependencies(defaultDependencies, workspace) {
26
26
  }
27
27
  return dependencies;
28
28
  }
29
+ export function getReferences(workspace, project) {
30
+ let references = [];
31
+ let currentProject = project;
32
+ for (let dependency of workspace.allDependencies){
33
+ for (let project of workspace.projects){
34
+ if (dependency.name === project.name) {
35
+ for (let dependencyProject of dependency.projects){
36
+ if (dependencyProject.name === currentProject.name) {
37
+ references.push({
38
+ path: `${currentProject.relativePath.split('/').map(()=>'..').join('/')}/${project.relativePath}`
39
+ });
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ references.sort((a, b)=>a.path.localeCompare(b.path));
46
+ return references;
47
+ }
29
48
 
30
49
  //# 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(\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"],"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"],"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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/carson-templates",
3
- "version": "0.1.0-5f6d70c",
3
+ "version": "0.1.0-7dbb232",
4
4
  "description": "Collection of Carson templates.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "typecheck": "tsc --project tsconfig.typecheck.json"
31
31
  },
32
32
  "dependencies": {
33
- "@jakubmazanec/carson": "0.1.0-5f6d70c",
33
+ "@jakubmazanec/carson": "0.1.0-7dbb232",
34
34
  "lodash": "^4.17.21"
35
35
  },
36
36
  "devDependencies": {
package/src/main.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {type Workspace} from '@jakubmazanec/carson';
1
+ import {type Project, type Workspace} from '@jakubmazanec/carson';
2
2
 
3
3
  export {default as lodash} from 'lodash';
4
4
 
@@ -37,3 +37,32 @@ export function getDependencies(
37
37
 
38
38
  return dependencies;
39
39
  }
40
+
41
+ export function getReferences(
42
+ workspace: Workspace | Workspace<false>,
43
+ project: Project | Project<false>,
44
+ ) {
45
+ let references = [];
46
+ let currentProject = project;
47
+
48
+ for (let dependency of workspace.allDependencies) {
49
+ for (let project of workspace.projects) {
50
+ if (dependency.name === project.name) {
51
+ for (let dependencyProject of dependency.projects) {
52
+ if (dependencyProject.name === currentProject.name) {
53
+ references.push({
54
+ path: `${currentProject.relativePath
55
+ .split('/')
56
+ .map(() => '..')
57
+ .join('/')}/${project.relativePath}`,
58
+ });
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ references.sort((a, b) => a.path.localeCompare(b.path));
66
+
67
+ return references;
68
+ }
@@ -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(references, null, 2) %>
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(references, null, 2) %>
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(references, null, 2) %>
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(references, null, 2) %>
13
+ "references": <%- JSON.stringify(getReferences(workspace, project), null, 2) %>
34
14
  }
@@ -2,45 +2,53 @@
2
2
  to: 'turbo.json'
3
3
  strategy: overwrite
4
4
  ---
5
- {
6
- "$schema": "https://turborepo.org/schema.json",
7
- "pipeline": {
8
- "build": {
9
- "dependsOn": ["^build", "clean", "codegen"],
10
- "outputs": ["build/**", "dist/**"]
11
- },
12
- "clean": {
13
- "cache": false
14
- },
15
- "codegen": {
16
- "cache": false
17
- },
18
- "document": {
19
- "dependsOn": ["^build", "codegen"],
20
- "outputs": ["docs/**"]
21
- },
22
- "format": {
23
- "cache": false
24
- },
25
- "lint": {
26
- "dependsOn": ["@jakubmazanec/eslint-config#build", "^build"],
27
- "outputs": []
28
- },
29
- "test": {
30
- "dependsOn": ["^build", "clean", "typecheck", "lint"],
31
- "outputs": ["coverage/**"]
32
- },
33
- "typecheck": {
34
- "dependsOn": ["^build"],
35
- "outputs": []
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
- "globalDependencies": [
39
- ".editorconfig",
40
- ".eslintrc.cjs",
41
- ".prettierignore",
42
- "prettier.config.js",
43
- "tsconfig.options.json",
44
- "tsconfig.typecheck.json"
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
+