fscr 5.4.0 → 6.1.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/bin +1 -1
- package/dist/index.js +196 -49
- package/dist/lib/auth/auth-conf.js +63 -0
- package/dist/lib/codemod/arrow.js +13 -0
- package/dist/lib/codemod/arrow2.js +67 -0
- package/dist/lib/codemod/funcs.js +25 -0
- package/dist/lib/codemod/removeConsole.js +12 -0
- package/dist/lib/codemod/test.js +8 -0
- package/dist/lib/components/App.js +64 -0
- package/dist/lib/components/Selector.js +133 -0
- package/dist/lib/components/TabChanger.js +113 -0
- package/dist/lib/components/Table.js +177 -0
- package/dist/lib/components/Tabs.js +221 -0
- package/dist/lib/encryption/decryptConfig.js +81 -0
- package/dist/lib/encryption/encryption.js +135 -0
- package/dist/lib/generateFScripts.js +25 -0
- package/dist/lib/generateToc.js +36 -0
- package/dist/lib/generators/generateFScripts.js +25 -0
- package/dist/lib/generators/generateToc.js +38 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/git/files.js +26 -0
- package/dist/lib/git/pub.js +42 -0
- package/dist/lib/git/taskRunner.js +80 -0
- package/dist/lib/git/validateNotDev.js +71 -0
- package/dist/lib/helpers.js +191 -0
- package/dist/lib/optionList.js +61 -0
- package/dist/lib/parseScriptsMd.js +93 -0
- package/dist/lib/parseScriptsPackage.js +9 -0
- package/dist/lib/parsers/parseScriptsMd.js +96 -0
- package/dist/lib/parsers/parseScriptsPackage.js +9 -0
- package/dist/lib/release/bump.js +52 -0
- package/dist/lib/release/commitWithMessage.js +65 -0
- package/dist/lib/release/index.js +4 -0
- package/dist/lib/release/publish.js +23 -0
- package/dist/lib/release/publish.sh +1 -0
- package/dist/lib/release/pushToGit.js +43 -0
- package/dist/lib/release/releasenotes.js +158 -0
- package/dist/lib/release/seeChangedFiles.js +89 -0
- package/dist/lib/release/sort.js +136 -0
- package/dist/lib/release/tree.js +163 -0
- package/dist/lib/release/validateNotDev.js +63 -0
- package/dist/lib/run/lib.js +454 -0
- package/dist/lib/run/main-p.js +59 -0
- package/dist/lib/run/main-s.js +56 -0
- package/dist/lib/run/parse-cli-args.js +222 -0
- package/dist/lib/run/run-p.js +30 -0
- package/dist/lib/run/run-s.js +57 -0
- package/dist/lib/runCLICommand.js +30 -0
- package/dist/lib/runParallel.js +20 -0
- package/dist/lib/runSequence.js +38 -0
- package/dist/lib/running/index.js +3 -0
- package/dist/lib/running/runCLICommand.js +38 -0
- package/dist/lib/running/runParallel.js +33 -0
- package/dist/lib/running/runSequence.js +43 -0
- package/dist/lib/startScripts.js +135 -0
- package/dist/lib/taskList.js +93 -0
- package/dist/lib/taskListAutoComplete.js +10 -0
- package/dist/lib/upgradePackages.js +65 -0
- package/dist/lib/utils/clear.js +18 -0
- package/dist/lib/utils/console.js +33 -0
- package/dist/lib/utils/encryption.js +18 -0
- package/dist/lib/utils/helpers.js +228 -0
- package/dist/lib/utils/index.js +2 -0
- package/dist/lib/utils/prompt.js +34 -0
- package/package.json +10 -8
- /package/dist/{index.html → lib/auth/index.html} +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// let modifiedGitFiles = await ggg({ diffFilter: "M", showStatus: false, showCommitted: false });
|
|
2
|
+
// modifiedGitFiles = modifiedGitFiles.unCommittedFiles;
|
|
3
|
+
// console.log("MODDED", modifiedGitFiles);
|
|
4
|
+
// const res = await sgf();
|
|
5
|
+
import { writeFile } from "../utils/helpers.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import releaseNotes from "git-release-notes";
|
|
9
|
+
import inquirer from "inquirer";
|
|
10
|
+
import jclrz from "json-colorz";
|
|
11
|
+
import git from "git-state";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
import ggg from "git-changed-files";
|
|
14
|
+
import tree from "./tree.js";
|
|
15
|
+
import childProcess from "child_process";
|
|
16
|
+
// const tree = require("terminal-tree");
|
|
17
|
+
|
|
18
|
+
// jclrz.level.show = true;
|
|
19
|
+
// jclrz.level.spaces = 2;
|
|
20
|
+
// jclrz.level.start = 1;
|
|
21
|
+
// jclrz.level.char = chalk.bold.grey("⌐");
|
|
22
|
+
// jclrz.level.color = "black";
|
|
23
|
+
// for (const ss in syms) {
|
|
24
|
+
// jclrz.level.char = chalk.bold.grey(syms[ss]);
|
|
25
|
+
// }
|
|
26
|
+
// var toSymbol = String.fromCharCode(10132);
|
|
27
|
+
// const syms = ["⌯", "➢", "⃕", "⌁", "⌐", "━", "═", "⇝"];
|
|
28
|
+
|
|
29
|
+
const pathToCwd = process.cwd();
|
|
30
|
+
const grouped = (data, filesChanged) => {
|
|
31
|
+
let output = {};
|
|
32
|
+
let current;
|
|
33
|
+
for (const pdata of data) {
|
|
34
|
+
current = output;
|
|
35
|
+
for (const segment of pdata.split("/")) {
|
|
36
|
+
if (segment !== "") {
|
|
37
|
+
if (!(segment in current)) {
|
|
38
|
+
current[segment] = {};
|
|
39
|
+
}
|
|
40
|
+
current = current[segment];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let level = "";
|
|
45
|
+
const deepClone = obj => {
|
|
46
|
+
let clone = Object.assign({}, obj);
|
|
47
|
+
Object.keys(clone).forEach(key => {
|
|
48
|
+
let findMac = filesChanged.find(z => z.filename === key || z.filename === level + key);
|
|
49
|
+
if (typeof obj[key] === "object" && Object.keys(obj[key]).length) {
|
|
50
|
+
level += key + "/";
|
|
51
|
+
clone[key] = deepClone(obj[key]);
|
|
52
|
+
} else if (findMac) {
|
|
53
|
+
let stat = findMac.status === undefined ? "Deleted" : findMac.status;
|
|
54
|
+
console.info("-- Console STATUS", findMac.status, stat, key);
|
|
55
|
+
stat = stat.replace(/\x1B[[(?);]{0,2}(;?\d)*./g, "");
|
|
56
|
+
clone[key] = stat;
|
|
57
|
+
} else {
|
|
58
|
+
clone[key] = "";
|
|
59
|
+
}
|
|
60
|
+
return clone[key];
|
|
61
|
+
});
|
|
62
|
+
return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone;
|
|
63
|
+
};
|
|
64
|
+
output = deepClone(output);
|
|
65
|
+
console.info(tree(output, {
|
|
66
|
+
symbol: true,
|
|
67
|
+
highlight: true,
|
|
68
|
+
padding: 1,
|
|
69
|
+
colors: {
|
|
70
|
+
string: "black",
|
|
71
|
+
number: "red",
|
|
72
|
+
boolean: "red",
|
|
73
|
+
infinity: "red",
|
|
74
|
+
nan: "red",
|
|
75
|
+
null: "cyan",
|
|
76
|
+
undefined: "gray",
|
|
77
|
+
regexp: "green",
|
|
78
|
+
key: "black",
|
|
79
|
+
object: "grey",
|
|
80
|
+
array: "red"
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
// jclrz(output);
|
|
85
|
+
//
|
|
86
|
+
return output;
|
|
87
|
+
};
|
|
88
|
+
import sgfPkg from "staged-git-files";
|
|
89
|
+
const sgf = sgfPkg.default || sgfPkg;
|
|
90
|
+
(async () => {
|
|
91
|
+
const howManyCommitsBack = await new Promise(resolve => {
|
|
92
|
+
inquirer.prompt([{
|
|
93
|
+
type: "input",
|
|
94
|
+
message: "How many commits do you want to compare in the past?",
|
|
95
|
+
default: 5,
|
|
96
|
+
name: "howMany"
|
|
97
|
+
}]).then(async ({
|
|
98
|
+
howMany
|
|
99
|
+
}) => {
|
|
100
|
+
resolve(howMany);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
const results = await sgf();
|
|
104
|
+
let updatedFiles = await ggg({
|
|
105
|
+
diffFilter: "ACDMRTUXB",
|
|
106
|
+
showStatus: true,
|
|
107
|
+
showCommitted: false
|
|
108
|
+
});
|
|
109
|
+
updatedFiles = [...updatedFiles.unCommittedFiles, ...results];
|
|
110
|
+
let z = ""; // grouped(updatedFiles.map(e => e.filename).sort(), updatedFiles);
|
|
111
|
+
try {
|
|
112
|
+
z = childProcess.execSync(`git log -${howManyCommitsBack} --oneline | nl -v0 | sed 's/^ \\+/&HEAD~/'`, {
|
|
113
|
+
env: Object.assign({}, process.env)
|
|
114
|
+
}).toString();
|
|
115
|
+
// console.info("--- INFO z", z);
|
|
116
|
+
} catch (e) {}
|
|
117
|
+
z = z.split("\n").slice(-2)[0].split("\t").slice(-2)[1].split(" ")[0];
|
|
118
|
+
const last = await new Promise(rzz => {
|
|
119
|
+
git.isGit(pathToCwd, function (exists) {
|
|
120
|
+
if (!exists) return;
|
|
121
|
+
git.commit(pathToCwd, function (err, result) {
|
|
122
|
+
if (err) throw err;
|
|
123
|
+
rzz(result);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
console.info("-- Console FROM", z, "TO", last);
|
|
128
|
+
const OPTIONS = {
|
|
129
|
+
branch: "Development"
|
|
130
|
+
};
|
|
131
|
+
const RANGE = `${z}..${last}`;
|
|
132
|
+
const TEMPLATE = "markdown";
|
|
133
|
+
const changelog = await releaseNotes(OPTIONS, RANGE, TEMPLATE);
|
|
134
|
+
console.log(`Changelog between ${RANGE}\n\n${changelog}`);
|
|
135
|
+
// await fs.writeFileSync(path.resolve(process.cwd(), "release.md"), changelog, "utf-8");
|
|
136
|
+
})();
|
|
137
|
+
//
|
|
138
|
+
|
|
139
|
+
// git.check(path, function(err, result) {
|
|
140
|
+
// if (err) throw err;
|
|
141
|
+
// console.log(result); // => { branch: 'master',
|
|
142
|
+
// // ahead: 0,
|
|
143
|
+
// // dirty: 9,
|
|
144
|
+
// // untracked: 1,
|
|
145
|
+
// // stashes: 0 }
|
|
146
|
+
// });
|
|
147
|
+
|
|
148
|
+
// console.info(
|
|
149
|
+
// '-- Console path.resolve(process.cwd(), "release.md")',
|
|
150
|
+
// path.resolve(process.cwd(), "release.md")
|
|
151
|
+
// );
|
|
152
|
+
//
|
|
153
|
+
|
|
154
|
+
//
|
|
155
|
+
// // .catch(ex => {
|
|
156
|
+
// // console.error(ex);
|
|
157
|
+
// // process.exit(1);
|
|
158
|
+
// // resolve();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// let modifiedGitFiles = await ggg({ diffFilter: "M", showStatus: false, showCommitted: false });
|
|
2
|
+
// modifiedGitFiles = modifiedGitFiles.unCommittedFiles;
|
|
3
|
+
// console.log("MODDED", modifiedGitFiles);
|
|
4
|
+
// const res = await sgf();
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import ggg from "git-changed-files";
|
|
7
|
+
import tree from "./tree.js";
|
|
8
|
+
// const tree = require("terminal-tree");
|
|
9
|
+
|
|
10
|
+
// jclrz.level.show = true;
|
|
11
|
+
// jclrz.level.spaces = 2;
|
|
12
|
+
// jclrz.level.start = 1;
|
|
13
|
+
// jclrz.level.char = chalk.bold.grey("⌐");
|
|
14
|
+
// jclrz.level.color = "black";
|
|
15
|
+
// for (const ss in syms) {
|
|
16
|
+
// jclrz.level.char = chalk.bold.grey(syms[ss]);
|
|
17
|
+
// }
|
|
18
|
+
// var toSymbol = String.fromCharCode(10132);
|
|
19
|
+
// const syms = ["⌯", "➢", "⃕", "⌁", "⌐", "━", "═", "⇝"];
|
|
20
|
+
|
|
21
|
+
const grouped = (data, filesChanged) => {
|
|
22
|
+
let output = {};
|
|
23
|
+
let current;
|
|
24
|
+
for (const pdata of data) {
|
|
25
|
+
current = output;
|
|
26
|
+
for (const segment of pdata.split("/")) {
|
|
27
|
+
if (segment !== "") {
|
|
28
|
+
if (!(segment in current)) {
|
|
29
|
+
current[segment] = {};
|
|
30
|
+
}
|
|
31
|
+
current = current[segment];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let level = "";
|
|
36
|
+
const deepClone = obj => {
|
|
37
|
+
let clone = Object.assign({}, obj);
|
|
38
|
+
Object.keys(clone).forEach(key => {
|
|
39
|
+
let findMac = filesChanged.find(z => z.filename === key || z.filename === level + key);
|
|
40
|
+
if (typeof obj[key] === "object" && Object.keys(obj[key]).length) {
|
|
41
|
+
level += key + "/";
|
|
42
|
+
clone[key] = deepClone(obj[key]);
|
|
43
|
+
} else if (findMac) {
|
|
44
|
+
let stat = findMac.status === undefined ? "Deleted" : findMac.status;
|
|
45
|
+
stat = stat.replace(/\x1B[[(?);]{0,2}(;?\d)*./g, "");
|
|
46
|
+
clone[key] = stat;
|
|
47
|
+
} else {
|
|
48
|
+
clone[key] = "";
|
|
49
|
+
}
|
|
50
|
+
return clone[key];
|
|
51
|
+
});
|
|
52
|
+
return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone;
|
|
53
|
+
};
|
|
54
|
+
output = deepClone(output);
|
|
55
|
+
|
|
56
|
+
// jclrz(output);
|
|
57
|
+
//
|
|
58
|
+
return output;
|
|
59
|
+
};
|
|
60
|
+
import sgfPkg from "staged-git-files";
|
|
61
|
+
const sgf = sgfPkg.default || sgfPkg;
|
|
62
|
+
const seeChangedFiles = async () => {
|
|
63
|
+
const results = await sgf();
|
|
64
|
+
let updatedFiles = await ggg({
|
|
65
|
+
diffFilter: "ACDMRTUXB",
|
|
66
|
+
showStatus: true,
|
|
67
|
+
showCommitted: false
|
|
68
|
+
});
|
|
69
|
+
updatedFiles = [...updatedFiles.unCommittedFiles, ...results];
|
|
70
|
+
console.log(tree(grouped(updatedFiles.map(e => e.filename).sort(), updatedFiles), {
|
|
71
|
+
symbol: true,
|
|
72
|
+
highlight: true,
|
|
73
|
+
padding: 1,
|
|
74
|
+
colors: {
|
|
75
|
+
string: "black",
|
|
76
|
+
number: "red",
|
|
77
|
+
boolean: "red",
|
|
78
|
+
infinity: "red",
|
|
79
|
+
nan: "red",
|
|
80
|
+
null: "cyan",
|
|
81
|
+
undefined: "gray",
|
|
82
|
+
regexp: "green",
|
|
83
|
+
key: "black",
|
|
84
|
+
object: "grey",
|
|
85
|
+
array: "red"
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
export default seeChangedFiles;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import sortObjectKeys from "sort-object-keys";
|
|
2
|
+
import detectIndentPkg from "detect-indent";
|
|
3
|
+
const detectIndent = detectIndentPkg.default || detectIndentPkg;
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const sortOrder = ["name", "version", "description", "keywords", "sideEffects", "main", "umd:main", "unpkg", "module", "workspaces", "scripts", "betterScripts", "fscripts", "source", "jsnext:main", "browser", "homepage", "bugs", "repository", "private", "license", "author", "contributors", "files", "types", "typings", "style", "example", "examplestyle", "assets", "bin", "man", "directories", "husky", "pre-commit", "commitlint", "lint-staged", "config", "nodemonConfig", "browserify", "babel", "browserslist", "xo", "prettier", "eslintConfig", "eslintIgnore", "stylelint", "jest", "dependencies", "devDependencies", "peerDependencies", "bundledDependencies", "bundleDependencies", "optionalDependencies", "flat", "resolutions", "engines", "engineStrict", "os", "cpu", "preferGlobal", "publishConfig"];
|
|
10
|
+
// See https://docs.npmjs.com/misc/scripts
|
|
11
|
+
const defaultNpmScripts = ["install", "pack", "prepare", "publish", "restart", "shrinkwrap", "start", "stop", "test", "uninstall", "version"];
|
|
12
|
+
function sortPackageJson(packageJson, options = {}) {
|
|
13
|
+
const determinedSortOrder = options.sortOrder || sortOrder;
|
|
14
|
+
let wasString = false;
|
|
15
|
+
let hasWindowsNewlines = false;
|
|
16
|
+
let endCharacters = "";
|
|
17
|
+
let indentLevel = 2;
|
|
18
|
+
if (typeof packageJson === "string") {
|
|
19
|
+
wasString = true;
|
|
20
|
+
indentLevel = detectIndent(packageJson).indent;
|
|
21
|
+
if (packageJson.substr(-1) === "\n") {
|
|
22
|
+
endCharacters = "\n";
|
|
23
|
+
}
|
|
24
|
+
const newlineMatch = packageJson.match(/(\r?\n)/);
|
|
25
|
+
hasWindowsNewlines = (newlineMatch && newlineMatch[0]) === "\r\n";
|
|
26
|
+
packageJson = JSON.parse(packageJson);
|
|
27
|
+
}
|
|
28
|
+
const prefixedScriptRegex = /^(pre|post)(.)/;
|
|
29
|
+
const prefixableScripts = defaultNpmScripts.slice();
|
|
30
|
+
if (typeof packageJson.scripts === "object") {
|
|
31
|
+
Object.keys(packageJson.scripts).forEach(script => {
|
|
32
|
+
const prefixOmitted = script.replace(prefixedScriptRegex, "$2");
|
|
33
|
+
if (packageJson.scripts[prefixOmitted] && !prefixableScripts.includes(prefixOmitted)) {
|
|
34
|
+
prefixableScripts.push(prefixOmitted);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function sortSubKey(key, sortList, unique) {
|
|
39
|
+
if (Array.isArray(packageJson[key])) {
|
|
40
|
+
packageJson[key] = packageJson[key].sort();
|
|
41
|
+
if (unique) {
|
|
42
|
+
packageJson[key] = array_unique(packageJson[key]);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (typeof packageJson[key] === "object") {
|
|
47
|
+
packageJson[key] = sortObjectKeys(packageJson[key], sortList);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function toSortKey(script) {
|
|
51
|
+
const prefixOmitted = script.replace(prefixedScriptRegex, "$2");
|
|
52
|
+
if (prefixableScripts.includes(prefixOmitted)) {
|
|
53
|
+
return prefixOmitted;
|
|
54
|
+
}
|
|
55
|
+
return script;
|
|
56
|
+
}
|
|
57
|
+
/* b
|
|
58
|
+
* pre | * | post
|
|
59
|
+
* pre 0 | - | -
|
|
60
|
+
* a * + | 0 | -
|
|
61
|
+
* post + | + | 0
|
|
62
|
+
*/
|
|
63
|
+
function compareScriptKeys(a, b) {
|
|
64
|
+
if (a === b) return 0;
|
|
65
|
+
const aScript = toSortKey(a);
|
|
66
|
+
const bScript = toSortKey(b);
|
|
67
|
+
if (aScript === bScript) {
|
|
68
|
+
// pre* is always smaller; post* is always bigger
|
|
69
|
+
// Covers: pre* vs. *; pre* vs. post*; * vs. post*
|
|
70
|
+
if (a === `pre${aScript}` || b === `post${bScript}`) return -1;
|
|
71
|
+
// The rest is bigger: * vs. *pre; *post vs. *pre; *post vs. *
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
return aScript < bScript ? -1 : 1;
|
|
75
|
+
}
|
|
76
|
+
function array_unique(array) {
|
|
77
|
+
return array.filter((el, index, arr) => index == arr.indexOf(el));
|
|
78
|
+
}
|
|
79
|
+
sortSubKey("keywords", null, true);
|
|
80
|
+
sortSubKey("homepage");
|
|
81
|
+
sortSubKey("bugs", ["url", "email"]);
|
|
82
|
+
sortSubKey("license", ["type", "url"]);
|
|
83
|
+
sortSubKey("author", ["name", "email", "url"]);
|
|
84
|
+
sortSubKey("bin");
|
|
85
|
+
sortSubKey("man");
|
|
86
|
+
sortSubKey("directories", ["lib", "bin", "man", "doc", "example"]);
|
|
87
|
+
sortSubKey("repository", ["type", "url"]);
|
|
88
|
+
sortSubKey("scripts", compareScriptKeys);
|
|
89
|
+
sortSubKey("betterScripts", compareScriptKeys);
|
|
90
|
+
sortSubKey("commitlint");
|
|
91
|
+
sortSubKey("lint-staged");
|
|
92
|
+
sortSubKey("config");
|
|
93
|
+
sortSubKey("nodemonConfig");
|
|
94
|
+
sortSubKey("browserify");
|
|
95
|
+
sortSubKey("babel");
|
|
96
|
+
sortSubKey("eslintConfig");
|
|
97
|
+
sortSubKey("jest");
|
|
98
|
+
sortSubKey("xo");
|
|
99
|
+
sortSubKey("prettier");
|
|
100
|
+
sortSubKey("dependencies");
|
|
101
|
+
sortSubKey("devDependencies");
|
|
102
|
+
sortSubKey("peerDependencies");
|
|
103
|
+
sortSubKey("bundledDependencies");
|
|
104
|
+
sortSubKey("bundleDependencies");
|
|
105
|
+
sortSubKey("optionalDependencies");
|
|
106
|
+
sortSubKey("resolutions");
|
|
107
|
+
sortSubKey("engines");
|
|
108
|
+
sortSubKey("engineStrict");
|
|
109
|
+
sortSubKey("os");
|
|
110
|
+
sortSubKey("cpu");
|
|
111
|
+
sortSubKey("preferGlobal");
|
|
112
|
+
sortSubKey("private");
|
|
113
|
+
sortSubKey("publishConfig");
|
|
114
|
+
packageJson = sortObjectKeys(packageJson, determinedSortOrder);
|
|
115
|
+
if (wasString) {
|
|
116
|
+
let result = JSON.stringify(packageJson, null, indentLevel) + endCharacters;
|
|
117
|
+
if (hasWindowsNewlines) {
|
|
118
|
+
result = result.replace(/\n/g, "\r\n");
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
return packageJson;
|
|
123
|
+
}
|
|
124
|
+
export default sortPackageJson;
|
|
125
|
+
export { sortPackageJson, sortOrder };
|
|
126
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
127
|
+
const filesToProcess = process.argv[2] ? process.argv.slice(2) : [`${process.cwd()}/package.json`];
|
|
128
|
+
filesToProcess.forEach(filePath => {
|
|
129
|
+
const packageJson = fs.readFileSync(filePath, "utf8");
|
|
130
|
+
const sorted = sortPackageJson(packageJson);
|
|
131
|
+
if (sorted !== packageJson) {
|
|
132
|
+
fs.writeFileSync(filePath, sorted, "utf8");
|
|
133
|
+
console.log(`${filePath} is sorted!`);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
function isFunction(f) {
|
|
3
|
+
return Object.prototype.toString.call(f) === "[object Function]";
|
|
4
|
+
}
|
|
5
|
+
function isRegExp(r) {
|
|
6
|
+
return r instanceof RegExp;
|
|
7
|
+
}
|
|
8
|
+
function isObject(o) {
|
|
9
|
+
return !Array.isArray(o) && !isFunction(o) && !isRegExp(o) && o === new Object(o);
|
|
10
|
+
}
|
|
11
|
+
let reColorName = /^(black|red|green|yellow|blue|magenta|cyan|white|gray)$/;
|
|
12
|
+
function coloring(str, color, type) {
|
|
13
|
+
str = str + "";
|
|
14
|
+
if (typeof color === "function") {
|
|
15
|
+
return color(str);
|
|
16
|
+
} else if (reColorName.test(color)) {
|
|
17
|
+
if (type === "string") {
|
|
18
|
+
if (str === "Modified") {
|
|
19
|
+
return chalk.green(str);
|
|
20
|
+
} else if (str === "Deleted") {
|
|
21
|
+
return chalk.red(str);
|
|
22
|
+
} else {
|
|
23
|
+
return chalk.blue(str);
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
return chalk[color].bold.underline.white(str); //
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let defaultColors = {
|
|
33
|
+
string: "yellow",
|
|
34
|
+
number: "red",
|
|
35
|
+
boolean: "blue",
|
|
36
|
+
infinity: "red",
|
|
37
|
+
nan: "cyan",
|
|
38
|
+
null: "cyan",
|
|
39
|
+
undefined: "gray",
|
|
40
|
+
regexp: "green",
|
|
41
|
+
key: "magenta",
|
|
42
|
+
object: "white",
|
|
43
|
+
array: "white"
|
|
44
|
+
};
|
|
45
|
+
export default function (json, options) {
|
|
46
|
+
options = options || {};
|
|
47
|
+
if (options.symbol === undefined) {
|
|
48
|
+
options.symbol = true;
|
|
49
|
+
}
|
|
50
|
+
options.padding = options.padding || 0;
|
|
51
|
+
options.markdown = options.markdown || false;
|
|
52
|
+
options.highlight = options.highlight || false;
|
|
53
|
+
options.colors = options.colors || {};
|
|
54
|
+
Object.keys(defaultColors).forEach(function (key) {
|
|
55
|
+
options.colors[key] = options.colors[key] || defaultColors[key];
|
|
56
|
+
});
|
|
57
|
+
let output = "";
|
|
58
|
+
let tree = function (o, depth, index, isLast, inArray, type) {
|
|
59
|
+
index = [].concat(index || []);
|
|
60
|
+
depth = depth || 0;
|
|
61
|
+
index[depth] = 0;
|
|
62
|
+
if (Array.isArray(o)) {
|
|
63
|
+
if (inArray) {
|
|
64
|
+
if (options.symbol) {
|
|
65
|
+
tree("[]", depth, index, isLast, 0, "array");
|
|
66
|
+
index[depth] = isLast ? 0 : 1;
|
|
67
|
+
} else {
|
|
68
|
+
depth--;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (let i = 0, l = o.length; i < l; i++) {
|
|
72
|
+
tree(o[i], depth + 1, index, i === l - 1, 1);
|
|
73
|
+
}
|
|
74
|
+
} else if (isObject(o)) {
|
|
75
|
+
let keys = Object.keys(o);
|
|
76
|
+
if (inArray) {
|
|
77
|
+
// if (options.symbol) {
|
|
78
|
+
// tree("", depth, index, isLast, 0, "object");
|
|
79
|
+
index[depth] = isLast ? 0 : 1;
|
|
80
|
+
depth++;
|
|
81
|
+
// }
|
|
82
|
+
}
|
|
83
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
84
|
+
let lastFlg = inArray && !isLast && !options.symbol ? false : i === l - 1;
|
|
85
|
+
tree(keys[i], depth, index, lastFlg, 0, "key");
|
|
86
|
+
index[depth] = lastFlg ? 0 : 1;
|
|
87
|
+
tree(o[keys[i]], depth + 1, index, 1, 1);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
index[depth] = isLast ? 3 : 2;
|
|
91
|
+
if (isFunction(o)) {
|
|
92
|
+
o = "Function";
|
|
93
|
+
type = "function";
|
|
94
|
+
}
|
|
95
|
+
if (options.markdown) {
|
|
96
|
+
output += markdownList(depth) + o + "\n";
|
|
97
|
+
} else {
|
|
98
|
+
output += format(index) + highlight(o, type) + "\n";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
let format = function (index) {
|
|
103
|
+
let s = "";
|
|
104
|
+
let p = new Array(options.padding + 1).join(" ");
|
|
105
|
+
for (let i = 0, l = index.length; i < l; i++) {
|
|
106
|
+
switch (index[i]) {
|
|
107
|
+
case 1:
|
|
108
|
+
s += chalk.grey("┃");
|
|
109
|
+
break;
|
|
110
|
+
case 2:
|
|
111
|
+
s += chalk.grey("┣ ");
|
|
112
|
+
break;
|
|
113
|
+
case 3:
|
|
114
|
+
s += chalk.grey("┗");
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
s += chalk.grey("⌐");
|
|
118
|
+
}
|
|
119
|
+
if (i < l - 1) {
|
|
120
|
+
s += chalk.grey(p);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return s;
|
|
124
|
+
};
|
|
125
|
+
let markdownList = function (depth) {
|
|
126
|
+
return new Array(depth + 1).join(" ") + "+ ";
|
|
127
|
+
};
|
|
128
|
+
let highlight = function (data, type) {
|
|
129
|
+
let hi;
|
|
130
|
+
if (!options.highlight) {
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
if (type === "key") {
|
|
134
|
+
hi = "key";
|
|
135
|
+
} else if (type === "array") {
|
|
136
|
+
hi = "array";
|
|
137
|
+
} else if (type === "object") {
|
|
138
|
+
hi = "object";
|
|
139
|
+
} else if (data !== data) {
|
|
140
|
+
hi = "nan";
|
|
141
|
+
} else if (data === Infinity) {
|
|
142
|
+
hi = "infinity";
|
|
143
|
+
} else if (typeof data === "string") {
|
|
144
|
+
hi = "string";
|
|
145
|
+
} else if (typeof data === "number") {
|
|
146
|
+
hi = "number";
|
|
147
|
+
} else if (isRegExp(data)) {
|
|
148
|
+
hi = "regexp";
|
|
149
|
+
} else if (typeof data === "boolean") {
|
|
150
|
+
hi = "boolean";
|
|
151
|
+
} else if (data === null) {
|
|
152
|
+
hi = "null";
|
|
153
|
+
} else if (data === void 0) {
|
|
154
|
+
hi = "undefined";
|
|
155
|
+
} else {
|
|
156
|
+
return data;
|
|
157
|
+
}
|
|
158
|
+
return coloring(data, options.colors[hi], hi);
|
|
159
|
+
};
|
|
160
|
+
tree(json);
|
|
161
|
+
return output;
|
|
162
|
+
}
|
|
163
|
+
;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import boxen from "boxen";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
import { boxInform } from "../utils/helpers.js";
|
|
9
|
+
import git from "git-state";
|
|
10
|
+
import simple from "simple-git";
|
|
11
|
+
const pathToCwd = process.cwd();
|
|
12
|
+
const newBranch = async name => {
|
|
13
|
+
// const last = await new Promise(rzz => {
|
|
14
|
+
// git.isGit(pathToCwd, function(exists) {
|
|
15
|
+
// if (!exists) return;
|
|
16
|
+
//
|
|
17
|
+
// git.commit(pathToCwd, function(err, result) {
|
|
18
|
+
// if (err) throw err;
|
|
19
|
+
// rzz(result);
|
|
20
|
+
// });
|
|
21
|
+
// });
|
|
22
|
+
// });
|
|
23
|
+
|
|
24
|
+
// await simple().checkoutLocalBranch(name);
|
|
25
|
+
await simple().checkoutBranch(name, "origin/Development");
|
|
26
|
+
boxInform(chalk.green(`New branch ${name} created`, "", 5));
|
|
27
|
+
};
|
|
28
|
+
async function pub() {
|
|
29
|
+
return new Promise(resolve => {
|
|
30
|
+
inquirer.prompt([{
|
|
31
|
+
type: "input",
|
|
32
|
+
message: chalk.bold.hex("#38be18")(`Name new feature branch (or type cancel):`),
|
|
33
|
+
name: "branchname"
|
|
34
|
+
}]).then(async ({
|
|
35
|
+
branchname
|
|
36
|
+
}) => {
|
|
37
|
+
if (branchname !== "Development") await newBranch(branchname);
|
|
38
|
+
resolve();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const validateNotInDev = async () => {
|
|
43
|
+
await new Promise(async resolve => {
|
|
44
|
+
const {
|
|
45
|
+
default: git
|
|
46
|
+
} = await import("simple-git/promise");
|
|
47
|
+
let statusSummary = await git(__dirname).status();
|
|
48
|
+
if (statusSummary.current === "Development") {
|
|
49
|
+
console.clear();
|
|
50
|
+
console.log(boxen(chalk.bold.underline.red("DO NO MAKE CHANGES IN DEV!"), {
|
|
51
|
+
padding: 2
|
|
52
|
+
}));
|
|
53
|
+
await new Promise(resolve1 => setTimeout(() => {
|
|
54
|
+
resolve1();
|
|
55
|
+
}, 1000));
|
|
56
|
+
await pub();
|
|
57
|
+
resolve();
|
|
58
|
+
} else {
|
|
59
|
+
resolve();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export default validateNotInDev;
|