Skip to content

Commit

Permalink
chore(workspaces): rename allPackages to allWorkspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Jan 10, 2021
1 parent 7a3e70b commit c6c4df9
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 103 deletions.
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is require for running tests only!!
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

module.exports = {
babelrc: true,
babelrcRoots: allPackages()
babelrcRoots: allWorkspaces()
};
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require("fs");
const path = require("path");
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

const projects = allPackages()
const projects = allWorkspaces()
.map(pkg => {
if (!fs.existsSync(path.join(pkg, "jest.config.js"))) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"webiny-versions": "node ./scripts/webinyVersions.js",
"release-latest": "node ./scripts/releaseLatest.js",
"lint-staged": "lint-staged",
"postinstall": "node ./scripts/linkPackages.js",
"postinstall": "node ./scripts/linkWorkspaces.js",
"prepublishOnly": "node scripts/prepublishOnly.js",
"prettier": "prettier \"**/**/*.{js,jsx,ts,tsx}\" --config .prettierrc.js",
"prettier:check": "yarn prettier --check",
Expand Down
12 changes: 6 additions & 6 deletions packages/cli-plugin-workspaces/commands/list.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { join } = require("path");
const chalk = require("chalk");
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

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

module.exports = async ({ json, withPath }) => {
const packages = allPackages().reduce((acc, folder) => {
const workspaces = allWorkspaces().reduce((acc, folder) => {
const json = require(join(folder, "package.json"));
acc[json.name] = folder;
return acc;
Expand All @@ -16,16 +16,16 @@ module.exports = async ({ json, withPath }) => {
if (json) {
// `withPath` outputs a key => value object, containing workspace name and absolute path
if (withPath) {
outputJSON(packages);
outputJSON(workspaces);
} else {
outputJSON(Object.keys(packages));
outputJSON(Object.keys(workspaces));
}
return;
}

Object.keys(packages).forEach(name => {
Object.keys(workspaces).forEach(name => {
if (withPath) {
console.log(`${chalk.green(name)} (${chalk.blue(packages[name])})`);
console.log(`${chalk.green(name)} (${chalk.blue(workspaces[name])})`);
} else {
console.log(chalk.green(name));
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-plugin-workspaces/commands/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Graph, alg } = require("graphlib");
const { join, resolve } = require("path");
const multimatch = require("multimatch");
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

const createGraph = packages => {
const graph = new Graph();
Expand Down Expand Up @@ -46,7 +46,7 @@ const validateGraph = graph => {
};

const getPackages = ({ script, folders, scopes }) => {
return allPackages()
return allWorkspaces()
.filter(pkgPath => {
if (!folders.length) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/cwp-template-aws/template/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is required for running tests only!!
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

module.exports = {
babelrc: true,
babelrcRoots: allPackages()
babelrcRoots: allWorkspaces()
};
4 changes: 2 additions & 2 deletions packages/cwp-template-aws/template/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"scripts": {
"setup-repo": "node ./scripts/setupRepository.js",
"setup-env-files": "node ./scripts/setupEnvFiles.js",
"link-packages": "node ./scripts/linkPackages.js",
"postinstall": "yarn link-packages",
"link-workspaces": "node ./scripts/linkWorkspaces.js",
"postinstall": "yarn link-workspaces",
"test": "jest --config jest.config.js"
}
}
4 changes: 2 additions & 2 deletions packages/cwp-template-aws/template/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const fs = require("fs");
const path = require("path");
const { allPackages } = require("@webiny/project-utils/packages");
const { allWorkspaces } = require("@webiny/project-utils/workspaces");

const projects = allPackages()
const projects = allWorkspaces()
.map(pkg => {
if (!fs.existsSync(path.join(pkg, "jest.config.js"))) {
return null;
Expand Down
10 changes: 0 additions & 10 deletions packages/cwp-template-aws/template/scripts/linkPackages.js

This file was deleted.

10 changes: 10 additions & 0 deletions packages/cwp-template-aws/template/scripts/linkWorkspaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* This tool will re-link monorepo workspaces to one of the following directories (by priority):
* - {workspace}/package.json -> publishConfig.directory
* - lerna.json -> command.publish.contents
* - workspace root directory
*/
(async () => {
const { linkWorkspaces } = require("@webiny/project-utils/workspaces");
await linkWorkspaces();
})();
17 changes: 0 additions & 17 deletions packages/project-utils/aliases/jest.js

This file was deleted.

16 changes: 0 additions & 16 deletions packages/project-utils/aliases/webpack.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/project-utils/bundling/app/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require("path");
const fs = require("fs");
const url = require("url");
const { allPackages } = require("../../../packages");
const { allWorkspaces } = require("../../../workspaces");

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
Expand Down Expand Up @@ -81,6 +81,6 @@ module.exports = ({ appIndexJs }) => ({
appNodeModules: resolveApp("node_modules"),
publicUrl: getPublicUrl(resolveApp("package.json")),
servedPath: getServedPath(resolveApp("package.json")),
allPackages: allPackages(),
allWorkspaces: allWorkspaces(),
moduleFileExtensions
});
4 changes: 2 additions & 2 deletions packages/project-utils/bundling/app/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ module.exports = function(webpackEnv, { paths, babelCustomizer }) {
return false;
}

return paths.allPackages.some(p => file.includes(p));
return paths.allWorkspaces.some(p => file.includes(p));
},
exclude: /node_modules/
},
Expand All @@ -384,7 +384,7 @@ module.exports = function(webpackEnv, { paths, babelCustomizer }) {
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: [paths.appSrc, paths.appIndexJs, ...paths.allPackages],
include: [paths.appSrc, paths.appIndexJs, ...paths.allWorkspaces],
loader: require.resolve("babel-loader"),
options: babelCustomizer({
sourceType: "unambiguous",
Expand Down
8 changes: 0 additions & 8 deletions packages/project-utils/packages/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/project-utils/workspaces/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { linkWorkspaces } = require("./linkWorkspaces");

const allWorkspaces = () => {
const path = require("path");
return require("get-yarn-workspaces")().map(pkg => pkg.replace(/\//g, path.sep));
};

module.exports = { allWorkspaces, linkWorkspaces };
2 changes: 1 addition & 1 deletion scripts/cz-adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "webiny-cz-adapter",
"version": "1.0.0"
}
}
36 changes: 18 additions & 18 deletions scripts/layers/layers.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"webiny-v4-sharp": {
"us-east-1": "arn:aws:lambda:us-east-1:632417926021:layer:webiny-v4-sharp:1",
"us-east-2": "arn:aws:lambda:us-east-2:632417926021:layer:webiny-v4-sharp:1",
"us-west-1": "arn:aws:lambda:us-west-1:632417926021:layer:webiny-v4-sharp:1",
"us-west-2": "arn:aws:lambda:us-west-2:632417926021:layer:webiny-v4-sharp:1",
"ap-south-1": "arn:aws:lambda:ap-south-1:632417926021:layer:webiny-v4-sharp:1",
"ap-northeast-2": "arn:aws:lambda:ap-northeast-2:632417926021:layer:webiny-v4-sharp:1",
"ap-northeast-1": "arn:aws:lambda:ap-northeast-1:632417926021:layer:webiny-v4-sharp:1",
"ca-central-1": "arn:aws:lambda:ca-central-1:632417926021:layer:webiny-v4-sharp:1",
"eu-central-1": "arn:aws:lambda:eu-central-1:632417926021:layer:webiny-v4-sharp:1",
"eu-west-1": "arn:aws:lambda:eu-west-1:632417926021:layer:webiny-v4-sharp:1",
"eu-west-2": "arn:aws:lambda:eu-west-2:632417926021:layer:webiny-v4-sharp:1",
"eu-west-3": "arn:aws:lambda:eu-west-3:632417926021:layer:webiny-v4-sharp:1",
"eu-north-1": "arn:aws:lambda:eu-north-1:632417926021:layer:webiny-v4-sharp:1",
"ap-southeast-1": "arn:aws:lambda:ap-southeast-1:632417926021:layer:webiny-v4-sharp:1",
"ap-southeast-2": "arn:aws:lambda:ap-southeast-2:632417926021:layer:webiny-v4-sharp:1",
"sa-east-1": "arn:aws:lambda:sa-east-1:632417926021:layer:webiny-v4-sharp:1"
}
"webiny-v4-sharp": {
"us-east-1": "arn:aws:lambda:us-east-1:632417926021:layer:webiny-v4-sharp:1",
"us-east-2": "arn:aws:lambda:us-east-2:632417926021:layer:webiny-v4-sharp:1",
"us-west-1": "arn:aws:lambda:us-west-1:632417926021:layer:webiny-v4-sharp:1",
"us-west-2": "arn:aws:lambda:us-west-2:632417926021:layer:webiny-v4-sharp:1",
"ap-south-1": "arn:aws:lambda:ap-south-1:632417926021:layer:webiny-v4-sharp:1",
"ap-northeast-2": "arn:aws:lambda:ap-northeast-2:632417926021:layer:webiny-v4-sharp:1",
"ap-northeast-1": "arn:aws:lambda:ap-northeast-1:632417926021:layer:webiny-v4-sharp:1",
"ca-central-1": "arn:aws:lambda:ca-central-1:632417926021:layer:webiny-v4-sharp:1",
"eu-central-1": "arn:aws:lambda:eu-central-1:632417926021:layer:webiny-v4-sharp:1",
"eu-west-1": "arn:aws:lambda:eu-west-1:632417926021:layer:webiny-v4-sharp:1",
"eu-west-2": "arn:aws:lambda:eu-west-2:632417926021:layer:webiny-v4-sharp:1",
"eu-west-3": "arn:aws:lambda:eu-west-3:632417926021:layer:webiny-v4-sharp:1",
"eu-north-1": "arn:aws:lambda:eu-north-1:632417926021:layer:webiny-v4-sharp:1",
"ap-southeast-1": "arn:aws:lambda:ap-southeast-1:632417926021:layer:webiny-v4-sharp:1",
"ap-southeast-2": "arn:aws:lambda:ap-southeast-2:632417926021:layer:webiny-v4-sharp:1",
"sa-east-1": "arn:aws:lambda:sa-east-1:632417926021:layer:webiny-v4-sharp:1"
}
}
10 changes: 0 additions & 10 deletions scripts/linkPackages.js

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/linkWorkspaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* This tool will re-link monorepo workspaces to one of the following directories (by priority):
* - {workspaces}/package.json -> publishConfig.directory
* - lerna.json -> command.publish.contents
* - workspace root directory
*/
(async () => {
const { linkWorkspaces } = require("../packages/project-utils/workspaces");
await linkWorkspaces();
})();

0 comments on commit c6c4df9

Please sign in to comment.