@b12k/mvm 0.0.11 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +220 -5
  2. package/dist/artifacts.d.ts +3 -0
  3. package/dist/artifacts.js +89 -0
  4. package/dist/changed.d.ts +7 -0
  5. package/dist/changed.js +19 -0
  6. package/dist/cli.js +44 -0
  7. package/dist/config.d.ts +11 -0
  8. package/dist/config.js +36 -0
  9. package/dist/git.d.ts +11 -0
  10. package/dist/git.js +92 -0
  11. package/dist/index.d.ts +6 -3
  12. package/dist/index.js +5 -29
  13. package/dist/json.d.ts +3 -0
  14. package/dist/json.js +9 -0
  15. package/dist/lock-file.d.ts +12 -0
  16. package/dist/lock-file.js +46 -0
  17. package/dist/package-json.d.ts +32 -0
  18. package/dist/package-json.js +72 -0
  19. package/dist/pin.d.ts +8 -0
  20. package/dist/pin.js +66 -0
  21. package/dist/propagate.d.ts +2 -0
  22. package/dist/propagate.js +46 -0
  23. package/package.json +75 -75
  24. package/dist/cli-lock.js +0 -15
  25. package/dist/cli-skip.d.ts +0 -2
  26. package/dist/cli-skip.js +0 -35
  27. package/dist/cli-update.d.ts +0 -2
  28. package/dist/cli-update.js +0 -25
  29. package/dist/lock.d.ts +0 -1
  30. package/dist/lock.js +0 -19
  31. package/dist/skip.d.ts +0 -8
  32. package/dist/skip.js +0 -72
  33. package/dist/update.d.ts +0 -8
  34. package/dist/update.js +0 -68
  35. package/dist/utils/do-nothing.d.ts +0 -1
  36. package/dist/utils/do-nothing.js +0 -18
  37. package/dist/utils/get-dependency-type.d.ts +0 -1
  38. package/dist/utils/get-dependency-type.js +0 -25
  39. package/dist/utils/get-repo-root-path.d.ts +0 -1
  40. package/dist/utils/get-repo-root-path.js +0 -19
  41. package/dist/utils/index.d.ts +0 -8
  42. package/dist/utils/index.js +0 -39
  43. package/dist/utils/log-json.d.ts +0 -2
  44. package/dist/utils/log-json.js +0 -18
  45. package/dist/utils/read-local-package-json.d.ts +0 -2
  46. package/dist/utils/read-local-package-json.js +0 -19
  47. package/dist/utils/sort-lock-keys.d.ts +0 -5
  48. package/dist/utils/sort-lock-keys.js +0 -21
  49. package/dist/utils/to-semver.d.ts +0 -4
  50. package/dist/utils/to-semver.js +0 -39
  51. package/dist/utils/types.d.ts +0 -11
  52. package/dist/utils/types.js +0 -12
  53. /package/dist/{cli-lock.d.ts → cli.d.ts} +0 -0
@@ -0,0 +1,46 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { checkIsJsonObject, parseJsonObject } from "./json.js";
3
+ import { checkIsDependencyProtocol } from "./package-json.js";
4
+ function getLockedDependencies(lockFile, type, file) {
5
+ const dependencies = lockFile[type];
6
+ if (void 0 !== dependencies && !checkIsJsonObject(dependencies)) throw new Error(`Invalid ${type} in ${file}.`);
7
+ return dependencies;
8
+ }
9
+ function getLockedDependency(entry, name, file) {
10
+ if (!checkIsJsonObject(entry)) throw new Error(`Expected version and protocol for ${name} in ${file}.`);
11
+ const { protocol, version } = entry;
12
+ if (!checkIsDependencyProtocol(protocol)) throw new Error(`Invalid protocol for ${name} in ${file}.`);
13
+ return {
14
+ protocol,
15
+ version
16
+ };
17
+ }
18
+ function readLockFile(file) {
19
+ try {
20
+ const contents = readFileSync(file, 'utf8');
21
+ return {
22
+ contents,
23
+ hasLockFile: true,
24
+ lockFile: contents ? parseJsonObject(contents, file) : void 0
25
+ };
26
+ } catch (error) {
27
+ if (error instanceof Error && 'code' in error && 'ENOENT' === error.code) return {
28
+ contents: '',
29
+ hasLockFile: false,
30
+ lockFile: void 0
31
+ };
32
+ throw error;
33
+ }
34
+ }
35
+ function sortLockKeys(_key, entry) {
36
+ if (!checkIsJsonObject(entry)) return entry;
37
+ return Object.fromEntries(Object.keys(entry).toSorted().map((key)=>[
38
+ key,
39
+ entry[key]
40
+ ]));
41
+ }
42
+ function writeLockFile(file, prevContents, lockFile) {
43
+ const nextContents = `${JSON.stringify(lockFile, sortLockKeys, 2)}\n`;
44
+ if (nextContents !== prevContents) writeFileSync(file, nextContents);
45
+ }
46
+ export { getLockedDependencies, getLockedDependency, readLockFile, writeLockFile };
@@ -0,0 +1,32 @@
1
+ declare const DEPENDENCY_TYPES: readonly ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
2
+ type DependencyProtocol = '*' | 'workspace:*';
3
+ declare function checkIsDependencyProtocol(entry: unknown): entry is DependencyProtocol;
4
+ declare function checkIsPackageVersion(version: unknown): version is string;
5
+ declare function readPackageJson(manifestPath: string): {
6
+ manifestPath: string;
7
+ name: string | undefined;
8
+ packageJson: Record<string, unknown>;
9
+ version: string | undefined;
10
+ };
11
+ declare function findPackageManifest(manifests: Array<ReturnType<typeof readPackageJson>>, name: string): {
12
+ manifestPath: string;
13
+ name: string | undefined;
14
+ packageJson: Record<string, unknown>;
15
+ version: string | undefined;
16
+ };
17
+ declare function listPackageManifests(root: string): Promise<{
18
+ manifestPath: string;
19
+ name: string | undefined;
20
+ packageJson: Record<string, unknown>;
21
+ version: string | undefined;
22
+ }[]>;
23
+ declare function resolvePackage(name?: string): Promise<{
24
+ manifest: {
25
+ manifestPath: string;
26
+ name: string | undefined;
27
+ packageJson: Record<string, unknown>;
28
+ version: string | undefined;
29
+ };
30
+ root: string;
31
+ }>;
32
+ export { checkIsDependencyProtocol, checkIsPackageVersion, DEPENDENCY_TYPES, findPackageManifest, listPackageManifests, readPackageJson, resolvePackage, };
@@ -0,0 +1,72 @@
1
+ import { lstatSync, readFileSync, realpathSync } from "node:fs";
2
+ import node_path from "node:path";
3
+ import { valid } from "semver";
4
+ import { getRepoRootPath, listGitFiles } from "./git.js";
5
+ import { parseJsonObject } from "./json.js";
6
+ const DEPENDENCY_TYPES = [
7
+ 'dependencies',
8
+ 'devDependencies',
9
+ 'optionalDependencies',
10
+ 'peerDependencies'
11
+ ];
12
+ function checkIsDependencyProtocol(entry) {
13
+ return '*' === entry || 'workspace:*' === entry;
14
+ }
15
+ function checkIsPackageVersion(version) {
16
+ return 'string' == typeof version && Boolean(valid(version));
17
+ }
18
+ function readPackageJson(manifestPath) {
19
+ const contents = readFileSync(manifestPath, 'utf8');
20
+ const packageJson = parseJsonObject(contents, manifestPath);
21
+ const { name, version } = packageJson;
22
+ return {
23
+ manifestPath,
24
+ name: 'string' == typeof name ? name : void 0,
25
+ packageJson,
26
+ version: 'string' == typeof version ? version : void 0
27
+ };
28
+ }
29
+ function findPackageManifest(manifests, name) {
30
+ const matches = manifests.filter((manifest)=>manifest.name === name);
31
+ const [manifest] = matches;
32
+ if (!manifest) throw new Error(`Package not found: ${name}.`);
33
+ if (matches.length > 1) throw new Error(`Multiple packages named ${name}.`);
34
+ return manifest;
35
+ }
36
+ async function listPackageManifests(root) {
37
+ const files = await listGitFiles(root, ':(glob)**/package.json', ':(exclude,glob)**/node_modules/**');
38
+ const realRoot = realpathSync(root);
39
+ return files.flatMap((file)=>{
40
+ const manifestPath = node_path.join(root, file);
41
+ if (!lstatSync(manifestPath, {
42
+ throwIfNoEntry: false
43
+ })?.isFile()) return [];
44
+ if (node_path.relative(node_path.join(realRoot, file), realpathSync(manifestPath))) return [];
45
+ return [
46
+ readPackageJson(manifestPath)
47
+ ];
48
+ });
49
+ }
50
+ async function resolvePackage(name) {
51
+ const packageDir = process.cwd();
52
+ const root = getRepoRootPath(packageDir);
53
+ if (void 0 !== name) {
54
+ const manifests = await listPackageManifests(root);
55
+ const manifest = findPackageManifest(manifests, name);
56
+ return {
57
+ manifest,
58
+ root
59
+ };
60
+ }
61
+ const manifestPath = node_path.join(packageDir, 'package.json');
62
+ if (!lstatSync(manifestPath, {
63
+ throwIfNoEntry: false
64
+ })?.isFile()) throw new Error(`Run MVM from a directory with a package.json: ${packageDir}.`);
65
+ const manifest = readPackageJson(manifestPath);
66
+ if (!manifest.name) throw new Error(`Missing package name in ${manifest.manifestPath}.`);
67
+ return {
68
+ manifest,
69
+ root
70
+ };
71
+ }
72
+ export { DEPENDENCY_TYPES, checkIsDependencyProtocol, checkIsPackageVersion, findPackageManifest, listPackageManifests, readPackageJson, resolvePackage };
package/dist/pin.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { PinRange } from './config.js';
2
+ interface PinConfig {
3
+ name?: string | undefined;
4
+ range?: PinRange | undefined;
5
+ }
6
+ declare function pin({ name, range }?: PinConfig): Promise<boolean | undefined>;
7
+ declare function unpin(name?: string): Promise<boolean | undefined>;
8
+ export { pin, unpin };
package/dist/pin.js ADDED
@@ -0,0 +1,66 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import node_path from "node:path";
3
+ import { checkIsPinRange, loadPackageConfig } from "./config.js";
4
+ import { checkIsJsonObject, parseJsonObject } from "./json.js";
5
+ import { getLockedDependencies, getLockedDependency, readLockFile } from "./lock-file.js";
6
+ import { DEPENDENCY_TYPES, checkIsDependencyProtocol, checkIsPackageVersion, resolvePackage } from "./package-json.js";
7
+ function formatPackageJson(packageJson, contents) {
8
+ const indent = /^[ \t]+(?=")/mu.exec(contents)?.[0] ?? (contents.includes('\n') ? 2 : void 0);
9
+ const bom = contents.startsWith('\uFEFF') ? '\uFEFF' : '';
10
+ const trailingNewline = contents.endsWith('\n') ? '\n' : '';
11
+ const formatted = `${bom}${JSON.stringify(packageJson, void 0, indent)}${trailingNewline}`;
12
+ return contents.includes('\r\n') ? formatted.replaceAll('\n', '\r\n') : formatted;
13
+ }
14
+ async function readPackageLock(name) {
15
+ const { manifest, root } = await resolvePackage(name);
16
+ const packageDir = node_path.dirname(manifest.manifestPath);
17
+ const lockFilePath = node_path.join(packageDir, 'mvm.lock');
18
+ const { hasLockFile, lockFile } = readLockFile(lockFilePath);
19
+ return {
20
+ hasLockFile,
21
+ lockFile,
22
+ lockFilePath,
23
+ packageDir,
24
+ root
25
+ };
26
+ }
27
+ function rewriteDependencySpecifiers(packageDir, lockFile, lockFilePath, mapSpecifier) {
28
+ const manifestPath = node_path.join(packageDir, 'package.json');
29
+ const manifestContents = readFileSync(manifestPath, 'utf8');
30
+ const packageJson = parseJsonObject(manifestContents, manifestPath);
31
+ let hasChanges = false;
32
+ for (const type of DEPENDENCY_TYPES){
33
+ const entries = getLockedDependencies(lockFile, type, lockFilePath);
34
+ const dependencies = packageJson[type];
35
+ if (entries && checkIsJsonObject(dependencies)) for (const [name, entry] of Object.entries(entries)){
36
+ const prev = dependencies[name];
37
+ const next = 'string' == typeof prev ? mapSpecifier(prev, entry, name) : prev;
38
+ if (prev !== next) {
39
+ dependencies[name] = next;
40
+ hasChanges = true;
41
+ }
42
+ }
43
+ }
44
+ if (hasChanges) writeFileSync(manifestPath, formatPackageJson(packageJson, manifestContents));
45
+ return hasChanges;
46
+ }
47
+ async function pin({ name, range } = {}) {
48
+ const { hasLockFile, lockFile, lockFilePath, packageDir, root } = await readPackageLock(name);
49
+ if (!lockFile) return hasLockFile ? false : void 0;
50
+ const config = void 0 === range ? await loadPackageConfig(packageDir, root) : void 0;
51
+ const configuredRange = range ?? config?.['pinRange'];
52
+ const pinRange = void 0 === configuredRange ? 'exact' : configuredRange;
53
+ if (!checkIsPinRange(pinRange)) throw new Error('Pin range must be exact, ^, or ~.');
54
+ return rewriteDependencySpecifiers(packageDir, lockFile, lockFilePath, (specifier, entry, dependencyName)=>{
55
+ if (!checkIsDependencyProtocol(specifier)) return specifier;
56
+ const { version } = getLockedDependency(entry, dependencyName, lockFilePath);
57
+ if (!checkIsPackageVersion(version)) throw new Error(`Invalid version for ${dependencyName} in ${lockFilePath}.`);
58
+ return 'exact' === pinRange ? version : `${pinRange}${version}`;
59
+ });
60
+ }
61
+ async function unpin(name) {
62
+ const { hasLockFile, lockFile, lockFilePath, packageDir } = await readPackageLock(name);
63
+ if (!lockFile) return hasLockFile ? false : void 0;
64
+ return rewriteDependencySpecifiers(packageDir, lockFile, lockFilePath, (_, entry, dependencyName)=>getLockedDependency(entry, dependencyName, lockFilePath).protocol);
65
+ }
66
+ export { pin, unpin };
@@ -0,0 +1,2 @@
1
+ declare function propagate(name?: string, version?: string): Promise<void>;
2
+ export { propagate };
@@ -0,0 +1,46 @@
1
+ import node_path from "node:path";
2
+ import { getRepoRootPath } from "./git.js";
3
+ import { checkIsJsonObject } from "./json.js";
4
+ import { getLockedDependencies, readLockFile, writeLockFile } from "./lock-file.js";
5
+ import { DEPENDENCY_TYPES, checkIsDependencyProtocol, checkIsPackageVersion, findPackageManifest, listPackageManifests, readPackageJson } from "./package-json.js";
6
+ async function propagate(name, version) {
7
+ const packageDir = process.cwd();
8
+ const manifests = await listPackageManifests(getRepoRootPath(packageDir));
9
+ const selectedManifest = void 0 === name ? readPackageJson(node_path.join(packageDir, 'package.json')) : findPackageManifest(manifests, name);
10
+ const packageName = selectedManifest.name;
11
+ const releaseVersion = version ?? selectedManifest.version;
12
+ if (!packageName) throw new Error('Package name is missing from package.json.');
13
+ if (!checkIsPackageVersion(releaseVersion)) throw new Error(`Expected an exact semantic version for ${packageName}.`);
14
+ const updates = manifests.flatMap((manifest)=>{
15
+ if (manifest.manifestPath === selectedManifest.manifestPath) return [];
16
+ const specifiers = DEPENDENCY_TYPES.map((type)=>{
17
+ const dependencies = manifest.packageJson[type];
18
+ return {
19
+ specifier: checkIsJsonObject(dependencies) ? dependencies[packageName] : void 0,
20
+ type
21
+ };
22
+ });
23
+ if (!specifiers.some(({ specifier })=>checkIsDependencyProtocol(specifier))) return [];
24
+ const lockFilePath = node_path.join(node_path.dirname(manifest.manifestPath), 'mvm.lock');
25
+ const { contents, lockFile = {} } = readLockFile(lockFilePath);
26
+ for (const { specifier, type } of specifiers){
27
+ const group = getLockedDependencies(lockFile, type, lockFilePath);
28
+ if (checkIsDependencyProtocol(specifier)) lockFile[type] = {
29
+ ...group,
30
+ [packageName]: {
31
+ protocol: specifier,
32
+ version: releaseVersion
33
+ }
34
+ };
35
+ }
36
+ return [
37
+ {
38
+ contents,
39
+ lockFile,
40
+ lockFilePath
41
+ }
42
+ ];
43
+ });
44
+ for (const { contents, lockFile, lockFilePath } of updates)writeLockFile(lockFilePath, contents, lockFile);
45
+ }
46
+ export { propagate };
package/package.json CHANGED
@@ -1,87 +1,87 @@
1
1
  {
2
2
  "name": "@b12k/mvm",
3
- "version": "0.0.11",
3
+ "version": "1.0.0",
4
4
  "description": "Monorepo versions manager",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "bin": {
9
- "mvm-lock": "dist/cli-lock.js",
10
- "mvm-skip": "dist/cli-skip.js",
11
- "mvm-update": "dist/cli-update.js"
12
- },
13
- "main": "dist/mvm.js",
14
- "types": "dist/mvm.d.ts",
15
- "keywords": [],
16
- "author": "Bogdan Kolesnyk",
5
+ "keywords": [
6
+ "monorepo",
7
+ "release",
8
+ "workspaces"
9
+ ],
10
+ "homepage": "https://github.com/b12k/mvm",
11
+ "bugs": "https://github.com/b12k/mvm/issues",
17
12
  "license": "MIT",
13
+ "author": "Bogdan Kolesnyk",
18
14
  "repository": {
19
15
  "type": "git",
20
- "url": "git://github.com/b12k/mvm.git"
16
+ "url": "git+https://github.com/b12k/mvm.git"
21
17
  },
22
- "homepage": "https://github.com/b12k/mvm",
23
- "bugs": {
24
- "url": "https://github.com/b12k/mvm/issues"
18
+ "bin": {
19
+ "mvm": "./dist/cli.js"
25
20
  },
26
- "scripts": {
27
- "dev": "pnpm clean && run-p _dev:*",
28
- "_dev:types": "pnpm _build:types && chokidar \"./dist/**/*.js\" -c \"pnpm _build:types\"",
29
- "_dev:scripts": "pnpm _build:scripts --watch",
30
- "lint": "run-p _lint:*",
31
- "_lint:types": "tsc --noEmit",
32
- "_lint:scripts": "eslint ./src/**/*.ts",
33
- "_lint:codestyle": "pnpm prettier . --check",
34
- "build": "pnpm clean && run-p _build:*",
35
- "_build:types": "tsc --emitDeclarationOnly",
36
- "_build:scripts": "swc ./src -d ./dist",
37
- "clean": "shx rm -rf ./dist",
38
- "prepare": "husky install",
39
- "release": "release-it --ci",
40
- "husky:pre-commit": "run-p _husky:pre-commit:*",
41
- "_husky:pre-commit:typecheck": "pnpm _lint:types",
42
- "_husky:pre-commit:lintstaged": "lint-staged"
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.js"
30
+ }
43
31
  },
44
- "devDependencies": {
45
- "@commitlint/cli": "17.4.4",
46
- "@commitlint/config-conventional": "17.4.4",
47
- "@release-it/conventional-changelog": "5.1.1",
48
- "@swc/cli": "0.1.62",
49
- "@swc/core": "1.3.36",
50
- "@swc/helpers": "0.4.14",
51
- "@types/fs-extra": "11.0.1",
52
- "@types/glob": "8.0.1",
53
- "@types/node": "18.14.0",
54
- "@types/semver": "7.3.13",
55
- "@typescript-eslint/eslint-plugin": "5.53.0",
56
- "@typescript-eslint/parser": "5.53.0",
57
- "chokidar": "3.5.3",
58
- "chokidar-cli": "3.0.0",
59
- "eslint": "8.34.0",
60
- "eslint-config-airbnb-base": "15.0.0",
61
- "eslint-config-airbnb-typescript": "17.0.0",
62
- "eslint-config-prettier": "8.6.0",
63
- "eslint-import-resolver-typescript": "3.5.3",
64
- "eslint-plugin-eslint-comments": "3.2.0",
65
- "eslint-plugin-import": "2.27.5",
66
- "eslint-plugin-prettier": "4.2.1",
67
- "eslint-plugin-promise": "6.1.1",
68
- "eslint-plugin-simple-import-sort": "10.0.0",
69
- "eslint-plugin-unicorn": "45.0.2",
70
- "eslint-plugin-unused-imports": "2.0.0",
71
- "husky": "8.0.3",
72
- "lint-staged": "13.1.2",
73
- "npm-run-all": "4.1.5",
74
- "prettier": "2.8.4",
75
- "release-it": "15.6.0",
76
- "shx": "0.3.4",
77
- "typescript": "4.9.5"
32
+ "publishConfig": {
33
+ "access": "public"
78
34
  },
79
35
  "dependencies": {
80
- "clean-semver": "2.1.0",
81
- "commander": "10.0.0",
82
- "fs-extra": "11.1.0",
83
- "glob": "8.1.0",
84
- "semver": "7.3.8"
36
+ "commander": "15.1.0",
37
+ "cosmiconfig": "10.0.1",
38
+ "semver": "7.8.6",
39
+ "tinyglobby": "0.2.17"
85
40
  },
86
- "packageManager": "pnpm@10.8.0"
87
- }
41
+ "devDependencies": {
42
+ "@b12k/branch-name-lint": "1.3.0",
43
+ "@commitlint/config-conventional": "21.2.4",
44
+ "@release-it/conventional-changelog": "12.0.2",
45
+ "@rslib/core": "1.0.7",
46
+ "@rstest/core": "0.12.6",
47
+ "@types/node": "26.6.10",
48
+ "@types/semver": "7.8.0",
49
+ "commitlint": "21.2.4",
50
+ "eslint-plugin-perfectionist": "5.14.0",
51
+ "husky": "9.1.7",
52
+ "lint-staged": "17.6.2",
53
+ "npm-check-updates": "23.1.1",
54
+ "npm-run-all2": "9.1.0",
55
+ "oxfmt": "0.80.0",
56
+ "oxlint": "1.95.0",
57
+ "oxlint-tsgolint": "7.0.2008",
58
+ "release-it": "21.1.3",
59
+ "tsx": "4.23.15",
60
+ "typescript": "7.0.2"
61
+ },
62
+ "engines": {
63
+ "node": ">=24"
64
+ },
65
+ "scripts": {
66
+ "build": "rslib",
67
+ "check": "run-p -l check:*",
68
+ "check:format": "oxfmt . --check",
69
+ "check:scripts": "oxlint",
70
+ "check:types": "tsc --noEmit",
71
+ "check:tests": "rstest run",
72
+ "deps:check": "ncu -e 2 -c 1",
73
+ "deps:update": "ncu -du --dep prod,dev,optional --doctorInstall \"pnpm deps:update:install\" --doctorTest \"pnpm deps:update:doctor\" -c 1",
74
+ "deps:update:doctor": "run-p -l check:types check:scripts check:tests build",
75
+ "deps:update:install": "pnpm i --no-frozen-lockfile",
76
+ "dev": "rslib --watch",
77
+ "fix": "run-s -l fix:*",
78
+ "fix:format": "oxfmt . --write",
79
+ "fix:scripts": "oxlint --fix",
80
+ "ga:notify": "tsx .github/notify.ts",
81
+ "husky:commit-msg": "commitlint",
82
+ "husky:pre-commit": "lint-staged",
83
+ "husky:pre-push": "branch-name-lint",
84
+ "release": "release-it",
85
+ "test": "rstest run"
86
+ }
87
+ }
package/dist/cli-lock.js DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- (function(global, factory) {
3
- if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("./lock"));
4
- else if (typeof define === "function" && define.amd) define([
5
- "exports",
6
- "./lock"
7
- ], factory);
8
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.cliLock = {}, global.lock);
9
- })(this, function(exports, _lock) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- (0, _lock.lock)();
15
- });
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/cli-skip.js DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
- (function(global, factory) {
3
- if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("node:process"), require("node:path"), require("commander"), require("./skip"), require("./utils"));
4
- else if (typeof define === "function" && define.amd) define([
5
- "exports",
6
- "node:process",
7
- "node:path",
8
- "commander",
9
- "./skip",
10
- "./utils"
11
- ], factory);
12
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.cliSkip = {}, global.nodeProcess, global.nodePath, global.commander, global.skip, global.utils);
13
- })(this, function(exports, _nodeProcess, _nodePath, _commander, _skip, _utils) {
14
- "use strict";
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
18
- const args = _commander.program.option('-n, --name <name>', 'dependency / package name (like in package.json)').option('-w, --workspace <path>', 'absolute path to the monorepo root directory').option('-r, --root <path>', 'absolute path to the monorepo workspace directory').option('-s, --silent', 'mute output to console').option('-v, --verbose', 'enable debug output').helpOption('-h, --help', 'display this help').parse().opts();
19
- const config = {
20
- name: args.name || (0, _utils.readLocalPackageJson)().name,
21
- root: args.root && (0, _nodePath.resolve)(args.root) || (0, _utils.getRepoRootPath)(),
22
- workspace: (0, _nodePath.resolve)(args.workspace || (0, _nodeProcess.cwd)()),
23
- log: args.verbose ? _utils.logJson : undefined
24
- };
25
- const isSilent = args.silent || args.verbose;
26
- if ((0, _skip.skip)(config)) {
27
- // eslint-disable-next-line no-console
28
- if (!isSilent) console.log('[mvm-skip] skip');
29
- (0, _nodeProcess.exit)();
30
- } else {
31
- // eslint-disable-next-line no-console
32
- if (!isSilent) console.log('[mvm-skip] continue');
33
- (0, _nodeProcess.exit)(1);
34
- }
35
- });
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
- (function(global, factory) {
3
- if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("commander"), require("node:path"), require("./utils"), require("./update"));
4
- else if (typeof define === "function" && define.amd) define([
5
- "exports",
6
- "commander",
7
- "node:path",
8
- "./utils",
9
- "./update"
10
- ], factory);
11
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.cliUpdate = {}, global.commander, global.nodePath, global.utils, global.update);
12
- })(this, function(exports, _commander, _nodePath, _utils, _update) {
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- const args = _commander.program.option('-n, --name <name>', 'dependency / package name (like in package.json)').option('-v, --version <version>', 'dependency / package version (like in package.json)').option('-r, --root <path>', 'absolute path to the monorepo root directory').option('-v, --verbose', 'enable debug output').helpOption('-h, --help', 'display this help').parse().opts();
18
- const config = {
19
- name: args.name || (0, _utils.readLocalPackageJson)().name,
20
- root: args.root && (0, _nodePath.resolve)(args.root) || (0, _utils.getRepoRootPath)(),
21
- version: args.version || (0, _utils.readLocalPackageJson)().version,
22
- log: args.verbose ? _utils.logJson : undefined
23
- };
24
- (0, _update.update)(config);
25
- });
package/dist/lock.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const lock: () => void;
package/dist/lock.js DELETED
@@ -1,19 +0,0 @@
1
- (function(global, factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") factory(exports);
3
- else if (typeof define === "function" && define.amd) define([
4
- "exports"
5
- ], factory);
6
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.lock = {});
7
- })(this, function(exports) {
8
- "use strict";
9
- Object.defineProperty(exports, "__esModule", {
10
- value: true
11
- });
12
- Object.defineProperty(exports, "lock", {
13
- enumerable: true,
14
- get: ()=>lock
15
- });
16
- const lock = ()=>{
17
- // To be implemented
18
- };
19
- });
package/dist/skip.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Logger } from './utils';
2
- export interface SkipConfig {
3
- log?: Logger;
4
- name: string;
5
- root: string;
6
- workspace: string;
7
- }
8
- export declare const skip: (config: SkipConfig) => boolean;
package/dist/skip.js DELETED
@@ -1,72 +0,0 @@
1
- (function(global, factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("node:child_process"), require("./utils"));
3
- else if (typeof define === "function" && define.amd) define([
4
- "exports",
5
- "node:child_process",
6
- "./utils"
7
- ], factory);
8
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.skip = {}, global.nodeChildProcess, global.utils);
9
- })(this, function(exports, _nodeChildProcess, _utils) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- Object.defineProperty(exports, "skip", {
15
- enumerable: true,
16
- get: ()=>skip
17
- });
18
- const skip = (config)=>{
19
- const { name , workspace , root , log =_utils.doNothing } = config;
20
- log({
21
- config
22
- });
23
- const relatedTags = (0, _nodeChildProcess.execSync)('git tag').toString().split('\n').filter((tag)=>tag.match(new RegExp(`${name}-v\\d+.\\d+.\\d+$`)));
24
- if (relatedTags.length === 0) {
25
- log({
26
- message: 'no related tags found',
27
- skip: false
28
- });
29
- return false;
30
- }
31
- const latestVersion = (0, _utils.toSemver)(relatedTags.map((tag)=>tag.replace(name, '')))[0];
32
- if (!latestVersion) {
33
- log({
34
- message: 'no latest version found',
35
- skip: false
36
- });
37
- return false;
38
- }
39
- log({
40
- latestVersion
41
- });
42
- const latestTag = relatedTags.find((tag)=>tag.includes(latestVersion));
43
- if (!latestTag) {
44
- log({
45
- message: 'no latest tag found',
46
- skip: false
47
- });
48
- return false;
49
- }
50
- log({
51
- latestTag
52
- });
53
- const workspaceName = workspace.toLowerCase().replace(root.toLowerCase(), '').replaceAll('\\', '/').slice(1);
54
- log({
55
- workspaceName
56
- });
57
- const touchedFiles = (0, _nodeChildProcess.execSync)(`git diff --name-only ${latestTag}..HEAD`).toString().split('\n').filter((file)=>Boolean(file) && file.includes(`${workspaceName}/`));
58
- if (touchedFiles.length > 0) {
59
- log({
60
- message: 'files touched since last release',
61
- touchedFiles,
62
- skip: false
63
- });
64
- return false;
65
- }
66
- log({
67
- message: 'no files touched since last release',
68
- skip: true
69
- });
70
- return true;
71
- };
72
- });
package/dist/update.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Logger } from './utils';
2
- export interface UpdateConfig {
3
- root: string;
4
- name: string;
5
- version: string;
6
- log?: Logger;
7
- }
8
- export declare const update: (config: UpdateConfig) => void;