Skip to content

Commit

Permalink
feat: migrated to monorepo with separate packages
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ifc-cli is no longer in iframe-coordinator

COMUI-1121
  • Loading branch information
katie-bobbe-genesys committed Sep 15, 2022
1 parent c2bc68a commit b042338
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lint": "commitlint -f de759fc509cf39895450dc31742cfb36b08e01b8",
"sync-versions": "./scripts/sync-versions.mjs",
"release": "standard-version --prerelease beta && npm run sync-versions",
"release.dry": "standard-version --prerelease beta --dry-run",
"publish-libs": "npm publish --tag=beta --workspace=iframe-coordinator --workspace=ifc-cli",
"doc": "npm run doc --workspace=iframe-coordinator"
},
Expand All @@ -36,6 +37,12 @@
"path": "./node_modules/cz-conventional-changelog"
}
},
"standard-version": {
"skip": {
"commit": true,
"tag": true
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
Expand Down
42 changes: 24 additions & 18 deletions scripts/sync-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,41 @@ import { execSync } from 'child_process';
import { readdirSync } from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
import { createRequire } from "module";
import { createRequire } from 'module';

const projectDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
const version = getProjectVersion();
const workspaces = getWorkspaceDirs();

updateWorkspaceVersions(workspaces, version);

createReleaseCommit(version);

function updateWorkspaceVersions(workspaceDirs, version) {
workspaceDirs.forEach((dir) => {
execSync(`npm version ${version}`, {cwd: dir});
})
workspaceDirs.forEach(dir => {
execSync(`npm version ${version}`, { cwd: dir });
});
}

function getWorkspaceDirs() {
const packages = readdirSync(path.join(projectDir, 'packages'));
const packagesDirs = packages.map((dir) => {
return path.join(projectDir, `packages/${dir}`)
})
const apps = readdirSync(path.join(projectDir, 'apps'));
const appsDir = apps.map((dir) => {
return path.join(projectDir, `apps/${dir}`)
})
return packagesDirs.concat(appsDir);
const packages = readdirSync(path.join(projectDir, 'packages'));
const packagesDirs = packages.map(dir => {
return path.join(projectDir, `packages/${dir}`);
});
const apps = readdirSync(path.join(projectDir, 'apps'));
const appsDir = apps.map(dir => {
return path.join(projectDir, `apps/${dir}`);
});
return packagesDirs.concat(appsDir);
}

function getProjectVersion() {
const require = createRequire(import.meta.url);
const version = require(path.join(projectDir, 'package.json')).version;
return version;
}
const require = createRequire(import.meta.url);
const version = require(path.join(projectDir, 'package.json')).version;
return version;
}

function createReleaseCommit(version) {
execSync(`git add .`);
execSync(`git commit -m 'chore(release): ${version}'`);
execSync(`git tag v${version}`);
}

0 comments on commit b042338

Please sign in to comment.