arylo-init
Advanced tools
Comparing version 2.1.13 to 2.1.14
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const constants = require("../constants"); | ||
const json_1 = require("../utils/json"); | ||
const pkg_1 = require("../utils/pkg"); | ||
@@ -12,3 +12,4 @@ exports.UPDATE_LIST = [".huskyrc.json", "package.json"]; | ||
case 1: | ||
new json_1.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((data) => { | ||
@@ -15,0 +16,0 @@ data.hooks["commit-msg"] = |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const constants = require("../constants"); | ||
const yaml_1 = require("../utils/yaml"); | ||
exports.UPDATE_LIST = [".travis.yml"]; | ||
exports.update = (filePoint) => { | ||
const filePath = path.resolve(constants.targetPath, filePoint); | ||
new yaml_1.Yaml(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((data) => { | ||
@@ -11,0 +12,0 @@ data.node_js.push("10"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path_1 = require("path"); | ||
const constants = require("../constants"); | ||
const json_1 = require("../utils/json"); | ||
exports.UPDATE_LIST = ["package.json", "tsconfig.json"]; | ||
@@ -12,3 +12,4 @@ exports.update = (filePoint) => { | ||
const filePath = path_1.resolve(constants.targetPath, filePoint); | ||
new json_1.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((data) => { | ||
@@ -15,0 +16,0 @@ switch (exports.UPDATE_LIST.indexOf(filePoint) + 1) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const constants = require("../constants"); | ||
const json = require("../utils/json"); | ||
const json_1 = require("../utils/json"); | ||
const pkg_1 = require("../utils/pkg"); | ||
@@ -27,3 +26,4 @@ exports.UPDATE_LIST = [ | ||
case 2: | ||
new json_1.Json(filePath) | ||
ftconfig | ||
.readFile(filePath, { type: "json" }) | ||
.modify((data) => { | ||
@@ -55,3 +55,4 @@ for (const key of Object.keys(data.linters)) { | ||
case 3: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -64,3 +65,4 @@ obj.include.push("test/**/*"); | ||
case 4: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -77,3 +79,4 @@ obj.compilerOptions.declarationMap = false; | ||
case 5: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -80,0 +83,0 @@ delete obj.include; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const constants = require("../constants"); | ||
const json_1 = require("../utils/json"); | ||
exports.UPDATE_LIST = [".huskyrc.json"]; | ||
exports.update = (filePoint) => { | ||
const filePath = path.resolve(constants.targetPath, filePoint); | ||
new json_1.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -11,0 +12,0 @@ obj.hooks["pre-merge"] = "lint-staged"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const constants = require("../constants"); | ||
const pkg_1 = require("../utils/pkg"); | ||
const json_1 = require("./../utils/json"); | ||
exports.ADD_LIST = [".eslintignore"]; | ||
@@ -13,3 +13,5 @@ exports.UPDATE_LIST = [".lintstagedrc", "package.json"]; | ||
case 1: | ||
const json = new json_1.Json(filePath); | ||
const json = ftconfig.readFile(filePath, { | ||
type: "json" | ||
}); | ||
for (const key of Object.keys(json.toObject().linters)) { | ||
@@ -16,0 +18,0 @@ if (/\.editorconfig$/.test(key)) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ftconfig = require("ftconfig"); | ||
const path = require("path"); | ||
const json_1 = require("./json"); | ||
class Pkg extends json_1.Json { | ||
class Pkg { | ||
constructor(p) { | ||
super(path.resolve(p.toString(), "package.json")); | ||
const filepath = path.resolve(p.toString(), "package.json"); | ||
this.config = ftconfig.readFile(filepath, { type: "json" }); | ||
} | ||
save() { | ||
this.config.save(); | ||
return this; | ||
} | ||
modify(fn) { | ||
this.config.modify(fn); | ||
return this; | ||
} | ||
toObject() { | ||
return this.config.toObject(); | ||
} | ||
getSaveDependency(name) { | ||
return this.object.dependencies[name]; | ||
return this.toObject().dependencies[name]; | ||
} | ||
updateSaveDependency(name, version) { | ||
this.object.dependencies[name] = version; | ||
this.config.modify((obj) => { | ||
obj.dependencies[name] = version; | ||
return obj; | ||
}); | ||
return this; | ||
@@ -20,4 +35,7 @@ } | ||
deleteSaveDependencies(...names) { | ||
names.forEach((name) => { | ||
delete this.object.dependencies[name]; | ||
this.config.modify((object) => { | ||
names.forEach((name) => { | ||
delete object.dependencies[name]; | ||
}); | ||
return object; | ||
}); | ||
@@ -27,6 +45,9 @@ return this; | ||
getDevDependency(name) { | ||
return this.object.devDependencies[name]; | ||
return this.toObject().devDependencies[name]; | ||
} | ||
updateDevDependency(name, version) { | ||
this.object.devDependencies[name] = version; | ||
this.config.modify((object) => { | ||
object.devDependencies[name] = version; | ||
return object; | ||
}); | ||
return this; | ||
@@ -38,4 +59,7 @@ } | ||
deleteDevDependencies(...names) { | ||
names.forEach((name) => { | ||
delete this.object.devDependencies[name]; | ||
this.config.modify((object) => { | ||
names.forEach((name) => { | ||
delete object.devDependencies[name]; | ||
}); | ||
return object; | ||
}); | ||
@@ -45,11 +69,14 @@ return this; | ||
getScript(action) { | ||
return this.object.scripts[action]; | ||
return this.toObject().scripts[action]; | ||
} | ||
updateScript(action, command) { | ||
if (command) { | ||
this.object.scripts[action] = command; | ||
} | ||
else { | ||
delete this.object.scripts[action]; | ||
} | ||
this.config.modify((object) => { | ||
if (command) { | ||
object.scripts[action] = command; | ||
} | ||
else { | ||
delete object.scripts[action]; | ||
} | ||
return object; | ||
}); | ||
return this; | ||
@@ -61,4 +88,7 @@ } | ||
deleteScripts(...actions) { | ||
actions.forEach((action) => { | ||
delete this.object.scripts[action]; | ||
this.config.modify((object) => { | ||
actions.forEach((action) => { | ||
delete object.scripts[action]; | ||
}); | ||
return object; | ||
}); | ||
@@ -65,0 +95,0 @@ return this; |
@@ -0,4 +1,4 @@ | ||
import ftconfig = require("ftconfig"); | ||
import * as path from "path"; | ||
import constants = require("../constants"); | ||
import { Json } from "../utils/json"; | ||
import { Pkg } from "../utils/pkg"; | ||
@@ -13,3 +13,4 @@ | ||
case 1: | ||
new Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((data) => { | ||
@@ -16,0 +17,0 @@ data.hooks["commit-msg"] = |
@@ -0,4 +1,4 @@ | ||
import ftconfig = require("ftconfig"); | ||
import * as path from "path"; | ||
import constants = require("../constants"); | ||
import { Yaml } from "../utils/yaml"; | ||
import { ITravis } from "../utils/yaml.d"; | ||
@@ -11,3 +11,4 @@ | ||
new Yaml<ITravis>(filePath) | ||
ftconfig | ||
.readFile<ITravis>(filePath) | ||
.modify((data) => { | ||
@@ -14,0 +15,0 @@ data.node_js.push("10"); |
@@ -0,4 +1,4 @@ | ||
import ftconfig = require("ftconfig"); | ||
import { resolve } from "path"; | ||
import constants = require("../constants"); | ||
import { Json } from "../utils/json"; | ||
@@ -14,3 +14,4 @@ export const UPDATE_LIST = ["package.json", "tsconfig.json"]; | ||
new Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((data) => { | ||
@@ -17,0 +18,0 @@ switch (UPDATE_LIST.indexOf(filePoint) + 1) { |
@@ -0,5 +1,4 @@ | ||
import ftconfig = require("ftconfig"); | ||
import * as path from "path"; | ||
import constants = require("../constants"); | ||
import * as json from "../utils/json"; | ||
import { Json } from "../utils/json"; | ||
import { ILintstagedrc } from "../utils/json.d"; | ||
@@ -29,3 +28,4 @@ import { Pkg } from "../utils/pkg"; | ||
case 2: | ||
new Json<ILintstagedrc>(filePath) | ||
ftconfig | ||
.readFile<ILintstagedrc>(filePath, { type: "json" }) | ||
.modify((data) => { | ||
@@ -57,3 +57,4 @@ for (const key of Object.keys(data.linters)) { | ||
case 3: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -66,3 +67,4 @@ obj.include.push("test/**/*"); | ||
case 4: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -79,3 +81,4 @@ obj.compilerOptions.declarationMap = false; | ||
case 5: | ||
new json.Json(filePath) | ||
ftconfig | ||
.readFile(filePath) | ||
.modify((obj) => { | ||
@@ -82,0 +85,0 @@ delete obj.include; |
@@ -0,4 +1,4 @@ | ||
import ftconfig = require("ftconfig"); | ||
import * as path from "path"; | ||
import constants = require("../constants"); | ||
import { Json } from "../utils/json"; | ||
import { IHuskyrc } from "../utils/json.d"; | ||
@@ -11,3 +11,4 @@ | ||
new Json<IHuskyrc>(filePath) | ||
ftconfig | ||
.readFile<IHuskyrc>(filePath) | ||
.modify((obj) => { | ||
@@ -14,0 +15,0 @@ obj.hooks["pre-merge"] = "lint-staged"; |
@@ -0,1 +1,2 @@ | ||
import ftconfig = require("ftconfig"); | ||
import * as path from "path"; | ||
@@ -5,3 +6,2 @@ import constants = require("../constants"); | ||
import { Pkg } from "../utils/pkg"; | ||
import { Json } from "./../utils/json"; | ||
@@ -17,3 +17,5 @@ export const ADD_LIST = [".eslintignore"]; | ||
case 1: | ||
const json = new Json<ILintstagedrc>(filePath); | ||
const json = ftconfig.readFile<ILintstagedrc>(filePath, { | ||
type: "json" | ||
}); | ||
@@ -20,0 +22,0 @@ for (const key of Object.keys(json.toObject().linters)) { |
import * as fs from "fs"; | ||
import * as ftconfig from "ftconfig"; | ||
import { WriteConfig } from "ftconfig/lib/WriteConfig"; | ||
import * as path from "path"; | ||
import { Json } from "./json"; | ||
import { IPackage } from "./json.d"; | ||
export class Pkg extends Json<IPackage> { | ||
export class Pkg { | ||
private config: WriteConfig<IPackage>; | ||
constructor(p: fs.PathLike) { | ||
super(path.resolve(p.toString(), "package.json")); | ||
const filepath = path.resolve(p.toString(), "package.json"); | ||
this.config = ftconfig.readFile<IPackage>(filepath, { type: "json" }); | ||
} | ||
public save() { | ||
this.config.save(); | ||
return this; | ||
} | ||
public modify(fn: (obj: IPackage) => IPackage) { | ||
this.config.modify(fn); | ||
return this; | ||
} | ||
public toObject() { | ||
return this.config.toObject(); | ||
} | ||
public getSaveDependency(name: string) { | ||
return this.object.dependencies[name]; | ||
return this.toObject().dependencies[name]; | ||
} | ||
public updateSaveDependency(name: string, version: string) { | ||
this.object.dependencies[name] = version; | ||
this.config.modify((obj) => { | ||
obj.dependencies[name] = version; | ||
return obj; | ||
}); | ||
return this; | ||
@@ -25,4 +46,7 @@ } | ||
public deleteSaveDependencies(...names: string[]) { | ||
names.forEach((name) => { | ||
delete this.object.dependencies[name]; | ||
this.config.modify((object) => { | ||
names.forEach((name) => { | ||
delete object.dependencies[name]; | ||
}); | ||
return object; | ||
}); | ||
@@ -33,7 +57,10 @@ return this; | ||
public getDevDependency(name: string) { | ||
return this.object.devDependencies[name]; | ||
return this.toObject().devDependencies[name]; | ||
} | ||
public updateDevDependency(name: string, version: string) { | ||
this.object.devDependencies[name] = version; | ||
this.config.modify((object) => { | ||
object.devDependencies[name] = version; | ||
return object; | ||
}); | ||
return this; | ||
@@ -47,4 +74,7 @@ } | ||
public deleteDevDependencies(...names: string[]) { | ||
names.forEach((name) => { | ||
delete this.object.devDependencies[name]; | ||
this.config.modify((object) => { | ||
names.forEach((name) => { | ||
delete object.devDependencies[name]; | ||
}); | ||
return object; | ||
}); | ||
@@ -55,11 +85,14 @@ return this; | ||
public getScript(action: string) { | ||
return this.object.scripts[action]; | ||
return this.toObject().scripts[action]; | ||
} | ||
public updateScript(action: string, command?: string) { | ||
if (command) { | ||
this.object.scripts[action] = command; | ||
} else { | ||
delete this.object.scripts[action]; | ||
} | ||
this.config.modify((object) => { | ||
if (command) { | ||
object.scripts[action] = command; | ||
} else { | ||
delete object.scripts[action]; | ||
} | ||
return object; | ||
}); | ||
return this; | ||
@@ -73,4 +106,7 @@ } | ||
public deleteScripts(...actions: string[]) { | ||
actions.forEach((action) => { | ||
delete this.object.scripts[action]; | ||
this.config.modify((object) => { | ||
actions.forEach((action) => { | ||
delete object.scripts[action]; | ||
}); | ||
return object; | ||
}); | ||
@@ -77,0 +113,0 @@ return this; |
{ | ||
"name": "arylo-init", | ||
"version": "2.1.13", | ||
"version": "2.1.14", | ||
"description": "Initial Node.js Project for Arylo Edition", | ||
@@ -57,2 +57,3 @@ "main": "./dist/index.js", | ||
"chalk": "^2.4.1", | ||
"ftconfig": "^1.1.0", | ||
"js-yaml": "^3.12.0", | ||
@@ -59,0 +60,0 @@ "make-dir": "^1.3.0", |
10
71322
6
73
1749
+ Addedftconfig@^1.1.0
+ Added@iarna/toml@2.2.5(transitive)
+ Addedftconfig@1.1.8(transitive)
+ Addedhjson@3.2.2(transitive)
+ Addedjson5@2.2.3(transitive)