@zokugun/artifact 0.1.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/LICENSE +22 -0
- package/README.md +102 -0
- package/bin/artifact +3 -0
- package/lib/cli.js +17 -0
- package/lib/commands/add.js +57 -0
- package/lib/compositors/compose.js +49 -0
- package/lib/compositors/fork.js +21 -0
- package/lib/compositors/index.js +13 -0
- package/lib/compositors/json.js +56 -0
- package/lib/compositors/rc.js +47 -0
- package/lib/compositors/yaml.js +34 -0
- package/lib/install.js +32 -0
- package/lib/journeys/commitlint/index.js +19 -0
- package/lib/journeys/default/index.js +17 -0
- package/lib/journeys/gitignore/index.js +7 -0
- package/lib/journeys/ignore/index.js +7 -0
- package/lib/journeys/index.js +34 -0
- package/lib/journeys/npmignore/index.js +7 -0
- package/lib/journeys/package/index.js +48 -0
- package/lib/journeys/rc/index.js +15 -0
- package/lib/parsers/json.js +11 -0
- package/lib/parsers/jsonc/index.js +7 -0
- package/lib/parsers/jsonc/parse.js +194 -0
- package/lib/parsers/jsonc/stringify.js +100 -0
- package/lib/parsers/jsonc/transform.js +2 -0
- package/lib/parsers/yaml.js +15 -0
- package/lib/routes/command.js +21 -0
- package/lib/routes/hash.js +13 -0
- package/lib/routes/index.js +15 -0
- package/lib/routes/lines-concat.js +22 -0
- package/lib/routes/list-concat.js +18 -0
- package/lib/routes/overwrite.js +12 -0
- package/lib/routes/primitive.js +18 -0
- package/lib/steps/apply-formatting.js +78 -0
- package/lib/steps/copy-binary-files.js +31 -0
- package/lib/steps/index.js +42 -0
- package/lib/steps/insert-final-new-line.js +25 -0
- package/lib/steps/merge-text-files.js +57 -0
- package/lib/steps/read-editor-config.js +97 -0
- package/lib/steps/read-files.js +66 -0
- package/lib/steps/read-incoming-package.js +24 -0
- package/lib/steps/read-target-config.js +78 -0
- package/lib/steps/update-target-config.js +50 -0
- package/lib/steps/write-text-files.js +32 -0
- package/lib/types/config.js +2 -0
- package/lib/types/context.js +2 -0
- package/lib/types/format.js +8 -0
- package/lib/types/step.js +2 -0
- package/lib/types/text-file.js +2 -0
- package/lib/types/travel.js +2 -0
- package/lib/utils/build-journey-plan.js +18 -0
- package/lib/utils/build-travel-plan.js +20 -0
- package/lib/utils/command/command.js +2 -0
- package/lib/utils/command/index.js +7 -0
- package/lib/utils/command/join-command.js +27 -0
- package/lib/utils/command/split-command.js +30 -0
- package/lib/utils/read-buffer.js +38 -0
- package/lib/utils/to-lines.js +7 -0
- package/lib/utils/trim-final-newline.js +8 -0
- package/package.json +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2021-present Baptiste Augrain
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
[@zokugun/artifact](https://github.com/zokugun/artifact)
|
|
2
|
+
========================================================
|
|
3
|
+
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@zokugun/artifact)
|
|
6
|
+
[](https://ko-fi.com/daiyam)
|
|
7
|
+
[](https://liberapay.com/daiyam/donate)
|
|
8
|
+
[](https://paypal.me/daiyam99)
|
|
9
|
+
|
|
10
|
+
`artifact` is a command-line interface which allows you:
|
|
11
|
+
- to boilerplate your project from multiple packages
|
|
12
|
+
- to merge the duplicated configuration files found across the packages
|
|
13
|
+
- to keep your configurations up to date
|
|
14
|
+
|
|
15
|
+
Mergeable Files
|
|
16
|
+
---------------
|
|
17
|
+
|
|
18
|
+
- `*.json` (JSON or JSONC)
|
|
19
|
+
- `*.yml`
|
|
20
|
+
- `*.yaml`
|
|
21
|
+
- `*ignore`
|
|
22
|
+
- `*rc` (YAML, JSON or JSONC)
|
|
23
|
+
|
|
24
|
+
Getting Started
|
|
25
|
+
---------------
|
|
26
|
+
|
|
27
|
+
With [node](http://nodejs.org) previously installed:
|
|
28
|
+
|
|
29
|
+
npm install -g @zokugun/artifact
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Add the configuration packages:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
artifact add @daiyam/base @daiyam/lang-ts @daiyam/npm-ts
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
With the previous command, `artifact` will pull the following packages:
|
|
39
|
+
- [@daiyam/artifact-base](https://github.com/daiyam/artifact-configs/tree/master/packages/base)
|
|
40
|
+
- [@daiyam/artifact-lang-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/lang-ts)
|
|
41
|
+
- [@daiyam/artifact-npm-ts](https://github.com/daiyam/artifact-configs/tree/master/packages/npm-ts)
|
|
42
|
+
|
|
43
|
+
Like `yeoman`, a configuration package must be prefixed with `artifact-`.
|
|
44
|
+
|
|
45
|
+
Configuration Package
|
|
46
|
+
---------------------
|
|
47
|
+
|
|
48
|
+
The configuration/boilerplate files must be put inside the folder `configs`.
|
|
49
|
+
|
|
50
|
+
For example, the package [@daiyam/artifact-base](https://github.com/daiyam/artifact-configs/tree/master/packages/base):
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
artifact-configs/base/
|
|
54
|
+
├── configs/
|
|
55
|
+
│ ├── .commitlintrc.yml
|
|
56
|
+
│ ├── .editorconfig
|
|
57
|
+
│ ├── .lintstagedrc
|
|
58
|
+
│ ├── gitignore
|
|
59
|
+
│ ├── package.json
|
|
60
|
+
│ └── ...
|
|
61
|
+
├── LICENSE
|
|
62
|
+
├── package.json
|
|
63
|
+
└── README.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Yeoman
|
|
67
|
+
------
|
|
68
|
+
|
|
69
|
+
`artifact` can be used in a yeoman generator. Ex: [@daiyam/generator-new-project](https://github.com/daiyam/generator-new-project)
|
|
70
|
+
|
|
71
|
+
Limitation
|
|
72
|
+
----------
|
|
73
|
+
|
|
74
|
+
The `update` command haven't been developed, yet.<br />
|
|
75
|
+
But, to keep your configurations up to date, you can *re-add* the configuration packages and manually revert the bad changes.
|
|
76
|
+
|
|
77
|
+
Donations
|
|
78
|
+
---------
|
|
79
|
+
|
|
80
|
+
Support this project by becoming a financial contributor.
|
|
81
|
+
|
|
82
|
+
<table>
|
|
83
|
+
<tr>
|
|
84
|
+
<td><img src="https://raw.githubusercontent.com/daiyam/assets/master/icons/256/funding_kofi.png" alt="Ko-fi" width="80px" height="80px"></td>
|
|
85
|
+
<td><a href="https://ko-fi.com/daiyam" target="_blank">ko-fi.com/daiyam</a></td>
|
|
86
|
+
</tr>
|
|
87
|
+
<tr>
|
|
88
|
+
<td><img src="https://raw.githubusercontent.com/daiyam/assets/master/icons/256/funding_liberapay.png" alt="Liberapay" width="80px" height="80px"></td>
|
|
89
|
+
<td><a href="https://liberapay.com/daiyam/donate" target="_blank">liberapay.com/daiyam/donate</a></td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td><img src="https://raw.githubusercontent.com/daiyam/assets/master/icons/256/funding_paypal.png" alt="PayPal" width="80px" height="80px"></td>
|
|
93
|
+
<td><a href="https://paypal.me/daiyam99" target="_blank">paypal.me/daiyam99</a></td>
|
|
94
|
+
</tr>
|
|
95
|
+
</table>
|
|
96
|
+
|
|
97
|
+
License
|
|
98
|
+
-------
|
|
99
|
+
|
|
100
|
+
Copyright © 2021-present Baptiste Augrain
|
|
101
|
+
|
|
102
|
+
Licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
package/bin/artifact
ADDED
package/lib/cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
const commander_1 = require("commander");
|
|
7
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
8
|
+
const add_1 = require("./commands/add");
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program.version(package_json_1.default.version);
|
|
11
|
+
program
|
|
12
|
+
.command('add')
|
|
13
|
+
.description('add an artifact to the current project')
|
|
14
|
+
.option('-v, --verbose', 'output more details')
|
|
15
|
+
.argument('<artifacts...>')
|
|
16
|
+
.action(add_1.add);
|
|
17
|
+
program.parse();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.add = void 0;
|
|
16
|
+
const process_1 = __importDefault(require("process"));
|
|
17
|
+
const pacote_1 = __importDefault(require("pacote"));
|
|
18
|
+
const tempy_1 = __importDefault(require("tempy"));
|
|
19
|
+
const npm_1 = __importDefault(require("npm"));
|
|
20
|
+
const install_1 = require("../install");
|
|
21
|
+
function expandSpec(spec) {
|
|
22
|
+
if (spec.includes('/')) {
|
|
23
|
+
const [scope, name] = spec.split('/');
|
|
24
|
+
if (name.startsWith('artifact-')) {
|
|
25
|
+
return spec;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return `${scope}/artifact-${name}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (spec.startsWith('artifact-')) {
|
|
33
|
+
return spec;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return `artifact-${spec}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} // }}}
|
|
40
|
+
function add(specs, options) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield npm_1.default.load();
|
|
43
|
+
const registry = npm_1.default.config.get('registry');
|
|
44
|
+
const targetPath = process_1.default.env.INIT_CWD;
|
|
45
|
+
for (const spec of specs) {
|
|
46
|
+
const dir = tempy_1.default.directory();
|
|
47
|
+
const result = yield pacote_1.default.extract(expandSpec(spec), dir, { registry });
|
|
48
|
+
if (!result.resolved) {
|
|
49
|
+
throw new Error(result.from);
|
|
50
|
+
}
|
|
51
|
+
yield (0, install_1.install)(targetPath, dir, {
|
|
52
|
+
verbose: options.verbose,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.add = add;
|
|
@@ -0,0 +1,49 @@
|
|
|
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.compose = void 0;
|
|
7
|
+
const has_1 = __importDefault(require("lodash/has"));
|
|
8
|
+
const without_1 = __importDefault(require("lodash/without"));
|
|
9
|
+
function apply(map, keys, current, incoming, result) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
if (keys.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const ignores = (_a = map.$$ignore) !== null && _a !== void 0 ? _a : [];
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
const currentValue = current[key];
|
|
17
|
+
const transform = (_b = map[key]) !== null && _b !== void 0 ? _b : map.$$default;
|
|
18
|
+
if (!transform || !(0, has_1.default)(incoming, key) || ignores.includes(key)) {
|
|
19
|
+
if (currentValue !== undefined) {
|
|
20
|
+
result[key] = currentValue;
|
|
21
|
+
}
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const incomingValue = incoming[key];
|
|
25
|
+
result[key] = transform({
|
|
26
|
+
current: currentValue,
|
|
27
|
+
incoming: incomingValue,
|
|
28
|
+
ignores: map.$$ignore,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function compose(map) {
|
|
33
|
+
return ({ current, incoming }) => {
|
|
34
|
+
if (incoming === undefined) {
|
|
35
|
+
return current !== null && current !== void 0 ? current : {};
|
|
36
|
+
}
|
|
37
|
+
if (current === undefined || typeof current !== typeof incoming) {
|
|
38
|
+
return incoming;
|
|
39
|
+
}
|
|
40
|
+
const result = {};
|
|
41
|
+
const currentKeys = Object.keys(current);
|
|
42
|
+
const incomingKeys = Object.keys(incoming);
|
|
43
|
+
const newKeys = (0, without_1.default)(incomingKeys, ...currentKeys);
|
|
44
|
+
apply(map, currentKeys, current, incoming, result);
|
|
45
|
+
apply(map, newKeys, current, incoming, result);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.compose = compose;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fork = void 0;
|
|
4
|
+
function fork(...cases) {
|
|
5
|
+
return ({ current, incoming }) => {
|
|
6
|
+
const targetCase = cases.find((c) => {
|
|
7
|
+
if (!Array.isArray(c)) {
|
|
8
|
+
return c;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return c[0](current !== null && current !== void 0 ? current : incoming);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (!targetCase) {
|
|
15
|
+
return current !== null && current !== void 0 ? current : incoming;
|
|
16
|
+
}
|
|
17
|
+
const targetMerge = Array.isArray(targetCase) ? targetCase[1] : targetCase;
|
|
18
|
+
return targetMerge({ current, incoming });
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.fork = fork;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yaml = exports.rc = exports.json = exports.fork = exports.compose = void 0;
|
|
4
|
+
var compose_1 = require("./compose");
|
|
5
|
+
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.compose; } });
|
|
6
|
+
var fork_1 = require("./fork");
|
|
7
|
+
Object.defineProperty(exports, "fork", { enumerable: true, get: function () { return fork_1.fork; } });
|
|
8
|
+
var json_1 = require("./json");
|
|
9
|
+
Object.defineProperty(exports, "json", { enumerable: true, get: function () { return json_1.json; } });
|
|
10
|
+
var rc_1 = require("./rc");
|
|
11
|
+
Object.defineProperty(exports, "rc", { enumerable: true, get: function () { return rc_1.rc; } });
|
|
12
|
+
var yaml_1 = require("./yaml");
|
|
13
|
+
Object.defineProperty(exports, "yaml", { enumerable: true, get: function () { return yaml_1.yaml; } });
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.json = void 0;
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const JSON = __importStar(require("../parsers/json"));
|
|
25
|
+
const JSONC = __importStar(require("../parsers/jsonc"));
|
|
26
|
+
const routes_1 = require("../routes");
|
|
27
|
+
const compose_1 = require("./compose");
|
|
28
|
+
const fork_1 = require("./fork");
|
|
29
|
+
function tryJson(value) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(value);
|
|
32
|
+
}
|
|
33
|
+
catch (_a) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const merge = (0, compose_1.compose)({
|
|
38
|
+
$$default: (0, fork_1.fork)([Array.isArray, routes_1.listConcat], [lodash_1.isPlainObject, routes_1.hash], routes_1.primitive),
|
|
39
|
+
});
|
|
40
|
+
function json(...routes) {
|
|
41
|
+
return ({ current, incoming, ignores }) => {
|
|
42
|
+
const currentData = current && tryJson(current);
|
|
43
|
+
const incomingData = incoming && tryJson(incoming);
|
|
44
|
+
if ((!current || currentData) && (!incoming || incomingData)) {
|
|
45
|
+
return (0, lodash_1.flow)(...routes, JSON.stringify)({ current: currentData, incoming: incomingData, ignores });
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const { data: currentData, transform: currentTransform } = JSONC.parse(current);
|
|
49
|
+
const { data: incomingData, transform: incomingTransform } = JSONC.parse(incoming);
|
|
50
|
+
const mergedTransform = merge({ current: currentTransform, incoming: incomingTransform });
|
|
51
|
+
const toJSON = (data) => JSONC.stringify(data, mergedTransform);
|
|
52
|
+
return (0, lodash_1.flow)(...routes, toJSON)({ current: currentData, incoming: incomingData, ignores });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.json = json;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.rc = void 0;
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const JSON = __importStar(require("../parsers/json"));
|
|
25
|
+
const YAML = __importStar(require("../parsers/yaml"));
|
|
26
|
+
function tryJson(value) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(value);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function rc(...routes) {
|
|
35
|
+
return ({ current, incoming, ignores }) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const currentData = current && ((_a = tryJson(current)) !== null && _a !== void 0 ? _a : YAML.parse(current));
|
|
38
|
+
const incomingData = incoming && tryJson(incoming);
|
|
39
|
+
if (incomingData) {
|
|
40
|
+
return (0, lodash_1.flow)(...routes, JSON.stringify)({ current: currentData, incoming: incomingData, ignores });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return (0, lodash_1.flow)(...routes, YAML.stringify)({ current: currentData, incoming: incoming && YAML.parse(incoming), ignores });
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.rc = rc;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.yaml = void 0;
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const YAML = __importStar(require("../parsers/yaml"));
|
|
25
|
+
function fromYaml({ current, incoming }) {
|
|
26
|
+
return {
|
|
27
|
+
current: typeof current === 'undefined' ? undefined : YAML.parse(current),
|
|
28
|
+
incoming: YAML.parse(incoming),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function yaml(...routes) {
|
|
32
|
+
return (0, lodash_1.flow)(fromYaml, ...routes, YAML.stringify);
|
|
33
|
+
}
|
|
34
|
+
exports.yaml = yaml;
|
package/lib/install.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.install = void 0;
|
|
13
|
+
const steps_1 = require("./steps");
|
|
14
|
+
const commonFlow = (0, steps_1.composeSteps)(steps_1.steps.readTargetConfig, steps_1.steps.readIncomingPackage, steps_1.steps.readFiles, steps_1.steps.readEditorConfig, steps_1.steps.mergeTextFiles, steps_1.steps.updateTargetConfig, steps_1.steps.insertFinalNewLine, steps_1.steps.applyFormatting, steps_1.steps.copyBinaryFiles, steps_1.steps.writeTextFiles);
|
|
15
|
+
function install(targetPath, incomingPath, options) {
|
|
16
|
+
var _a;
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
yield commonFlow({
|
|
19
|
+
targetPath,
|
|
20
|
+
incomingPath,
|
|
21
|
+
binaryFiles: [],
|
|
22
|
+
textFiles: [],
|
|
23
|
+
mergedTextFiles: [],
|
|
24
|
+
configs: [],
|
|
25
|
+
formats: [],
|
|
26
|
+
options: {
|
|
27
|
+
verbose: (_a = options === null || options === void 0 ? void 0 : options.verbose) !== null && _a !== void 0 ? _a : false,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.install = install;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const compositors_1 = require("../../compositors");
|
|
4
|
+
const routes_1 = require("../../routes");
|
|
5
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
6
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
7
|
+
const mainRoute = (0, compositors_1.compose)({
|
|
8
|
+
extends: routes_1.listConcat,
|
|
9
|
+
parserPreset: routes_1.primitive,
|
|
10
|
+
rules: (0, compositors_1.compose)({
|
|
11
|
+
$$default: routes_1.overwrite,
|
|
12
|
+
}),
|
|
13
|
+
$$default: routes_1.primitive,
|
|
14
|
+
});
|
|
15
|
+
const jsonRoute = (0, compositors_1.json)(mainRoute);
|
|
16
|
+
const yamlRoute = (0, compositors_1.yaml)(mainRoute);
|
|
17
|
+
const rcRoute = (0, compositors_1.rc)(mainRoute);
|
|
18
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)(['.commitlintrc.json', jsonRoute], ['.commitlintrc.yaml', yamlRoute], ['.commitlintrc.yml', yamlRoute], ['.commitlintrc', rcRoute]);
|
|
19
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
7
|
+
const compositors_1 = require("../../compositors");
|
|
8
|
+
const routes_1 = require("../../routes");
|
|
9
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
10
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
11
|
+
const mainRoute = (0, compositors_1.compose)({
|
|
12
|
+
$$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
13
|
+
});
|
|
14
|
+
const jsonRoute = (0, compositors_1.json)(mainRoute);
|
|
15
|
+
const yamlRoute = (0, compositors_1.yaml)(mainRoute);
|
|
16
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/\.json$/, jsonRoute], [/\.ya?ml$/, yamlRoute]);
|
|
17
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const routes_1 = require("../../routes");
|
|
4
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
5
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
6
|
+
const gitignorePlan = (0, build_travel_plan_1.buildTravelPlan)([/^\.?gitignore$/, routes_1.linesConcat]);
|
|
7
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(gitignorePlan, '.gitignore');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const routes_1 = require("../../routes");
|
|
4
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
5
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
6
|
+
const ignorePlan = (0, build_travel_plan_1.buildTravelPlan)([/^\..*ignore$/, routes_1.linesConcat]);
|
|
7
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(ignorePlan);
|
|
@@ -0,0 +1,34 @@
|
|
|
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.getJourney = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const commitlint_1 = __importDefault(require("./commitlint"));
|
|
9
|
+
const default_1 = __importDefault(require("./default"));
|
|
10
|
+
const gitignore_1 = __importDefault(require("./gitignore"));
|
|
11
|
+
const ignore_1 = __importDefault(require("./ignore"));
|
|
12
|
+
const npmignore_1 = __importDefault(require("./npmignore"));
|
|
13
|
+
const package_1 = __importDefault(require("./package"));
|
|
14
|
+
const rc_1 = __importDefault(require("./rc"));
|
|
15
|
+
const plans = [
|
|
16
|
+
package_1.default,
|
|
17
|
+
gitignore_1.default,
|
|
18
|
+
npmignore_1.default,
|
|
19
|
+
ignore_1.default,
|
|
20
|
+
commitlint_1.default,
|
|
21
|
+
rc_1.default,
|
|
22
|
+
default_1.default,
|
|
23
|
+
];
|
|
24
|
+
function getJourney(filename) {
|
|
25
|
+
const basename = path_1.default.basename(filename);
|
|
26
|
+
for (const plan of plans) {
|
|
27
|
+
const journey = plan(basename);
|
|
28
|
+
if (journey) {
|
|
29
|
+
return journey;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.getJourney = getJourney;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const routes_1 = require("../../routes");
|
|
4
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
5
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
6
|
+
const gitignorePlan = (0, build_travel_plan_1.buildTravelPlan)([/^\.?npmignore$/, routes_1.linesConcat]);
|
|
7
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(gitignorePlan, '.npmignore');
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
7
|
+
const compositors_1 = require("../../compositors");
|
|
8
|
+
const routes_1 = require("../../routes");
|
|
9
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
10
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
11
|
+
const mainRoute = (0, compositors_1.compose)({
|
|
12
|
+
// default fields
|
|
13
|
+
keywords: routes_1.listConcat,
|
|
14
|
+
homepage: routes_1.primitive,
|
|
15
|
+
bugs: (0, compositors_1.fork)([isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
16
|
+
license: (0, compositors_1.fork)([isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
17
|
+
licenses: routes_1.listConcat,
|
|
18
|
+
author: (0, compositors_1.fork)([isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
19
|
+
repository: (0, compositors_1.fork)([isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
20
|
+
scripts: (0, compositors_1.compose)({
|
|
21
|
+
$$default: routes_1.command,
|
|
22
|
+
}),
|
|
23
|
+
config: routes_1.hash,
|
|
24
|
+
engines: routes_1.hash,
|
|
25
|
+
dependencies: routes_1.hash,
|
|
26
|
+
devDependencies: routes_1.hash,
|
|
27
|
+
peerDependencies: routes_1.hash,
|
|
28
|
+
optionalDependencies: routes_1.hash,
|
|
29
|
+
bundledDependencies: routes_1.hash,
|
|
30
|
+
// tools fields
|
|
31
|
+
browserslist: routes_1.listConcat,
|
|
32
|
+
// other fields
|
|
33
|
+
$$ignore: [
|
|
34
|
+
'name',
|
|
35
|
+
'version',
|
|
36
|
+
'description',
|
|
37
|
+
'people',
|
|
38
|
+
'man',
|
|
39
|
+
'os',
|
|
40
|
+
'cpu',
|
|
41
|
+
'preferGlobal',
|
|
42
|
+
'private',
|
|
43
|
+
],
|
|
44
|
+
$$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [isPlainObject_1.default, routes_1.hash], routes_1.primitive),
|
|
45
|
+
});
|
|
46
|
+
const jsonRoute = (0, compositors_1.json)(mainRoute);
|
|
47
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)(['package.json', jsonRoute]);
|
|
48
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lodash_1 = require("lodash");
|
|
4
|
+
const compositors_1 = require("../../compositors");
|
|
5
|
+
const routes_1 = require("../../routes");
|
|
6
|
+
const build_journey_plan_1 = require("../../utils/build-journey-plan");
|
|
7
|
+
const build_travel_plan_1 = require("../../utils/build-travel-plan");
|
|
8
|
+
const mainRoute = (0, compositors_1.compose)({
|
|
9
|
+
$$default: (0, compositors_1.fork)([Array.isArray, routes_1.listConcat], [lodash_1.isPlainObject, routes_1.hash], routes_1.primitive),
|
|
10
|
+
});
|
|
11
|
+
const jsonRoute = (0, compositors_1.json)(mainRoute);
|
|
12
|
+
const yamlRoute = (0, compositors_1.yaml)(mainRoute);
|
|
13
|
+
const rcRoute = (0, compositors_1.rc)(mainRoute);
|
|
14
|
+
const travelPlan = (0, build_travel_plan_1.buildTravelPlan)([/^\.\w+rc\.json$/, jsonRoute], [/^\.\w+rc\.ya?ml$/, yamlRoute], [/^\.\w+rc$/, rcRoute]);
|
|
15
|
+
exports.default = (0, build_journey_plan_1.buildJourneyPlan)(travelPlan);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringify = exports.parse = void 0;
|
|
4
|
+
function parse(data) {
|
|
5
|
+
return JSON.parse(data);
|
|
6
|
+
}
|
|
7
|
+
exports.parse = parse;
|
|
8
|
+
function stringify(data) {
|
|
9
|
+
return JSON.stringify(data, null, '\t');
|
|
10
|
+
}
|
|
11
|
+
exports.stringify = stringify;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringify = exports.parse = void 0;
|
|
4
|
+
var parse_1 = require("./parse");
|
|
5
|
+
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
6
|
+
var stringify_1 = require("./stringify");
|
|
7
|
+
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return stringify_1.stringify; } });
|