From 4ca44112eea75390d2fd193720826c21cc24f35b Mon Sep 17 00:00:00 2001 From: Jerome Simeon Date: Thu, 8 Apr 2021 18:53:20 -0400 Subject: [PATCH] chore(cleanup) Remove old unused scripts Signed-off-by: Jerome Simeon --- package.json | 11 +-- scripts/depcheck.js | 79 -------------------- scripts/manualrelease.sh | 45 ------------ scripts/pkgbump.js | 53 -------------- scripts/pkgcheck.js | 141 ------------------------------------ scripts/pkgset.js | 96 ------------------------ scripts/pkgstamp.js | 99 ------------------------- scripts/scan-all-modules.sh | 44 ----------- 8 files changed, 2 insertions(+), 566 deletions(-) delete mode 100644 scripts/depcheck.js delete mode 100755 scripts/manualrelease.sh delete mode 100644 scripts/pkgbump.js delete mode 100644 scripts/pkgcheck.js delete mode 100644 scripts/pkgset.js delete mode 100644 scripts/pkgstamp.js delete mode 100644 scripts/scan-all-modules.sh diff --git a/package.json b/package.json index 6a4884df4..6cface3e2 100644 --- a/package.json +++ b/package.json @@ -4,20 +4,13 @@ "version": "0.21.9", "scripts": { "postinstall": "npm run models:get && lerna bootstrap", - "prepare": "npm run pkgcheck", "models:get": "node ./scripts/external/getExternalModels.js", "models:clean": "node ./scripts/external/cleanExternalModels.js", - "pretest": "npm run depcheck && npm run licchk", + "pretest": "npm run licchk", "test": "lerna run test:cov", "coverage": "istanbul-combine -d coverage -r lcov packages/ergo-cli/coverage/*.json packages/ergo-compiler/coverage/*.json packages/ergo-engine/coverage/*.json && cat ./coverage/lcov.info", - "publish": "./scripts/manualrelease.sh", "repoclean": "lerna clean", - "licchk": "license-check-and-add", - "pkgcheck": "node ./scripts/pkgcheck.js", - "pkgstamp": "node ./scripts/pkgstamp.js", - "pkgbump": "node ./scripts/pkgbump.js && node ./scripts/pkgcheck.js --fix", - "pkgset": "node ./scripts/pkgset.js", - "depcheck": "node ./scripts/depcheck.js" + "licchk": "license-check-and-add" }, "repository": { "type": "git", diff --git a/scripts/depcheck.js b/scripts/depcheck.js deleted file mode 100644 index 5050d6ac2..000000000 --- a/scripts/depcheck.js +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env node -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const colors = require('colors'); -const fs = require('fs'); -const path = require('path'); - -const packages = {}; - -const lernaDirectory = path.resolve('.'); - -const masterPackageFile = path.resolve(lernaDirectory, 'package.json'); -const masterPackage = require(masterPackageFile); -packages['package.json'] = masterPackage; - -const packagesDirectory = path.resolve(lernaDirectory, 'packages'); -const packageNames = fs.readdirSync(packagesDirectory); -packageNames.forEach((packageName) => { - const packageFile = path.resolve(packagesDirectory, packageName, 'package.json'); - const thisPackage = require(packageFile); - packages[packageName] = thisPackage; -}); - -// Not going to catch ranges but unlikely to see those anyway -const badDependencies = {}; -const checkValue = function checkValue(packageIndex, dependency, currentValue) { - if (isNaN(currentValue.slice(0,1))) { - if (!badDependencies[packageIndex]) { - badDependencies[packageIndex] = []; - } - badDependencies[packageIndex].push({ dependency: dependency, currentValue: currentValue }); - } -}; - -for (const packageIndex in packages) { - const currentPackage = packages[packageIndex]; - for (const dependency in currentPackage.dependencies) { - checkValue(packageIndex, dependency, currentPackage.dependencies[dependency]); - } - for (const dependency in currentPackage.devDependencies) { - checkValue(packageIndex, dependency, currentPackage.devDependencies[dependency]); - } - for (const dependency in currentPackage.peerDependencies) { - checkValue(packageIndex, dependency, currentPackage.peerDependencies[dependency]); - } -} - -if (Object.keys(badDependencies).length > 0) { - console.error('Error: there is a mismatch between the versions of the packages in this repository!\n'); - for (const i in packages) { - if (badDependencies[i]) { - const currentPackage = packages[i]; - console.error(` ${i} ${currentPackage.version.green}`); - if (badDependencies[i]) { - badDependencies[i].forEach((badDependency) => { - console.error(` ${badDependency.dependency}@${badDependency.currentValue.red} (should be exact)`); - }); - } - } - } - console.error('\n'); - process.exit(1); -} else { - console.log('Status: no problems detected!'); -} \ No newline at end of file diff --git a/scripts/manualrelease.sh b/scripts/manualrelease.sh deleted file mode 100755 index 0c982e987..000000000 --- a/scripts/manualrelease.sh +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This script assumes that -# - the remote origin is set to a fork of the repo -# - the remote upstream is set to the original repo - -# Exit on first error, print all commands. -set -ev -set -o pipefail - -# Make sure we have the latest code from origin/master on our fork -git fetch --all --prune -git checkout master -git merge --ff-only upstream/master -git pull origin master - -# Increase the version number -npm run pkgbump -TARGET_VERSION=$( jq -r '.version' lerna.json ) -git add mechanization/Version.v -git add package.json -git commit -m "chore(release): Bump Ergo source version" -s - -# Publish each package to NPM registry. Generate changelog and update package.json files -lerna publish --conventional-commits -m 'chore(release): publish %s' --force-publish=* --repo-version ${TARGET_VERSION} --yes - -# Fix DCO sign-off -git commit --amend -s --no-edit -git push -f origin master - -# Merge into upstream/master -echo "Publish of ${TARGET_VERSION} successful." -echo "Now open a pull request to merge origin/master into upstream/master." diff --git a/scripts/pkgbump.js b/scripts/pkgbump.js deleted file mode 100644 index e5571e6f0..000000000 --- a/scripts/pkgbump.js +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env node -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const semver = require('semver'); - -const lernaDirectory = path.resolve('.'); -const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json'); -const lernaConfig = require(lernaConfigFile); -const targetVersion = semver.inc(lernaConfig.version, 'patch'); -lernaConfig.version = targetVersion; -fs.writeFileSync(lernaConfigFile, JSON.stringify(lernaConfig, null, 2), 'utf8'); - -const mechanizationVersionFileContents =`(* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*) - -(** This module defines Ergo version number *) - -Require Import String. - -Section Version. - Definition ergo_version := "${targetVersion}"%string. - -End Version. - -`; -const mechanizationVersionFile = fs.writeFileSync(path.resolve(lernaDirectory, 'mechanization/Version.v'),mechanizationVersionFileContents, 'utf8'); diff --git a/scripts/pkgcheck.js b/scripts/pkgcheck.js deleted file mode 100644 index 867efa4be..000000000 --- a/scripts/pkgcheck.js +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env node -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const child_process = require('child_process'); -const colors = require('colors'); -const fs = require('fs'); -const path = require('path'); -const semver = require('semver') - -const packages = {}; -const fix = (process.argv.indexOf('--fix') !== -1); - -const lernaDirectory = path.resolve('.'); -const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json'); -const lernaConfig = require(lernaConfigFile); -const targetVersion = lernaConfig.version; -const targetDependency = `${targetVersion}`; -packages['lerna.json'] = lernaConfig; - -if (!semver.valid(targetVersion)) { - console.error(`Error: the version "${targetVersion}" in "${lernaConfigFile}" is invalid!`); - process.exit(1); -} - -const masterPackageFile = path.resolve(lernaDirectory, 'package.json'); -const masterPackage = require(masterPackageFile); -packages['package.json'] = masterPackage; - -const packagesDirectory = path.resolve(lernaDirectory, 'packages'); -const packageNames = fs.readdirSync(packagesDirectory); -packageNames.forEach((packageName) => { - const packageFile = path.resolve(packagesDirectory, packageName, 'package.json'); - const thisPackage = require(packageFile); - packages[packageName] = thisPackage; -}); - -const ergoVersionFile = path.resolve(lernaDirectory, 'mechanization/Version.v'); -const ergoVersionFileContents = fs.readFileSync(ergoVersionFile, 'utf8'); -/* XXX -const matches = ergoVersionFileContents.match(/Definition ergo_version := \"([\w.-]+)\"%string./); -if(matches === null || (matches && matches[1] !== targetVersion)){ - console.error(`Error: the version "${matches[1]}" in "${ergoVersionFile}" is invalid!`); - process.exit(1); -} -*/ - -let mismatch = false; -const badDependencies = {}; -for (const i in packages) { - const currentPackage = packages[i]; - if (targetVersion !== currentPackage.version) { - mismatch = true; - break; - } -} - -for (const i in packages) { - const currentPackage = packages[i]; - for (const j in packages) { - const otherPackage = packages[j]; - for (const dependency in currentPackage.dependencies) { - const currentValue = currentPackage.dependencies[dependency]; - if (dependency === otherPackage.name) { - if (currentValue !== targetDependency) { - if (!badDependencies[i]) { - badDependencies[i] = []; - } - badDependencies[i].push({ dependency: dependency, currentValue: currentValue }); - mismatch = true; - } - } - } - for (const dependency in currentPackage.devDependencies) { - const currentValue = currentPackage.devDependencies[dependency]; - if (dependency === otherPackage.name) { - if (currentValue !== targetDependency) { - if (!badDependencies[i]) { - badDependencies[i] = []; - } - badDependencies[i].push({ dependency: dependency, currentValue: currentValue }); - mismatch = true; - } - } - } - for (const dependency in currentPackage.peerDependencies) { - const currentValue = currentPackage.peerDependencies[dependency]; - if (dependency === otherPackage.name) { - if (currentValue !== targetDependency) { - if (!badDependencies[i]) { - badDependencies[i] = []; - } - badDependencies[i].push({ dependency: dependency, currentValue: currentValue }); - mismatch = true; - } - } - } - } -} - -if (mismatch && !fix) { - console.error('Error: there is a mismatch between the versions of the packages in this repository!\n'); - for (const i in packages) { - const currentPackage = packages[i]; - if (targetVersion !== currentPackage.version) { - console.error(` ${i} ${currentPackage.version.red} (should be ${targetVersion})`); - } else { - console.error(` ${i} ${currentPackage.version.green}`); - } - if (badDependencies[i]) { - badDependencies[i].forEach((badDependency) => { - console.error(` ${badDependency.dependency}@${badDependency.currentValue.red} (should be ${targetDependency})`); - }); - } - } - console.error('\n'); - console.error(`Run "scripts/pkgcheck.js --fix" inside the directory "${lernaDirectory}" to resolve this problem and change the version to "${targetVersion}"`); - process.exit(1); -} else if (mismatch && fix) { - const command = `lerna publish --skip-git --skip-npm --yes --repo-version ${targetVersion} --force-publish '*' --exact`; - console.warn(`Status: running command ${command} to fix problems ...`) - child_process.execSync(command); - console.warn(`Status: modifying "${masterPackageFile} to fix problems ...`); - masterPackage.version = targetVersion; - fs.writeFileSync(masterPackageFile, JSON.stringify(masterPackage, null, 2), 'utf8'); -} else { - console.log('Status: no problems detected!'); -} \ No newline at end of file diff --git a/scripts/pkgset.js b/scripts/pkgset.js deleted file mode 100644 index e2fa9cdbf..000000000 --- a/scripts/pkgset.js +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env node -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const semver = require('semver') - -const lernaDirectory = path.resolve('.'); -const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json'); -const lernaConfig = require(lernaConfigFile); -lernaConfig.version.replace(/-.*/, ''); -const targetVersion = semver.clean(process.argv[2]); -lernaConfig.version = targetVersion; -fs.writeFileSync(lernaConfigFile, JSON.stringify(lernaConfig, null, 2), 'utf8'); - -const masterPackageFile = path.resolve(lernaDirectory, 'package.json'); -const masterPackage = require(masterPackageFile); -masterPackage.version = targetVersion; -fs.writeFileSync(masterPackageFile, JSON.stringify(masterPackage, null, 2), 'utf8'); - -const packagesDirectory = path.resolve(lernaDirectory, 'packages'); -const packageNames = fs.readdirSync(packagesDirectory); -const packages = {}; -packageNames.forEach((packageName) => { - const packageFile = path.resolve(packagesDirectory, packageName, 'package.json'); - const thisPackage = require(packageFile); - thisPackage.version = targetVersion; - packages[packageName] = thisPackage; -}); - -for (const i in packages) { - const currentPackage = packages[i]; - for (const j in packages) { - const otherPackage = packages[j]; - for (const dependency in currentPackage.dependencies) { - const currentValue = currentPackage.dependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.dependencies[dependency] = targetVersion; - } - } - for (const dependency in currentPackage.devDependencies) { - const currentValue = currentPackage.devDependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.devDependencies[dependency] = targetVersion; - } - } - for (const dependency in currentPackage.peerDependencies) { - const currentValue = currentPackage.peerDependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.peerDependencies[dependency] = targetVersion; - } - } - } - const packageFile = path.resolve(packagesDirectory, i, 'package.json'); - fs.writeFileSync(packageFile, JSON.stringify(currentPackage, null, 2), 'utf8'); -} - -const mechanizationVersionFileContents =`(* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*) - -(** This module defines Ergo version number *) - -Require Import String. - -Section Version. - Definition ergo_version := "${targetVersion}"%string. - -End Version. - -`; -const mechanizationVersionFile = fs.writeFileSync(path.resolve(lernaDirectory, 'mechanization/Version.v'),mechanizationVersionFileContents, 'utf8'); diff --git a/scripts/pkgstamp.js b/scripts/pkgstamp.js deleted file mode 100644 index 5827fcc52..000000000 --- a/scripts/pkgstamp.js +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env node -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const fs = require('fs'); -const moment = require('moment-mini'); -const path = require('path'); -const semver = require('semver'); - -const timestamp = moment().format('YYYYMMDDHHmmss'); - -const lernaDirectory = path.resolve('.'); -const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json'); -const lernaConfig = require(lernaConfigFile); -lernaConfig.version.replace(/-.*/, ''); -const targetVersion = semver.inc(lernaConfig.version, 'patch') + '-' + timestamp; -lernaConfig.version = targetVersion; -fs.writeFileSync(lernaConfigFile, JSON.stringify(lernaConfig, null, 2), 'utf8'); - -const masterPackageFile = path.resolve(lernaDirectory, 'package.json'); -const masterPackage = require(masterPackageFile); -masterPackage.version = targetVersion; -fs.writeFileSync(masterPackageFile, JSON.stringify(masterPackage, null, 2), 'utf8'); - -const packagesDirectory = path.resolve(lernaDirectory, 'packages'); -const packageNames = fs.readdirSync(packagesDirectory); -const packages = {}; -packageNames.forEach((packageName) => { - const packageFile = path.resolve(packagesDirectory, packageName, 'package.json'); - const thisPackage = require(packageFile); - thisPackage.version = targetVersion; - packages[packageName] = thisPackage; -}); - -for (const i in packages) { - const currentPackage = packages[i]; - for (const j in packages) { - const otherPackage = packages[j]; - for (const dependency in currentPackage.dependencies) { - const currentValue = currentPackage.dependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.dependencies[dependency] = targetVersion; - } - } - for (const dependency in currentPackage.devDependencies) { - const currentValue = currentPackage.devDependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.devDependencies[dependency] = targetVersion; - } - } - for (const dependency in currentPackage.peerDependencies) { - const currentValue = currentPackage.peerDependencies[dependency]; - if (dependency === otherPackage.name) { - currentPackage.peerDependencies[dependency] = targetVersion; - } - } - } - const packageFile = path.resolve(packagesDirectory, i, 'package.json'); - fs.writeFileSync(packageFile, JSON.stringify(currentPackage, null, 2), 'utf8'); -} - -const mechanizationVersionFileContents =`(* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*) - -(** This module defines Ergo version number *) - -Require Import String. - -Section Version. - Definition ergo_version := "${targetVersion}"%string. - -End Version. - -`; -const mechanizationVersionFile = fs.writeFileSync(path.resolve(lernaDirectory, 'mechanization/Version.v'),mechanizationVersionFileContents, 'utf8'); diff --git a/scripts/scan-all-modules.sh b/scripts/scan-all-modules.sh deleted file mode 100644 index 39c774543..000000000 --- a/scripts/scan-all-modules.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# find . -maxdepth 2 -name package.json | xargs jq -s 'reduce .[] as $item ({} ; . + {($item.name): {dependencies:$item.dependencies,devDependencies:$item.devDependencies }} )' | prettyoutput --indent 3 -# Exit on first error, print all commands. -set -e - -# Grab the parent (root) directory. -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" - -BIN=${DIR}/node_modules/.bin - -echo "Scanning all the node modules starting at "${DIR} -#echo "Needs to have had npm install -g npm -g install licensecheck" - -rm -f "${DIR}/license-raw.txt" -touch "${DIR}/license-raw.txt" -rm -f "${DIR}/license-full.txt" -touch "${DIR}/license-full.txt" - - - -ls -d "${DIR}"/packages/* | while read dirname -do - cd "${dirname}" - ${BIN}/licensecheck --tsv >> "${DIR}/license-raw.txt" - ${BIN}/licensecheck >> "${DIR}/license-full.txt" - echo "-------------------------------------------" >> "${DIR}/license-full.txt" - -done - -exit \ No newline at end of file