Skip to content

Commit c6c4df9

Browse files
committed
chore(workspaces): rename allPackages to allWorkspaces
1 parent 7a3e70b commit c6c4df9

File tree

21 files changed

+70
-103
lines changed

21 files changed

+70
-103
lines changed

babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is require for running tests only!!
2-
const { allPackages } = require("@webiny/project-utils/packages");
2+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
33

44
module.exports = {
55
babelrc: true,
6-
babelrcRoots: allPackages()
6+
babelrcRoots: allWorkspaces()
77
};

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const fs = require("fs");
22
const path = require("path");
3-
const { allPackages } = require("@webiny/project-utils/packages");
3+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
44

5-
const projects = allPackages()
5+
const projects = allWorkspaces()
66
.map(pkg => {
77
if (!fs.existsSync(path.join(pkg, "jest.config.js"))) {
88
return null;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"webiny-versions": "node ./scripts/webinyVersions.js",
123123
"release-latest": "node ./scripts/releaseLatest.js",
124124
"lint-staged": "lint-staged",
125-
"postinstall": "node ./scripts/linkPackages.js",
125+
"postinstall": "node ./scripts/linkWorkspaces.js",
126126
"prepublishOnly": "node scripts/prepublishOnly.js",
127127
"prettier": "prettier \"**/**/*.{js,jsx,ts,tsx}\" --config .prettierrc.js",
128128
"prettier:check": "yarn prettier --check",

packages/cli-plugin-workspaces/commands/list.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const { join } = require("path");
22
const chalk = require("chalk");
3-
const { allPackages } = require("@webiny/project-utils/packages");
3+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
44

55
const outputJSON = obj => {
66
console.log(JSON.stringify(obj, null, 2));
77
};
88

99
module.exports = async ({ json, withPath }) => {
10-
const packages = allPackages().reduce((acc, folder) => {
10+
const workspaces = allWorkspaces().reduce((acc, folder) => {
1111
const json = require(join(folder, "package.json"));
1212
acc[json.name] = folder;
1313
return acc;
@@ -16,16 +16,16 @@ module.exports = async ({ json, withPath }) => {
1616
if (json) {
1717
// `withPath` outputs a key => value object, containing workspace name and absolute path
1818
if (withPath) {
19-
outputJSON(packages);
19+
outputJSON(workspaces);
2020
} else {
21-
outputJSON(Object.keys(packages));
21+
outputJSON(Object.keys(workspaces));
2222
}
2323
return;
2424
}
2525

26-
Object.keys(packages).forEach(name => {
26+
Object.keys(workspaces).forEach(name => {
2727
if (withPath) {
28-
console.log(`${chalk.green(name)} (${chalk.blue(packages[name])})`);
28+
console.log(`${chalk.green(name)} (${chalk.blue(workspaces[name])})`);
2929
} else {
3030
console.log(chalk.green(name));
3131
}

packages/cli-plugin-workspaces/commands/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { Graph, alg } = require("graphlib");
22
const { join, resolve } = require("path");
33
const multimatch = require("multimatch");
4-
const { allPackages } = require("@webiny/project-utils/packages");
4+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
55

66
const createGraph = packages => {
77
const graph = new Graph();
@@ -46,7 +46,7 @@ const validateGraph = graph => {
4646
};
4747

4848
const getPackages = ({ script, folders, scopes }) => {
49-
return allPackages()
49+
return allWorkspaces()
5050
.filter(pkgPath => {
5151
if (!folders.length) {
5252
return true;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is required for running tests only!!
2-
const { allPackages } = require("@webiny/project-utils/packages");
2+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
33

44
module.exports = {
55
babelrc: true,
6-
babelrcRoots: allPackages()
6+
babelrcRoots: allWorkspaces()
77
};

packages/cwp-template-aws/template/dependencies.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"scripts": {
5858
"setup-repo": "node ./scripts/setupRepository.js",
5959
"setup-env-files": "node ./scripts/setupEnvFiles.js",
60-
"link-packages": "node ./scripts/linkPackages.js",
61-
"postinstall": "yarn link-packages",
60+
"link-workspaces": "node ./scripts/linkWorkspaces.js",
61+
"postinstall": "yarn link-workspaces",
6262
"test": "jest --config jest.config.js"
6363
}
6464
}

packages/cwp-template-aws/template/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const fs = require("fs");
22
const path = require("path");
3-
const { allPackages } = require("@webiny/project-utils/packages");
3+
const { allWorkspaces } = require("@webiny/project-utils/workspaces");
44

5-
const projects = allPackages()
5+
const projects = allWorkspaces()
66
.map(pkg => {
77
if (!fs.existsSync(path.join(pkg, "jest.config.js"))) {
88
return null;

packages/cwp-template-aws/template/scripts/linkPackages.js

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* This tool will re-link monorepo workspaces to one of the following directories (by priority):
3+
* - {workspace}/package.json -> publishConfig.directory
4+
* - lerna.json -> command.publish.contents
5+
* - workspace root directory
6+
*/
7+
(async () => {
8+
const { linkWorkspaces } = require("@webiny/project-utils/workspaces");
9+
await linkWorkspaces();
10+
})();

packages/project-utils/aliases/jest.js

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

packages/project-utils/aliases/webpack.js

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

packages/project-utils/bundling/app/config/paths.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require("path");
44
const fs = require("fs");
55
const url = require("url");
6-
const { allPackages } = require("../../../packages");
6+
const { allWorkspaces } = require("../../../workspaces");
77

88
// Make sure any symlinks in the project folder are resolved:
99
// https://github.com/facebook/create-react-app/issues/637
@@ -81,6 +81,6 @@ module.exports = ({ appIndexJs }) => ({
8181
appNodeModules: resolveApp("node_modules"),
8282
publicUrl: getPublicUrl(resolveApp("package.json")),
8383
servedPath: getServedPath(resolveApp("package.json")),
84-
allPackages: allPackages(),
84+
allWorkspaces: allWorkspaces(),
8585
moduleFileExtensions
8686
});

packages/project-utils/bundling/app/config/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ module.exports = function(webpackEnv, { paths, babelCustomizer }) {
360360
return false;
361361
}
362362

363-
return paths.allPackages.some(p => file.includes(p));
363+
return paths.allWorkspaces.some(p => file.includes(p));
364364
},
365365
exclude: /node_modules/
366366
},
@@ -384,7 +384,7 @@ module.exports = function(webpackEnv, { paths, babelCustomizer }) {
384384
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
385385
{
386386
test: /\.(js|mjs|jsx|ts|tsx)$/,
387-
include: [paths.appSrc, paths.appIndexJs, ...paths.allPackages],
387+
include: [paths.appSrc, paths.appIndexJs, ...paths.allWorkspaces],
388388
loader: require.resolve("babel-loader"),
389389
options: babelCustomizer({
390390
sourceType: "unambiguous",

packages/project-utils/packages/index.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { linkWorkspaces } = require("./linkWorkspaces");
2+
3+
const allWorkspaces = () => {
4+
const path = require("path");
5+
return require("get-yarn-workspaces")().map(pkg => pkg.replace(/\//g, path.sep));
6+
};
7+
8+
module.exports = { allWorkspaces, linkWorkspaces };

scripts/cz-adapter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "webiny-cz-adapter",
33
"version": "1.0.0"
4-
}
4+
}

scripts/layers/layers.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"webiny-v4-sharp": {
3-
"us-east-1": "arn:aws:lambda:us-east-1:632417926021:layer:webiny-v4-sharp:1",
4-
"us-east-2": "arn:aws:lambda:us-east-2:632417926021:layer:webiny-v4-sharp:1",
5-
"us-west-1": "arn:aws:lambda:us-west-1:632417926021:layer:webiny-v4-sharp:1",
6-
"us-west-2": "arn:aws:lambda:us-west-2:632417926021:layer:webiny-v4-sharp:1",
7-
"ap-south-1": "arn:aws:lambda:ap-south-1:632417926021:layer:webiny-v4-sharp:1",
8-
"ap-northeast-2": "arn:aws:lambda:ap-northeast-2:632417926021:layer:webiny-v4-sharp:1",
9-
"ap-northeast-1": "arn:aws:lambda:ap-northeast-1:632417926021:layer:webiny-v4-sharp:1",
10-
"ca-central-1": "arn:aws:lambda:ca-central-1:632417926021:layer:webiny-v4-sharp:1",
11-
"eu-central-1": "arn:aws:lambda:eu-central-1:632417926021:layer:webiny-v4-sharp:1",
12-
"eu-west-1": "arn:aws:lambda:eu-west-1:632417926021:layer:webiny-v4-sharp:1",
13-
"eu-west-2": "arn:aws:lambda:eu-west-2:632417926021:layer:webiny-v4-sharp:1",
14-
"eu-west-3": "arn:aws:lambda:eu-west-3:632417926021:layer:webiny-v4-sharp:1",
15-
"eu-north-1": "arn:aws:lambda:eu-north-1:632417926021:layer:webiny-v4-sharp:1",
16-
"ap-southeast-1": "arn:aws:lambda:ap-southeast-1:632417926021:layer:webiny-v4-sharp:1",
17-
"ap-southeast-2": "arn:aws:lambda:ap-southeast-2:632417926021:layer:webiny-v4-sharp:1",
18-
"sa-east-1": "arn:aws:lambda:sa-east-1:632417926021:layer:webiny-v4-sharp:1"
19-
}
2+
"webiny-v4-sharp": {
3+
"us-east-1": "arn:aws:lambda:us-east-1:632417926021:layer:webiny-v4-sharp:1",
4+
"us-east-2": "arn:aws:lambda:us-east-2:632417926021:layer:webiny-v4-sharp:1",
5+
"us-west-1": "arn:aws:lambda:us-west-1:632417926021:layer:webiny-v4-sharp:1",
6+
"us-west-2": "arn:aws:lambda:us-west-2:632417926021:layer:webiny-v4-sharp:1",
7+
"ap-south-1": "arn:aws:lambda:ap-south-1:632417926021:layer:webiny-v4-sharp:1",
8+
"ap-northeast-2": "arn:aws:lambda:ap-northeast-2:632417926021:layer:webiny-v4-sharp:1",
9+
"ap-northeast-1": "arn:aws:lambda:ap-northeast-1:632417926021:layer:webiny-v4-sharp:1",
10+
"ca-central-1": "arn:aws:lambda:ca-central-1:632417926021:layer:webiny-v4-sharp:1",
11+
"eu-central-1": "arn:aws:lambda:eu-central-1:632417926021:layer:webiny-v4-sharp:1",
12+
"eu-west-1": "arn:aws:lambda:eu-west-1:632417926021:layer:webiny-v4-sharp:1",
13+
"eu-west-2": "arn:aws:lambda:eu-west-2:632417926021:layer:webiny-v4-sharp:1",
14+
"eu-west-3": "arn:aws:lambda:eu-west-3:632417926021:layer:webiny-v4-sharp:1",
15+
"eu-north-1": "arn:aws:lambda:eu-north-1:632417926021:layer:webiny-v4-sharp:1",
16+
"ap-southeast-1": "arn:aws:lambda:ap-southeast-1:632417926021:layer:webiny-v4-sharp:1",
17+
"ap-southeast-2": "arn:aws:lambda:ap-southeast-2:632417926021:layer:webiny-v4-sharp:1",
18+
"sa-east-1": "arn:aws:lambda:sa-east-1:632417926021:layer:webiny-v4-sharp:1"
19+
}
2020
}

scripts/linkPackages.js

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

scripts/linkWorkspaces.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* This tool will re-link monorepo workspaces to one of the following directories (by priority):
3+
* - {workspaces}/package.json -> publishConfig.directory
4+
* - lerna.json -> command.publish.contents
5+
* - workspace root directory
6+
*/
7+
(async () => {
8+
const { linkWorkspaces } = require("../packages/project-utils/workspaces");
9+
await linkWorkspaces();
10+
})();

0 commit comments

Comments
 (0)