Remove the remove_tags script
This commit is contained in:
@@ -8,8 +8,6 @@ This repository contains a few helpful scripts for working with this mono repo.
|
||||
|
||||
**`yarn find_unused_deps`**: Sometimes we accidentally leave dependencies listed in `package.json` that are no longer being used. This script finds potential dependencies that might no longer be in use. Please verify that it is no longer in use before removing, the `depcheck` package we use under-the-hood doesn't handle some TS quirks perfectly.
|
||||
|
||||
**`yarn remove_tags`**: Our publishing script calls `lerna publish` under-the-hood. If this command fails, it might have created new versioned git tags for each package. Removing these manually is tedious, so you can also run this command instead. Before doing so, check to see if `lerna` already created the publish commit. If so, first revert that with `git reset --hard HEAD~1`, then run this command.
|
||||
|
||||
**`yarn test:publish`**: Execute a test-run of the publish script. This dry run won't actually publish, nor will it commit/push anything to Github.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
"build": "tsc",
|
||||
"test:publish": "run-s build script:publish",
|
||||
"find_unused_deps": "run-s build script:find_unused_deps",
|
||||
"remove_tags": "run-s build script:remove_tags",
|
||||
"script:deps_versions": "node ./lib/deps_versions.js",
|
||||
"script:prepublish_checks": "node ./lib/prepublish_checks.js",
|
||||
"script:publish": "IS_DRY_RUN=true node ./lib/publish.js",
|
||||
"script:find_unused_deps": "node ./lib/find_unused_dependencies.js",
|
||||
"script:remove_tags": "node ./lib/remove_tags.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import lernaGetPackages = require('lerna-get-packages');
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
import { exec as execAsync } from 'promisify-child-process';
|
||||
import semverSort = require('semver-sort');
|
||||
|
||||
import { constants } from './constants';
|
||||
import { Changelog } from './types';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
(async () => {
|
||||
const shouldIncludePrivate = true;
|
||||
const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
|
||||
|
||||
for (const lernaPackage of updatedPublicLernaPackages) {
|
||||
const packageName = lernaPackage.package.name;
|
||||
const currentVersion = lernaPackage.package.version;
|
||||
const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json');
|
||||
// Private packages don't have changelogs, and their versions are always incremented
|
||||
// by a patch version.
|
||||
const changelogJSONIfExists = utils.getChangelogJSONIfExists(changelogJSONPath);
|
||||
|
||||
let latestChangelogVersion: string;
|
||||
if (!_.isUndefined(changelogJSONIfExists)) {
|
||||
let changelogs: Changelog;
|
||||
try {
|
||||
changelogs = JSON.parse(changelogJSONIfExists);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`${lernaPackage.package.name}'s CHANGELOG.json contains invalid JSON. Please fix and try again.`,
|
||||
);
|
||||
}
|
||||
latestChangelogVersion = changelogs[0].version;
|
||||
} else {
|
||||
latestChangelogVersion = utils.getNextPatchVersion(currentVersion);
|
||||
}
|
||||
|
||||
const sortedVersions = semverSort.desc([latestChangelogVersion, currentVersion]);
|
||||
if (sortedVersions[0] === latestChangelogVersion && latestChangelogVersion !== currentVersion) {
|
||||
const tagName = `${packageName}@${latestChangelogVersion}`;
|
||||
try {
|
||||
await execAsync(`git tag -d ${tagName}`, { cwd: constants.monorepoRootPath });
|
||||
utils.log(`removed tag: ${tagName}`);
|
||||
} catch (err) {
|
||||
if (_.includes(err.message, 'not found')) {
|
||||
utils.log(`Could not find tag: ${tagName}`);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})().catch(err => {
|
||||
utils.log(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user