Comparing version 0.0.1 to 0.0.2
@@ -1,27 +0,76 @@ | ||
import { Project } from "@lerna/project"; | ||
import { Package } from "@lerna/package"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lernaUpdate = exports.getPackages = exports.getRootPackage = exports.getProject = void 0; | ||
const project_1 = require("@lerna/project"); | ||
const package_1 = require("@lerna/package"); | ||
const exec = require('sync-exec'); | ||
const { updateLockfileVersion } = require("@lerna/version/lib/update-lockfile-version"); | ||
let project; | ||
let rootPackage; | ||
let packages; | ||
export function getRootPackage() { | ||
function syncExec(command) { | ||
const result = exec(command); | ||
if (result.stderr) { | ||
console.error(result.stderr); | ||
} | ||
else if (result.stdout) { | ||
console.log(result.stdout); | ||
} | ||
} | ||
function getProject() { | ||
if (!project) { | ||
project = new project_1.Project(); | ||
} | ||
return project; | ||
} | ||
exports.getProject = getProject; | ||
function getRootPackage() { | ||
if (!rootPackage) { | ||
rootPackage = Package.lazy("./"); | ||
rootPackage = package_1.Package.lazy("./"); | ||
} | ||
return rootPackage; | ||
} | ||
export function getPackages() { | ||
exports.getRootPackage = getRootPackage; | ||
function getPackages() { | ||
if (!packages) { | ||
packages = new Project().getPackagesSync(); | ||
packages = getProject().getPackagesSync(); | ||
} | ||
return packages; | ||
} | ||
exports.getPackages = getPackages; | ||
; | ||
export function lernaUpdate() { | ||
function lernaUpdate() { | ||
const useWorkspaces = getProject().config.useWorkspaces; | ||
getPackages().forEach(async (pkg) => { | ||
console.log(pkg.dependencies); | ||
console.log(pkg.devDependencies); | ||
await pkg.serialize(); | ||
await updateLockfileVersion(pkg); | ||
const dependencies = pkg.dependencies || {}; | ||
const devDependencies = pkg.devDependencies || {}; | ||
const updatedDependencies = []; | ||
const updatedDevDependencies = []; | ||
Object.keys(dependencies).forEach(moduleName => { | ||
if (moduleName.startsWith("@cfcs/")) { | ||
updatedDependencies.push(moduleName); | ||
} | ||
}); | ||
Object.keys(devDependencies).forEach(moduleName => { | ||
if (moduleName.startsWith("@cfcs/")) { | ||
updatedDevDependencies.push(moduleName); | ||
} | ||
}); | ||
const moduleArgs = updatedDependencies.map(name => { | ||
return `${name}@latest`; | ||
}).join(" "); | ||
const devModuleArgs = updatedDevDependencies.map(name => { | ||
return `${name}@latest`; | ||
}).join(" "); | ||
if (useWorkspaces) { | ||
syncExec(`yarn workspace ${pkg.name} add ${moduleArgs}`); | ||
syncExec(`yarn workspace ${pkg.name} add ${devModuleArgs} -D`); | ||
} | ||
else { | ||
syncExec(`npm i ${moduleArgs} --prefix ${pkg.location}`); | ||
syncExec(`npm i ${devModuleArgs} -D --prefix ${pkg.location}`); | ||
} | ||
}); | ||
} | ||
exports.lernaUpdate = lernaUpdate; | ||
//# sourceMappingURL=lerna.js.map |
18
index.js
@@ -0,1 +1,19 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
const { program } = require('commander'); | ||
// cfcs lerna update | ||
program | ||
.command("lerna", "") | ||
.argument('<service>', 'Lerna를 위한 CFCs 서비스(테스트)') | ||
.action(service => { | ||
import("./dist/").then(() => { | ||
}) | ||
}); | ||
program.parse(); |
{ | ||
"name": "@cfcs/cli", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Cross Framework Components CLI", | ||
@@ -45,4 +45,5 @@ "main": "dist/cli.cjs.js", | ||
"dependencies": { | ||
"commander": "^9.4.1" | ||
"commander": "^9.4.1", | ||
"sync-exec": "^0.6.2" | ||
} | ||
} |
import { Project } from "@lerna/project"; | ||
import { Package } from "@lerna/package"; | ||
const exec = require('sync-exec'); | ||
const { updateLockfileVersion } = require("@lerna/version/lib/update-lockfile-version"); | ||
let project!: Project; | ||
let rootPackage!: Package; | ||
let packages!: Package[]; | ||
function syncExec(command: string) { | ||
const result = exec(command); | ||
if (result.stderr) { | ||
console.error(result.stderr); | ||
} else if (result.stdout) { | ||
console.log(result.stdout); | ||
} | ||
} | ||
export function getProject() { | ||
if (!project) { | ||
project = new Project(); | ||
} | ||
return project; | ||
} | ||
export function getRootPackage() { | ||
@@ -17,3 +36,3 @@ if (!rootPackage) { | ||
if (!packages) { | ||
packages = new Project().getPackagesSync(); | ||
packages = getProject().getPackagesSync(); | ||
} | ||
@@ -24,8 +43,35 @@ return packages; | ||
export function lernaUpdate() { | ||
const useWorkspaces = getProject().config.useWorkspaces; | ||
getPackages().forEach(async pkg => { | ||
console.log(pkg.dependencies); | ||
console.log(pkg.devDependencies); | ||
await pkg.serialize(); | ||
await updateLockfileVersion(pkg); | ||
}) | ||
const dependencies = pkg.dependencies || {}; | ||
const devDependencies = pkg.devDependencies || {}; | ||
const updatedDependencies: string[] = []; | ||
const updatedDevDependencies: string[] = []; | ||
Object.keys(dependencies).forEach(moduleName => { | ||
if (moduleName.startsWith("@cfcs/")) { | ||
updatedDependencies.push(moduleName); | ||
} | ||
}); | ||
Object.keys(devDependencies).forEach(moduleName => { | ||
if (moduleName.startsWith("@cfcs/")) { | ||
updatedDevDependencies.push(moduleName); | ||
} | ||
}); | ||
const moduleArgs = updatedDependencies.map(name => { | ||
return `${name}@latest`; | ||
}).join(" "); | ||
const devModuleArgs = updatedDevDependencies.map(name => { | ||
return `${name}@latest`; | ||
}).join(" "); | ||
if (useWorkspaces) { | ||
syncExec(`yarn workspace ${pkg.name} add ${moduleArgs}`); | ||
syncExec(`yarn workspace ${pkg.name} add ${devModuleArgs} -D`); | ||
} else { | ||
syncExec(`npm i ${moduleArgs} --prefix ${pkg.location}`); | ||
syncExec(`npm i ${devModuleArgs} -D --prefix ${pkg.location}`); | ||
} | ||
}); | ||
} |
@@ -16,3 +16,3 @@ { | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "esnext", | ||
"module": "CommonJS", | ||
"moduleResolution": "node", | ||
@@ -19,0 +19,0 @@ "resolveJsonModule": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
779184
193
2
+ Addedsync-exec@^0.6.2
+ Addedsync-exec@0.6.2(transitive)