rman 0.12.1 → 0.15.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.
- package/cjs/cli.js +2 -0
- package/cjs/commands/build-command.js +32 -0
- package/cjs/commands/publish-command.js +4 -3
- package/cjs/commands/run-command.js +1 -1
- package/cjs/utils/file-utils.js +2 -1
- package/cjs/utils/npm-utils.js +34 -0
- package/esm/cli.mjs +2 -0
- package/esm/commands/build-command.d.ts +11 -0
- package/esm/commands/build-command.mjs +28 -0
- package/esm/commands/publish-command.mjs +4 -3
- package/esm/commands/run-command.mjs +1 -1
- package/esm/utils/file-utils.d.ts +2 -0
- package/esm/utils/file-utils.mjs +1 -0
- package/esm/utils/npm-utils.d.ts +12 -0
- package/esm/utils/npm-utils.mjs +29 -0
- package/package.json +3 -2
package/cjs/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ const run_command_1 = require("./commands/run-command");
|
|
|
19
19
|
const version_command_1 = require("./commands/version-command");
|
|
20
20
|
const publish_command_1 = require("./commands/publish-command");
|
|
21
21
|
const ci_command_1 = require("./commands/ci-command");
|
|
22
|
+
const build_command_1 = require("./commands/build-command");
|
|
22
23
|
async function runCli(options) {
|
|
23
24
|
const s = path_1.default.resolve((0, utils_1.getDirname)(), '../package.json');
|
|
24
25
|
const pkgJson = JSON.parse(await promises_1.default.readFile(s, 'utf-8'));
|
|
@@ -50,6 +51,7 @@ async function runCli(options) {
|
|
|
50
51
|
version_command_1.VersionCommand.initCli(repository, program);
|
|
51
52
|
publish_command_1.PublishCommand.initCli(repository, program);
|
|
52
53
|
ci_command_1.CleanInstallCommand.initCli(repository, program);
|
|
54
|
+
build_command_1.BuildCommand.initCli(repository, program);
|
|
53
55
|
if (!_argv.length)
|
|
54
56
|
program.showHelp();
|
|
55
57
|
else
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildCommand = void 0;
|
|
4
|
+
const command_1 = require("../core/command");
|
|
5
|
+
const run_command_1 = require("./run-command");
|
|
6
|
+
class BuildCommand extends run_command_1.RunCommand {
|
|
7
|
+
constructor(repository, options) {
|
|
8
|
+
super(repository, 'build', options);
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.BuildCommand = BuildCommand;
|
|
13
|
+
BuildCommand.commandName = 'changed';
|
|
14
|
+
(function (BuildCommand) {
|
|
15
|
+
function initCli(repository, program) {
|
|
16
|
+
program.command({
|
|
17
|
+
command: 'build [options...]',
|
|
18
|
+
describe: 'Alias for "run build"',
|
|
19
|
+
builder: (cmd) => {
|
|
20
|
+
return cmd
|
|
21
|
+
.example("$0 build", "# Builds packages")
|
|
22
|
+
.option(BuildCommand.cliCommandOptions);
|
|
23
|
+
},
|
|
24
|
+
handler: async (args) => {
|
|
25
|
+
const options = command_1.Command.composeOptions(BuildCommand.commandName, args, repository.config);
|
|
26
|
+
await new BuildCommand(repository, options)
|
|
27
|
+
.execute();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
BuildCommand.initCli = initCli;
|
|
32
|
+
})(BuildCommand = exports.BuildCommand || (exports.BuildCommand = {}));
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PublishCommand = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const package_json_1 = __importDefault(require("package-json"));
|
|
9
8
|
const npmlog_1 = __importDefault(require("npmlog"));
|
|
10
9
|
const command_1 = require("../core/command");
|
|
11
10
|
const run_command_1 = require("./run-command");
|
|
12
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const npm_utils_1 = require("../utils/npm-utils");
|
|
13
13
|
class PublishCommand extends run_command_1.RunCommand {
|
|
14
14
|
constructor(repository, options) {
|
|
15
15
|
super(repository, 'publish', options);
|
|
@@ -26,8 +26,9 @@ class PublishCommand extends run_command_1.RunCommand {
|
|
|
26
26
|
}
|
|
27
27
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const npmHelper = new npm_utils_1.NpmHelper({ cwd: p.dirname });
|
|
30
|
+
const r = await npmHelper.getPackageInfo(p.json.name);
|
|
31
|
+
if (r && r.version === p.version) {
|
|
31
32
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Same version (${p.version}) in repository`);
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
@@ -114,7 +114,7 @@ RunCommand.commandName = 'run';
|
|
|
114
114
|
function initCli(repository, program) {
|
|
115
115
|
program.command({
|
|
116
116
|
command: 'run <script>',
|
|
117
|
-
describe: 'Execute an arbitrary
|
|
117
|
+
describe: 'Execute an arbitrary script in each package',
|
|
118
118
|
builder: (cmd) => {
|
|
119
119
|
return cmd
|
|
120
120
|
.example("$0 run build", '')
|
package/cjs/utils/file-utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fsDelete = exports.tryStat = exports.fsExists = void 0;
|
|
6
|
+
exports.fsDelete = exports.fsReadFile = exports.tryStat = exports.fsExists = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
async function fsExists(s) {
|
|
@@ -14,6 +14,7 @@ async function tryStat(s) {
|
|
|
14
14
|
return promises_1.default.lstat(s).catch(() => undefined);
|
|
15
15
|
}
|
|
16
16
|
exports.tryStat = tryStat;
|
|
17
|
+
exports.fsReadFile = promises_1.default.readFile;
|
|
17
18
|
async function fsDelete(fileOrDir) {
|
|
18
19
|
const stat = await tryStat(fileOrDir);
|
|
19
20
|
if (stat) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NpmHelper = exports.PackageNotFoundError = void 0;
|
|
4
|
+
const exec_1 = require("./exec");
|
|
5
|
+
class PackageNotFoundError extends Error {
|
|
6
|
+
}
|
|
7
|
+
exports.PackageNotFoundError = PackageNotFoundError;
|
|
8
|
+
class NpmHelper {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.cwd = options?.cwd || process.cwd();
|
|
11
|
+
}
|
|
12
|
+
async getPackageInfo(packageName) {
|
|
13
|
+
const x = await (0, exec_1.exec)('npm', {
|
|
14
|
+
cwd: this.cwd,
|
|
15
|
+
argv: ['view', packageName, '--json']
|
|
16
|
+
});
|
|
17
|
+
if (x.stdout) {
|
|
18
|
+
if (x.stdout.includes('404'))
|
|
19
|
+
return new PackageNotFoundError('Package ' + packageName + ' not found in repository');
|
|
20
|
+
const b = x.stdout.indexOf('{');
|
|
21
|
+
const e = x.stdout.lastIndexOf('}');
|
|
22
|
+
const s = x.stdout.substring(b, e + 1);
|
|
23
|
+
try {
|
|
24
|
+
if (s)
|
|
25
|
+
return JSON.parse(s);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
//
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Unable to fetch version info');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.NpmHelper = NpmHelper;
|
package/esm/cli.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { RunCommand } from './commands/run-command.mjs';
|
|
|
13
13
|
import { VersionCommand } from './commands/version-command.mjs';
|
|
14
14
|
import { PublishCommand } from './commands/publish-command.mjs';
|
|
15
15
|
import { CleanInstallCommand } from './commands/ci-command.mjs';
|
|
16
|
+
import { BuildCommand } from './commands/build-command.mjs';
|
|
16
17
|
export async function runCli(options) {
|
|
17
18
|
const s = path.resolve(getDirname(), '../package.json');
|
|
18
19
|
const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
|
|
@@ -44,6 +45,7 @@ export async function runCli(options) {
|
|
|
44
45
|
VersionCommand.initCli(repository, program);
|
|
45
46
|
PublishCommand.initCli(repository, program);
|
|
46
47
|
CleanInstallCommand.initCli(repository, program);
|
|
48
|
+
BuildCommand.initCli(repository, program);
|
|
47
49
|
if (!_argv.length)
|
|
48
50
|
program.showHelp();
|
|
49
51
|
else
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { Repository } from '../core/repository';
|
|
3
|
+
import { RunCommand } from './run-command';
|
|
4
|
+
export declare class BuildCommand extends RunCommand<any> {
|
|
5
|
+
readonly repository: Repository;
|
|
6
|
+
static commandName: string;
|
|
7
|
+
constructor(repository: Repository, options?: RunCommand.Options);
|
|
8
|
+
}
|
|
9
|
+
export declare namespace BuildCommand {
|
|
10
|
+
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from './../core/command.mjs';
|
|
2
|
+
import { RunCommand } from './run-command.mjs';
|
|
3
|
+
export class BuildCommand extends RunCommand {
|
|
4
|
+
constructor(repository, options) {
|
|
5
|
+
super(repository, 'build', options);
|
|
6
|
+
this.repository = repository;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
BuildCommand.commandName = 'changed';
|
|
10
|
+
(function (BuildCommand) {
|
|
11
|
+
function initCli(repository, program) {
|
|
12
|
+
program.command({
|
|
13
|
+
command: 'build [options...]',
|
|
14
|
+
describe: 'Alias for "run build"',
|
|
15
|
+
builder: (cmd) => {
|
|
16
|
+
return cmd
|
|
17
|
+
.example("$0 build", "# Builds packages")
|
|
18
|
+
.option(BuildCommand.cliCommandOptions);
|
|
19
|
+
},
|
|
20
|
+
handler: async (args) => {
|
|
21
|
+
const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
|
|
22
|
+
await new BuildCommand(repository, options)
|
|
23
|
+
.execute();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
BuildCommand.initCli = initCli;
|
|
28
|
+
})(BuildCommand || (BuildCommand = {}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import fetchPackageInfo from 'package-json';
|
|
3
2
|
import logger from 'npmlog';
|
|
4
3
|
import { Command } from './../core/command.mjs';
|
|
5
4
|
import { RunCommand } from './run-command.mjs';
|
|
6
5
|
import path from 'path';
|
|
6
|
+
import { NpmHelper } from './../utils/npm-utils.mjs';
|
|
7
7
|
export class PublishCommand extends RunCommand {
|
|
8
8
|
constructor(repository, options) {
|
|
9
9
|
super(repository, 'publish', options);
|
|
@@ -20,8 +20,9 @@ export class PublishCommand extends RunCommand {
|
|
|
20
20
|
}
|
|
21
21
|
logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
24
|
+
const r = await npmHelper.getPackageInfo(p.json.name);
|
|
25
|
+
if (r && r.version === p.version) {
|
|
25
26
|
logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Same version (${p.version}) in repository`);
|
|
26
27
|
continue;
|
|
27
28
|
}
|
|
@@ -107,7 +107,7 @@ RunCommand.commandName = 'run';
|
|
|
107
107
|
function initCli(repository, program) {
|
|
108
108
|
program.command({
|
|
109
109
|
command: 'run <script>',
|
|
110
|
-
describe: 'Execute an arbitrary
|
|
110
|
+
describe: 'Execute an arbitrary script in each package',
|
|
111
111
|
builder: (cmd) => {
|
|
112
112
|
return cmd
|
|
113
113
|
.example("$0 run build", '')
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import fsa from 'fs/promises';
|
|
2
3
|
import { Stats } from 'node:fs';
|
|
3
4
|
export declare function fsExists(s: string): Promise<boolean>;
|
|
4
5
|
export declare function tryStat(s: any): Promise<Stats | undefined>;
|
|
6
|
+
export declare const fsReadFile: typeof fsa.readFile;
|
|
5
7
|
export declare function fsDelete(fileOrDir: string): Promise<boolean>;
|
package/esm/utils/file-utils.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export async function fsExists(s) {
|
|
|
6
6
|
export async function tryStat(s) {
|
|
7
7
|
return fsa.lstat(s).catch(() => undefined);
|
|
8
8
|
}
|
|
9
|
+
export const fsReadFile = fsa.readFile;
|
|
9
10
|
export async function fsDelete(fileOrDir) {
|
|
10
11
|
const stat = await tryStat(fileOrDir);
|
|
11
12
|
if (stat) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class PackageNotFoundError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export declare namespace NpmHelper {
|
|
4
|
+
}
|
|
5
|
+
export interface NpmOptions {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class NpmHelper {
|
|
9
|
+
cwd: string;
|
|
10
|
+
constructor(options?: NpmOptions);
|
|
11
|
+
getPackageInfo(packageName: string): Promise<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { exec } from './exec.mjs';
|
|
2
|
+
export class PackageNotFoundError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export class NpmHelper {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.cwd = options?.cwd || process.cwd();
|
|
7
|
+
}
|
|
8
|
+
async getPackageInfo(packageName) {
|
|
9
|
+
const x = await exec('npm', {
|
|
10
|
+
cwd: this.cwd,
|
|
11
|
+
argv: ['view', packageName, '--json']
|
|
12
|
+
});
|
|
13
|
+
if (x.stdout) {
|
|
14
|
+
if (x.stdout.includes('404'))
|
|
15
|
+
return new PackageNotFoundError('Package ' + packageName + ' not found in repository');
|
|
16
|
+
const b = x.stdout.indexOf('{');
|
|
17
|
+
const e = x.stdout.lastIndexOf('}');
|
|
18
|
+
const s = x.stdout.substring(b, e + 1);
|
|
19
|
+
try {
|
|
20
|
+
if (s)
|
|
21
|
+
return JSON.parse(s);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
//
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw new Error('Unable to fetch version info');
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rman",
|
|
3
3
|
"description": "Monorepo repository manager",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"contributors": [
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"envinfo": "^7.8.1",
|
|
39
39
|
"fast-glob": "^3.2.11",
|
|
40
40
|
"figures": "^4.0.0",
|
|
41
|
+
"ini": "^2.0.0",
|
|
41
42
|
"is-ci": "^3.0.1",
|
|
42
43
|
"js-yaml": "^4.1.0",
|
|
43
44
|
"npmlog": "^6.0.1",
|
|
44
|
-
"package-json": "^7.0.0",
|
|
45
45
|
"path-key": "^4.0.0",
|
|
46
46
|
"power-tasks": "^0.6.0",
|
|
47
47
|
"putil-merge": "^3.8.0",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@babel/eslint-parser": "^7.17.0",
|
|
57
57
|
"@types/envinfo": "^7.8.1",
|
|
58
|
+
"@types/ini": "^1.3.31",
|
|
58
59
|
"@types/is-ci": "^3.0.0",
|
|
59
60
|
"@types/jest": "^27.4.1",
|
|
60
61
|
"@types/js-yaml": "^4.0.5",
|