Comparing version 1.0.3 to 1.0.4
@@ -8,8 +8,13 @@ #!/usr/bin/env node | ||
const userHomeDir = os.homedir(); | ||
const dataDir = '.my-ci'; | ||
const configFileName = '.my-ci.yml' | ||
// 获取当前项目的根目录路径 | ||
const projectRootPath = path.resolve(); | ||
let projectName = ''; | ||
// 读取yml配置文件 | ||
try { | ||
const wsYmlPath = path.join(projectRootPath, '.easy-ci.yml'); | ||
const wsYmlPath = path.join(projectRootPath, configFileName); | ||
const ymlConfig = yaml.load(fs.readFileSync(wsYmlPath, 'utf8')); | ||
@@ -19,3 +24,4 @@ // console.log(doc); | ||
if (ymlConfig.project) { | ||
newWorkspace(ymlConfig.project); | ||
projectName = ymlConfig.project | ||
newWorkspace(projectName); | ||
} else { | ||
@@ -26,3 +32,5 @@ throw 'project属性不能为空'; | ||
if (err?.code === 'EEXIST') { | ||
console.error(`${ymlConfig.project}已存在,请在yml配置中设置一个不重复的project属性`); | ||
console.error(`${projectName}已存在,请在yml配置中设置一个不重复的project属性`); | ||
} else if (err?.code === 'ENOENT') { | ||
console.error(`没有找到配置文件: ${configFileName}`); | ||
} else { | ||
@@ -34,6 +42,19 @@ console.error('项目初始化失败: ', err); | ||
function newWorkspace(projectName) { | ||
const wsInfoPath = path.resolve(os.homedir(), '.easy-ci', projectName); | ||
// .my-ci文件夹不存在则先创建 | ||
try { | ||
fs.mkdirSync(path.resolve(userHomeDir, dataDir)); | ||
console.log(`工具初始化${dataDir}`); | ||
} catch(err) { | ||
if (err.code === 'EEXIST') { | ||
console.log('工具已初始化'); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
// workspace初始化 | ||
const wsInfoPath = path.resolve(os.homedir(), dataDir, projectName); | ||
fs.openSync(wsInfoPath, 'wx'); // 如果文件已经存在,会抛出错误 | ||
fs.writeFileSync(wsInfoPath, `PATH=${projectRootPath}`); | ||
console.log('File created successfully.'); | ||
console.log('my-ci project created successfully.'); | ||
} |
{ | ||
"name": "my-ci", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -23,5 +23,10 @@ "main": "index.js", | ||
"dependencies": { | ||
"@koa/cors": "^4.0.0", | ||
"arg": "^5.0.2", | ||
"ini": "^4.1.0", | ||
"js-yaml": "^4.1.0", | ||
"koa": "^2.14.2" | ||
"koa": "^2.14.2", | ||
"koa-bodyparser": "^4.4.0", | ||
"koa-router": "^12.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5928
9
144
7
2
+ Added@koa/cors@^4.0.0
+ Addedarg@^5.0.2
+ Addedini@^4.1.0
+ Addedkoa-bodyparser@^4.4.0
+ Addedkoa-router@^12.0.0
+ Added@hapi/bourne@3.0.0(transitive)
+ Added@koa/cors@4.0.0(transitive)
+ Addedarg@5.0.2(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedco-body@6.2.0(transitive)
+ Addedcopy-to@2.0.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflation@2.1.0(transitive)
+ Addedini@4.1.3(transitive)
+ Addedkoa-bodyparser@4.4.1(transitive)
+ Addedkoa-router@12.0.1(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpath-to-regexp@6.3.0(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedunpipe@1.0.0(transitive)