Skip to content

Commit 51d6c7a

Browse files
committed
fix: handle weird monorepo setup; some more tweaks
Signed-off-by: Charlike Mike Reagent <[email protected]>
1 parent 3bfaa4c commit 51d6c7a

File tree

10 files changed

+31
-242
lines changed

10 files changed

+31
-242
lines changed

@tunnckocore/utils/dist/main/index.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

@tunnckocore/utils/dist/module/index.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

@tunnckocore/utils/package.json

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"version": "0.5.1",
33
"name": "@tunnckocore/utils",
4-
"description": "Thin layer on top of `execa` that allows executing multiple commands in parallel or in sequence with control for concurrency",
4+
"description": "Utility functions and helpers for internal usage and monorepos",
55
"author": "Charlike Mike Reagent <[email protected]>",
66
"homepage": "https://github.com/tunnckoCore/opensource",
77
"license": "MPL-2.0",
88
"licenseStart": 2019,
99
"main": "src/index.js",
10-
"module": "src/index.js",
11-
"types": "dist/types/index.d.ts",
10+
"types": "src/index.d.ts",
1211
"scripts": {},
1312
"publishConfig": {
1413
"access": "public",
@@ -23,30 +22,17 @@
2322
"directory": "@tunnckocore/utils"
2423
},
2524
"files": [
26-
"dist"
25+
"src"
2726
],
2827
"keywords": [
2928
"tunnckocorehq",
3029
"develop",
31-
"parallel",
32-
"series",
33-
"concurrency",
34-
"sequence",
35-
"exec",
36-
"child",
37-
"process",
38-
"execute",
39-
"fork",
40-
"execfile",
41-
"execa",
42-
"spawn",
43-
"file",
44-
"shell",
45-
"bin",
46-
"binary",
47-
"binaries",
48-
"npm",
49-
"path",
50-
"local"
30+
"hela",
31+
"tunnckocore",
32+
"monorepo",
33+
"monorepo helpers",
34+
"helpers",
35+
"utils",
36+
"utilities"
5137
]
5238
}

@tunnckocore/utils/src/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ function createAliases(cwd = process.cwd(), sourceDirectory) {
3535

3636
const packages = fs
3737
.readdirSync(workspace)
38+
.filter((x) => !result.workspaces.find((z) => z.endsWith(x)))
3839
.map((directory) => {
40+
// console.log(workspace);
3941
const pkgDirectory = path.join(workspace, directory);
4042
const pkgJsonPath = path.join(pkgDirectory, 'package.json');
4143

@@ -47,15 +49,17 @@ function createAliases(cwd = process.cwd(), sourceDirectory) {
4749

4850
/* istanbul ignore next */
4951
if (Object.keys(packageJson).length === 0) {
50-
throw new Error(
51-
`Cannot find package.json or cannot parse it: ${pkgJsonPath}`,
52-
);
52+
return null;
53+
// throw new Error(
54+
// `Cannot find package.json or cannot parse it: ${pkgJsonPath}`,
55+
// );
5356
}
5457
return [pkgDirectory, packageJson];
5558
});
5659

57-
return acc.concat(packages);
60+
return acc.concat(packages).filter(Boolean);
5861
}, [])
62+
.filter(Boolean)
5963
.reduce((acc, [pkgDirectory, packageJson]) => {
6064
if (typeof sourceDirectory === 'string') {
6165
acc[packageJson.name] = path.join(pkgDirectory, sourceDirectory);
@@ -86,7 +90,7 @@ function getWorkspacesAndExtensions(cwd = process.cwd()) {
8690
.filter(Boolean)
8791
.reduce((acc, ws) => acc.concat(ws.split(',')), [])
8892
.map((ws) => path.dirname(ws));
89-
93+
// console.log('workspaces', workspaces);
9094
let exts = [].concat(pkg.extensions).filter(Boolean);
9195

9296
if (exts.length === 0) {

jest.build.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
2-
const utils = require('@tunnckocore/utils');
1+
const utils = require('./@tunnckocore/utils/src');
32

43
const { alias, exts } = utils.createAliases();
54

@@ -17,6 +16,7 @@ module.exports = {
1716
/.+\/support\/.+/.toString(),
1817
/.+\/__support__\/.+/.toString(),
1918
/.+\/__shared__\/.+/.toString(),
19+
/.+\/@tunnckocore\/utils\/.+/.toString(),
2020
],
2121
moduleNameMapper: alias,
2222
moduleFileExtensions: exts,

jest.lint.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
2-
const utils = require('@tunnckocore/utils');
1+
const utils = require('./@tunnckocore/utils/src');
32

43
const { alias, exts } = utils.createAliases();
54

jest.test.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// eslint-disable-next-line import/no-extraneous-dependencies
2-
const utils = require('@tunnckocore/utils');
1+
const utils = require('./@tunnckocore/utils/src');
32

43
const { alias, exts } = utils.createAliases();
54

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"name": "@tunnckocore/opensource",
44
"homepage": "https://github.com/tunnckocore/opensource",
55
"workspaces": [
6-
"shared/*",
76
"packages/*",
87
"@tunnckocore/*"
98
],
@@ -22,7 +21,9 @@
2221
"@commitlint/cli": "^8.2.0",
2322
"@commitlint/config-conventional": "^8.2.0",
2423
"@tunnckocore/babel-preset": "^0.2.1",
25-
"@tunnckocore/eslint-config": "^4.1.4",
24+
"@tunnckocore/eslint-config": "^4.1.5",
25+
"@tunnckocore/jest-runner-babel": "^3.1.0",
26+
"@tunnckocore/jest-runner-eslint": "^0.3.1",
2627
"@tunnckocore/prettier-config": "^0.2.2",
2728
"@tunnckocore/typescript-config": "^0.3.1",
2829
"babel-plugin-add-module-exports": "^1.0.2",

shared/package.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

yarn.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,11 +2254,12 @@
22542254
babel-plugin-transform-react-remove-prop-types "^0.4.24"
22552255
babel-preset-proposal-typescript "^1.4.1"
22562256

2257-
"@tunnckocore/eslint-config@^4.1.4":
2258-
version "4.1.4"
2259-
resolved "https://registry.yarnpkg.com/@tunnckocore/eslint-config/-/eslint-config-4.1.4.tgz#e6a58d6c9620579d1a55be2db28cd119d1a54e2a"
2260-
integrity sha512-0HJQ8AapHTvOq0erg3bzCLddqHe7/DNhCvaniXQg1Xr/lC3T7ew6zooIRQ1eDQ6VMRuyxVu5sQFZFR3/b3DuLQ==
2257+
"@tunnckocore/eslint-config@^4.1.5":
2258+
version "4.1.5"
2259+
resolved "https://registry.yarnpkg.com/@tunnckocore/eslint-config/-/eslint-config-4.1.5.tgz#ea6e63b60f8e9b0f088274ab0c3f74ccfc68b9ac"
2260+
integrity sha512-xLuXLQt9GLrcBJefdBucTdbFEZSgPXSRatXe7OrqoKYwGZEnC27jOB2TrfU8fB7cHIloP5ATx+r0Mp4BGaA2jA==
22612261
dependencies:
2262+
"@tunnckocore/utils" "^0.5.1"
22622263
"@typescript-eslint/eslint-plugin" "^2.3.0"
22632264
"@typescript-eslint/parser" "^2.3.0"
22642265
babel-eslint "^10.0.3"

0 commit comments

Comments
 (0)