Skip to content

Commit

Permalink
Merge pull request #42 from MailOnline/feat/remove-deprecated-lerna-d…
Browse files Browse the repository at this point in the history
…ependency

feat: 🎸 remove deprecated lerna dependencies
  • Loading branch information
carpasse authored Jun 27, 2024
2 parents 2a29475 + 1871b00 commit 7cc2029
Show file tree
Hide file tree
Showing 9 changed files with 3,004 additions and 4,026 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build
on:
push:
branches-ignore:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
cache: 'yarn'
check-latest: true
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn run test
- name: Lint code
run: yarn run lint
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
cache: 'yarn'
check-latest: true
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn run test
- name: Lint code
run: yarn run lint
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn run semantic-release
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn test
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
lts/hydrogen
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"main": "index.js",
"scripts": {
"test": "echo \"No test specified\" && exit 0",
"lint": "eslint **/*.js",
"lint": "eslint './**/*.js'",
"precommit": "npm run lint",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"prepare": "husky",
"semantic-release": "semantic-release"
},
"author": "MailOnline <fe@mailonline.co.uk>",
"homepage": "https://github.com/MailOnline/mol-conventional-changelog",
Expand All @@ -18,24 +19,24 @@
"license": "UNLICENSED",
"dependencies": {
"app-root-path": "^2.2.1",
"glob": "^10.4.2",
"inquirer": "^7.0.5",
"pad-right": "^0.2.2",
"shelljs": "^0.8.5",
"signale": "^1.4.0",
"word-wrap": "^1.2.3"
},
"peerDependencies": {
"@lerna/project": "^5.1.8",
"lerna": "^5.1.8"
},
"devDependencies": {
"@lerna/project": "^5.1.8",
"commitizen": "^4.2.4",
"eslint": "^7.0.0",
"eslint-config-mailonline": "^9.0.2",
"husky": "^0.14.3",
"lerna": "^5.1.8",
"semantic-release": "^19.0.0"
"eslint": "8.57.0",
"eslint-config-mailonline": "^13.0.2",
"husky": "^9.0.11",
"semantic-release": "^22.0.12"
},
"release": {
"branches": [
"master"
]
},
"resolutions": {
"lodash": "^4.17.21",
Expand Down
11 changes: 4 additions & 7 deletions src/createPrompter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,12 @@ module.exports = (config) => {
let promptQuestions = createQuestions(config);

if (IS_LERNA_PROJECT) {
return getAllPackages().then((allPackagesPromise) => {
const allPackages = allPackagesPromise.map((pkg) => pkg.name);
const allPackages = getAllPackages().map((pkg) => pkg.name);
const changedPackages = getChangedPackages();

return getChangedPackages().then((changedPackages) => {
promptQuestions = promptQuestions.concat(createPackagesQuestion(allPackages, changedPackages));
promptQuestions = promptQuestions.concat(createPackagesQuestion(allPackages, changedPackages));

return returnPrompt(config, promptQuestions, commit);
});
});
return returnPrompt(config, promptQuestions, commit);
}

return returnPrompt(config, promptQuestions, commit);
Expand Down
17 changes: 13 additions & 4 deletions src/lernaUtils.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
/* eslint-disable global-require */
const path = require('path');
const fs = require('fs');
const glob = require('glob');

const getAllPackages = () => {
const {Project} = require('@lerna/project');
const packagePaths = JSON.parse(fs.readFileSync('package.json')).workspaces;

return new Project().getPackages();
const packages = packagePaths.flatMap((packagePath) =>
glob.sync(packagePath).map((pkgPath) => ({
location: pkgPath,
name: JSON.parse(fs.readFileSync(path.join(pkgPath, 'package.json'))).name
}))
);

return packages;
};

const getChangedPackages = async () => {
const getChangedPackages = () => {
const shell = require('shelljs');

const changedFiles = shell.exec('git diff --cached --name-only', {silent: true})
.stdout
.split('\n');

const packages = await getAllPackages();
const packages = getAllPackages();

return packages
.filter((pkg) => {
Expand Down
Loading

0 comments on commit 7cc2029

Please sign in to comment.