rman 0.16.0 → 0.16.1
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 +43 -37
- package/cjs/commands/multi-task-command.js +1 -1
- package/cjs/core/command.js +3 -4
- package/cjs/{utils → core}/constants.js +0 -0
- package/cjs/core/repository.js +2 -2
- package/cjs/debug.js +1 -1
- package/cjs/{utils.js → utils/get-dirname.js} +0 -0
- package/esm/cli.mjs +43 -37
- package/esm/commands/multi-task-command.mjs +1 -1
- package/esm/core/command.mjs +3 -4
- package/esm/{utils → core}/constants.d.ts +0 -0
- package/esm/{utils → core}/constants.mjs +0 -0
- package/esm/core/repository.mjs +1 -1
- package/esm/debug.mjs +1 -1
- package/esm/{utils.d.ts → utils/get-dirname.d.ts} +0 -0
- package/esm/{utils.mjs → utils/get-dirname.mjs} +0 -0
- package/package.json +17 -17
- package/cjs/core/config.js +0 -73
- package/esm/core/config.d.ts +0 -9
- package/esm/core/config.mjs +0 -66
package/cjs/cli.js
CHANGED
|
@@ -8,7 +8,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const yargs_1 = __importDefault(require("yargs"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
11
|
+
const npmlog_1 = __importDefault(require("npmlog"));
|
|
12
|
+
const get_dirname_1 = require("./utils/get-dirname");
|
|
12
13
|
const repository_1 = require("./core/repository");
|
|
13
14
|
const info_command_1 = require("./commands/info-command");
|
|
14
15
|
const command_1 = require("./core/command");
|
|
@@ -21,41 +22,46 @@ const publish_command_1 = require("./commands/publish-command");
|
|
|
21
22
|
const ci_command_1 = require("./commands/ci-command");
|
|
22
23
|
const build_command_1 = require("./commands/build-command");
|
|
23
24
|
async function runCli(options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
25
|
+
try {
|
|
26
|
+
const s = path_1.default.resolve((0, get_dirname_1.getDirname)(), '../package.json');
|
|
27
|
+
const pkgJson = JSON.parse(await promises_1.default.readFile(s, 'utf-8'));
|
|
28
|
+
const repository = repository_1.Repository.create(options?.cwd);
|
|
29
|
+
const _argv = options?.argv || process.argv.slice(2);
|
|
30
|
+
const globalKeys = Object.keys(command_1.Command.globalOptions).concat(["help", "version"]);
|
|
31
|
+
const program = (0, yargs_1.default)(_argv)
|
|
32
|
+
// .scriptName('rman')
|
|
33
|
+
.strict()
|
|
34
|
+
.version(pkgJson.version || '').alias('version', 'v')
|
|
35
|
+
.usage('$0 <cmd> [options...]')
|
|
36
|
+
.help('help').alias('help', 'h')
|
|
37
|
+
.showHelpOnFail(false, 'Run with --help for available options')
|
|
38
|
+
.fail((msg, err) => {
|
|
39
|
+
const text = (msg
|
|
40
|
+
? msg + '\n\n' + chalk_1.default.whiteBright('Run with --help for available options')
|
|
41
|
+
: (err ? err.message : ''));
|
|
42
|
+
console.log('\n' + chalk_1.default.red(text));
|
|
43
|
+
throw msg;
|
|
44
|
+
})
|
|
45
|
+
// group options under "Global Options:" header
|
|
46
|
+
.options(command_1.Command.globalOptions)
|
|
47
|
+
.group(globalKeys, "Global Options:");
|
|
48
|
+
info_command_1.InfoCommand.initCli(repository, program);
|
|
49
|
+
list_command_1.ListCommand.initCli(repository, program);
|
|
50
|
+
changed_command_1.ChangedCommand.initCli(repository, program);
|
|
51
|
+
execute_command_1.ExecuteCommand.initCli(repository, program);
|
|
52
|
+
run_command_1.RunCommand.initCli(repository, program);
|
|
53
|
+
version_command_1.VersionCommand.initCli(repository, program);
|
|
54
|
+
publish_command_1.PublishCommand.initCli(repository, program);
|
|
55
|
+
ci_command_1.CleanInstallCommand.initCli(repository, program);
|
|
56
|
+
build_command_1.BuildCommand.initCli(repository, program);
|
|
57
|
+
if (!_argv.length)
|
|
58
|
+
program.showHelp();
|
|
59
|
+
else
|
|
60
|
+
await program.parseAsync()
|
|
61
|
+
.catch(() => false);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
npmlog_1.default.error('rman', e);
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
exports.runCli = runCli;
|
|
@@ -9,7 +9,7 @@ const npmlog_1 = __importDefault(require("npmlog"));
|
|
|
9
9
|
const power_tasks_1 = require("power-tasks");
|
|
10
10
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
11
11
|
const command_1 = require("../core/command");
|
|
12
|
-
const constants_1 = require("../
|
|
12
|
+
const constants_1 = require("../core/constants");
|
|
13
13
|
class MultiTaskCommand extends command_1.Command {
|
|
14
14
|
constructor(repository, options) {
|
|
15
15
|
super(options);
|
package/cjs/core/command.js
CHANGED
|
@@ -9,10 +9,9 @@ const npmlog_1 = __importDefault(require("npmlog"));
|
|
|
9
9
|
const is_ci_1 = __importDefault(require("is-ci"));
|
|
10
10
|
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
11
|
require("./logger");
|
|
12
|
-
const constants_1 = require("
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
14
|
const figures_1 = __importDefault(require("figures"));
|
|
15
|
-
const npmlog_2 = __importDefault(require("npmlog"));
|
|
16
15
|
const noOp = () => void (0);
|
|
17
16
|
class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
18
17
|
constructor(options) {
|
|
@@ -26,7 +25,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
26
25
|
this.logger.separator = chalk_1.default.gray(figures_1.default.lineVerticalDashed0);
|
|
27
26
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
28
27
|
get() {
|
|
29
|
-
return
|
|
28
|
+
return npmlog_1.default.levels[npmlog_1.default.level] || 0;
|
|
30
29
|
}
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -88,7 +87,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
88
87
|
//
|
|
89
88
|
}
|
|
90
89
|
async _preExecute() {
|
|
91
|
-
|
|
90
|
+
npmlog_1.default.info('rman', `Executing "${this.commandName}" command`);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
exports.Command = Command;
|
|
File without changes
|
package/cjs/core/repository.js
CHANGED
|
@@ -10,7 +10,7 @@ const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
|
10
10
|
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
11
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
12
|
const package_1 = require("./package");
|
|
13
|
-
const
|
|
13
|
+
const get_dirname_1 = require("../utils/get-dirname");
|
|
14
14
|
class Repository extends package_1.Package {
|
|
15
15
|
constructor(dirname, config, packages) {
|
|
16
16
|
super(dirname);
|
|
@@ -103,7 +103,7 @@ class Repository extends package_1.Package {
|
|
|
103
103
|
}
|
|
104
104
|
static _readConfig(dirname) {
|
|
105
105
|
const result = {};
|
|
106
|
-
const pkgJson = (0,
|
|
106
|
+
const pkgJson = (0, get_dirname_1.getPackageJson)(dirname);
|
|
107
107
|
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
108
108
|
(0, putil_merge_1.default)(result, pkgJson.rman, { deep: true });
|
|
109
109
|
let filename = path_1.default.resolve(dirname, '.rman.yml');
|
package/cjs/debug.js
CHANGED
|
File without changes
|
package/esm/cli.mjs
CHANGED
|
@@ -2,7 +2,8 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import yargs from "yargs";
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import
|
|
5
|
+
import logger from 'npmlog';
|
|
6
|
+
import { getDirname } from './utils/get-dirname.mjs';
|
|
6
7
|
import { Repository } from './core/repository.mjs';
|
|
7
8
|
import { InfoCommand } from './commands/info-command.mjs';
|
|
8
9
|
import { Command } from './core/command.mjs';
|
|
@@ -15,40 +16,45 @@ import { PublishCommand } from './commands/publish-command.mjs';
|
|
|
15
16
|
import { CleanInstallCommand } from './commands/ci-command.mjs';
|
|
16
17
|
import { BuildCommand } from './commands/build-command.mjs';
|
|
17
18
|
export async function runCli(options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
19
|
+
try {
|
|
20
|
+
const s = path.resolve(getDirname(), '../package.json');
|
|
21
|
+
const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
|
|
22
|
+
const repository = Repository.create(options?.cwd);
|
|
23
|
+
const _argv = options?.argv || process.argv.slice(2);
|
|
24
|
+
const globalKeys = Object.keys(Command.globalOptions).concat(["help", "version"]);
|
|
25
|
+
const program = yargs(_argv)
|
|
26
|
+
// .scriptName('rman')
|
|
27
|
+
.strict()
|
|
28
|
+
.version(pkgJson.version || '').alias('version', 'v')
|
|
29
|
+
.usage('$0 <cmd> [options...]')
|
|
30
|
+
.help('help').alias('help', 'h')
|
|
31
|
+
.showHelpOnFail(false, 'Run with --help for available options')
|
|
32
|
+
.fail((msg, err) => {
|
|
33
|
+
const text = (msg
|
|
34
|
+
? msg + '\n\n' + chalk.whiteBright('Run with --help for available options')
|
|
35
|
+
: (err ? err.message : ''));
|
|
36
|
+
console.log('\n' + chalk.red(text));
|
|
37
|
+
throw msg;
|
|
38
|
+
})
|
|
39
|
+
// group options under "Global Options:" header
|
|
40
|
+
.options(Command.globalOptions)
|
|
41
|
+
.group(globalKeys, "Global Options:");
|
|
42
|
+
InfoCommand.initCli(repository, program);
|
|
43
|
+
ListCommand.initCli(repository, program);
|
|
44
|
+
ChangedCommand.initCli(repository, program);
|
|
45
|
+
ExecuteCommand.initCli(repository, program);
|
|
46
|
+
RunCommand.initCli(repository, program);
|
|
47
|
+
VersionCommand.initCli(repository, program);
|
|
48
|
+
PublishCommand.initCli(repository, program);
|
|
49
|
+
CleanInstallCommand.initCli(repository, program);
|
|
50
|
+
BuildCommand.initCli(repository, program);
|
|
51
|
+
if (!_argv.length)
|
|
52
|
+
program.showHelp();
|
|
53
|
+
else
|
|
54
|
+
await program.parseAsync()
|
|
55
|
+
.catch(() => false);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
logger.error('rman', e);
|
|
59
|
+
}
|
|
54
60
|
}
|
|
@@ -3,7 +3,7 @@ import logger from 'npmlog';
|
|
|
3
3
|
import { Task } from 'power-tasks';
|
|
4
4
|
import { toNumber } from 'putil-varhelpers';
|
|
5
5
|
import { Command } from './../core/command.mjs';
|
|
6
|
-
import { isTTY } from './../
|
|
6
|
+
import { isTTY } from './../core/constants.mjs';
|
|
7
7
|
export class MultiTaskCommand extends Command {
|
|
8
8
|
constructor(repository, options) {
|
|
9
9
|
super(options);
|
package/esm/core/command.mjs
CHANGED
|
@@ -3,10 +3,9 @@ import npmlog from 'npmlog';
|
|
|
3
3
|
import isCi from 'is-ci';
|
|
4
4
|
import merge from 'putil-merge';
|
|
5
5
|
import './logger.mjs';
|
|
6
|
-
import { isTTY } from '
|
|
6
|
+
import { isTTY } from './constants.mjs';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import figures from 'figures';
|
|
9
|
-
import logger from 'npmlog';
|
|
10
9
|
const noOp = () => void (0);
|
|
11
10
|
export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
12
11
|
constructor(options) {
|
|
@@ -20,7 +19,7 @@ export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
20
19
|
this.logger.separator = chalk.gray(figures.lineVerticalDashed0);
|
|
21
20
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
22
21
|
get() {
|
|
23
|
-
return
|
|
22
|
+
return npmlog.levels[npmlog.level] || 0;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
}
|
|
@@ -82,7 +81,7 @@ export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
82
81
|
//
|
|
83
82
|
}
|
|
84
83
|
async _preExecute() {
|
|
85
|
-
|
|
84
|
+
npmlog.info('rman', `Executing "${this.commandName}" command`);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
(function (Command) {
|
|
File without changes
|
|
File without changes
|
package/esm/core/repository.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import glob from 'fast-glob';
|
|
|
4
4
|
import merge from 'putil-merge';
|
|
5
5
|
import yaml from 'js-yaml';
|
|
6
6
|
import { Package } from './package.mjs';
|
|
7
|
-
import { getPackageJson } from './../utils.mjs';
|
|
7
|
+
import { getPackageJson } from './../utils/get-dirname.mjs';
|
|
8
8
|
export class Repository extends Package {
|
|
9
9
|
constructor(dirname, config, packages) {
|
|
10
10
|
super(dirname);
|
package/esm/debug.mjs
CHANGED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rman",
|
|
3
3
|
"description": "Monorepo repository manager",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"contributors": [
|
|
@@ -37,46 +37,46 @@
|
|
|
37
37
|
"easy-table": "^1.2.0",
|
|
38
38
|
"envinfo": "^7.8.1",
|
|
39
39
|
"fast-glob": "^3.2.11",
|
|
40
|
-
"figures": "^4.0.
|
|
41
|
-
"ini": "^
|
|
40
|
+
"figures": "^4.0.1",
|
|
41
|
+
"ini": "^3.0.0",
|
|
42
42
|
"is-ci": "^3.0.1",
|
|
43
43
|
"js-yaml": "^4.1.0",
|
|
44
|
-
"npmlog": "^6.0.
|
|
44
|
+
"npmlog": "^6.0.2",
|
|
45
45
|
"path-key": "^4.0.0",
|
|
46
46
|
"power-tasks": "^0.6.0",
|
|
47
47
|
"putil-merge": "^3.8.0",
|
|
48
|
-
"putil-varhelpers": "^1.6.
|
|
49
|
-
"semver": "^7.3.
|
|
48
|
+
"putil-varhelpers": "^1.6.4",
|
|
49
|
+
"semver": "^7.3.7",
|
|
50
50
|
"signal-exit": "^3.0.7",
|
|
51
51
|
"strict-typed-events": "^2.1.0",
|
|
52
52
|
"strip-color": "^0.1.0",
|
|
53
|
-
"yargs": "^17.
|
|
53
|
+
"yargs": "^17.5.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@babel/eslint-parser": "^7.17.0",
|
|
57
57
|
"@types/envinfo": "^7.8.1",
|
|
58
58
|
"@types/ini": "^1.3.31",
|
|
59
59
|
"@types/is-ci": "^3.0.0",
|
|
60
|
-
"@types/jest": "^27.
|
|
60
|
+
"@types/jest": "^27.5.1",
|
|
61
61
|
"@types/js-yaml": "^4.0.5",
|
|
62
|
-
"@types/node": "^17.0.
|
|
62
|
+
"@types/node": "^17.0.34",
|
|
63
63
|
"@types/npmlog": "^4.1.4",
|
|
64
64
|
"@types/semver": "^7.3.9",
|
|
65
65
|
"@types/signal-exit": "^3.0.1",
|
|
66
66
|
"@types/strip-color": "^0.1.0",
|
|
67
67
|
"@types/yargs": "^17.0.10",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
69
|
-
"@typescript-eslint/parser": "^5.
|
|
70
|
-
"eslint": "^8.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.25.0",
|
|
70
|
+
"eslint": "^8.15.0",
|
|
71
71
|
"eslint-config-google": "^0.14.0",
|
|
72
|
-
"jest": "^
|
|
72
|
+
"jest": "^28.1.0",
|
|
73
73
|
"ts-cleanup": "^0.2.4",
|
|
74
74
|
"ts-gems": "^1.5.2",
|
|
75
|
-
"ts-jest": "^
|
|
76
|
-
"ts-loader": "^9.
|
|
75
|
+
"ts-jest": "^28.0.2",
|
|
76
|
+
"ts-loader": "^9.3.0",
|
|
77
77
|
"ts-node": "^10.7.0",
|
|
78
|
-
"tsconfig-paths": "^
|
|
79
|
-
"typescript": "^4.6.
|
|
78
|
+
"tsconfig-paths": "^4.0.0",
|
|
79
|
+
"typescript": "^4.6.4",
|
|
80
80
|
"typescript-esm": "^2.0.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
package/cjs/core/config.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Config = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
10
|
-
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
class Config {
|
|
13
|
-
constructor(data) {
|
|
14
|
-
this.data = data;
|
|
15
|
-
}
|
|
16
|
-
getObject(key, def) {
|
|
17
|
-
const v = this.get(key);
|
|
18
|
-
if (v != null && typeof v === 'object')
|
|
19
|
-
return v;
|
|
20
|
-
return def;
|
|
21
|
-
}
|
|
22
|
-
getString(key, def) {
|
|
23
|
-
const v = this.get(key);
|
|
24
|
-
if (v != null && typeof v !== 'object')
|
|
25
|
-
return '' + v;
|
|
26
|
-
return def;
|
|
27
|
-
}
|
|
28
|
-
getNumber(key, def) {
|
|
29
|
-
const v = this.get(key);
|
|
30
|
-
if (v != null && typeof v !== 'object') {
|
|
31
|
-
const n = parseFloat(v);
|
|
32
|
-
if (!isNaN(n))
|
|
33
|
-
return n;
|
|
34
|
-
}
|
|
35
|
-
return def;
|
|
36
|
-
}
|
|
37
|
-
get(key) {
|
|
38
|
-
const keys = key.split('.');
|
|
39
|
-
let o = this.data;
|
|
40
|
-
for (let i = 0; i < keys.length; i++) {
|
|
41
|
-
const k = keys[i];
|
|
42
|
-
if (o.hasOwnProperty(k)) {
|
|
43
|
-
if (i === keys.length - 1)
|
|
44
|
-
return o[k];
|
|
45
|
-
if (o[k] && typeof o[k] === 'object') {
|
|
46
|
-
o = o[k];
|
|
47
|
-
}
|
|
48
|
-
else
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
static resolve(dirname) {
|
|
54
|
-
const data = {};
|
|
55
|
-
const pkgJson = (0, utils_1.getPackageJson)(dirname);
|
|
56
|
-
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
57
|
-
(0, putil_merge_1.default)(data, pkgJson.rman, { deep: true });
|
|
58
|
-
let filename = path_1.default.resolve(dirname, '.rman.yml');
|
|
59
|
-
if (fs_1.default.existsSync(filename)) {
|
|
60
|
-
const obj = js_yaml_1.default.load(fs_1.default.readFileSync(filename, 'utf-8'));
|
|
61
|
-
if (obj && typeof obj === 'object')
|
|
62
|
-
(0, putil_merge_1.default)(data, obj, { deep: true });
|
|
63
|
-
}
|
|
64
|
-
filename = path_1.default.resolve(dirname, '.rmanrc');
|
|
65
|
-
if (fs_1.default.existsSync(filename)) {
|
|
66
|
-
const obj = JSON.parse(fs_1.default.readFileSync(filename, 'utf-8'));
|
|
67
|
-
if (obj && typeof obj === 'object')
|
|
68
|
-
(0, putil_merge_1.default)(data, obj, { deep: true });
|
|
69
|
-
}
|
|
70
|
-
return new Config(data);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.Config = Config;
|
package/esm/core/config.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class Config {
|
|
2
|
-
data: any;
|
|
3
|
-
constructor(data: any);
|
|
4
|
-
getObject(key: string, def?: any): any | undefined;
|
|
5
|
-
getString(key: string, def?: string): string | undefined;
|
|
6
|
-
getNumber(key: string, def?: number): number | undefined;
|
|
7
|
-
get(key: string): any;
|
|
8
|
-
static resolve(dirname: string): Config;
|
|
9
|
-
}
|
package/esm/core/config.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import yaml from 'js-yaml';
|
|
4
|
-
import merge from 'putil-merge';
|
|
5
|
-
import { getPackageJson } from './../utils.mjs';
|
|
6
|
-
export class Config {
|
|
7
|
-
constructor(data) {
|
|
8
|
-
this.data = data;
|
|
9
|
-
}
|
|
10
|
-
getObject(key, def) {
|
|
11
|
-
const v = this.get(key);
|
|
12
|
-
if (v != null && typeof v === 'object')
|
|
13
|
-
return v;
|
|
14
|
-
return def;
|
|
15
|
-
}
|
|
16
|
-
getString(key, def) {
|
|
17
|
-
const v = this.get(key);
|
|
18
|
-
if (v != null && typeof v !== 'object')
|
|
19
|
-
return '' + v;
|
|
20
|
-
return def;
|
|
21
|
-
}
|
|
22
|
-
getNumber(key, def) {
|
|
23
|
-
const v = this.get(key);
|
|
24
|
-
if (v != null && typeof v !== 'object') {
|
|
25
|
-
const n = parseFloat(v);
|
|
26
|
-
if (!isNaN(n))
|
|
27
|
-
return n;
|
|
28
|
-
}
|
|
29
|
-
return def;
|
|
30
|
-
}
|
|
31
|
-
get(key) {
|
|
32
|
-
const keys = key.split('.');
|
|
33
|
-
let o = this.data;
|
|
34
|
-
for (let i = 0; i < keys.length; i++) {
|
|
35
|
-
const k = keys[i];
|
|
36
|
-
if (o.hasOwnProperty(k)) {
|
|
37
|
-
if (i === keys.length - 1)
|
|
38
|
-
return o[k];
|
|
39
|
-
if (o[k] && typeof o[k] === 'object') {
|
|
40
|
-
o = o[k];
|
|
41
|
-
}
|
|
42
|
-
else
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
static resolve(dirname) {
|
|
48
|
-
const data = {};
|
|
49
|
-
const pkgJson = getPackageJson(dirname);
|
|
50
|
-
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
51
|
-
merge(data, pkgJson.rman, { deep: true });
|
|
52
|
-
let filename = path.resolve(dirname, '.rman.yml');
|
|
53
|
-
if (fs.existsSync(filename)) {
|
|
54
|
-
const obj = yaml.load(fs.readFileSync(filename, 'utf-8'));
|
|
55
|
-
if (obj && typeof obj === 'object')
|
|
56
|
-
merge(data, obj, { deep: true });
|
|
57
|
-
}
|
|
58
|
-
filename = path.resolve(dirname, '.rmanrc');
|
|
59
|
-
if (fs.existsSync(filename)) {
|
|
60
|
-
const obj = JSON.parse(fs.readFileSync(filename, 'utf-8'));
|
|
61
|
-
if (obj && typeof obj === 'object')
|
|
62
|
-
merge(data, obj, { deep: true });
|
|
63
|
-
}
|
|
64
|
-
return new Config(data);
|
|
65
|
-
}
|
|
66
|
-
}
|