cli:update cli config

This commit is contained in:
pengfei.zhou 2020-01-07 14:03:07 +08:00 committed by osborn
parent 1ea382d8d5
commit 8fc72c95bc
12 changed files with 33 additions and 60 deletions

View File

@ -4,7 +4,12 @@ var program = require('commander');
program program
.command('create <name>') .command('create <name>')
.option('-n, --native', 'Native') .action(function (name, cmd) {
console.log('create ' + name + (cmd.native ? ' native' : 'js'))
require('./scripts/init')(name)
})
program
.command('new <name>')
.action(function (name, cmd) { .action(function (name, cmd) {
console.log('create ' + name + (cmd.native ? ' native' : 'js')) console.log('create ' + name + (cmd.native ? ' native' : 'js'))
require('./scripts/init')(name) require('./scripts/init')(name)

View File

@ -3,7 +3,7 @@ var path = require('path')
require('shelljs/global') require('shelljs/global')
const targetJSPath = `${__dirname}/../target/js` const targetJSPath = `${__dirname}/../target/`
const targetAndroidPath = `${__dirname}/../target/android` const targetAndroidPath = `${__dirname}/../target/android`
const targetiOSPath = `${__dirname}/../target/iOS` const targetiOSPath = `${__dirname}/../target/iOS`
@ -65,28 +65,19 @@ function copyFolder(srcDir, tarDir, cb) {
} }
function initJS(path, name) { function initJS(path, name) {
if (fs.existsSync(path)) { console.log(`create dir ${path} success`);
console.warn(`Dir:${process.cwd()}/${path} already exists`) fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString().replace(/__\$__/g, name))
return; fs.writeFileSync(`${path}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`))
} fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`))
fs.mkdir(path, function (err) { fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`))
if (err) { fs.mkdirSync(`${path}/.vscode`)
return console.error(err); fs.writeFileSync(`${path}/.vscode/launch.json`, fs.readFileSync(`${targetJSPath}/_launch.json`).toString().replace(/__\$__/g, name))
} fs.writeFileSync(`${path}/.vscode/tasks.json`, fs.readFileSync(`${targetJSPath}/_tasks.json`).toString().replace(/__\$__/g, name))
console.log(`create dir ${path} success`); fs.mkdirSync(`${path}/src`)
fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString().replace(/__\$__/g, name)) fs.writeFileSync(`${path}/src/${name}.ts`, fs.readFileSync(`${targetJSPath}/$.ts`).toString().replace(/__\$__/g, name))
fs.writeFileSync(`${path}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`)) fs.writeFileSync(`${path}/index.ts`, `export default ['src/${name}']`)
fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`)) exec(`cd ${path} && npm install && npm run build`, () => {
fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`)) console.log(`Create Doric JS Project Success`)
fs.mkdirSync(`${path}/.vscode`)
fs.writeFileSync(`${path}/.vscode/launch.json`, fs.readFileSync(`${targetJSPath}/_launch.json`).toString().replace(/__\$__/g, name))
fs.writeFileSync(`${path}/.vscode/tasks.json`, fs.readFileSync(`${targetJSPath}/_tasks.json`).toString().replace(/__\$__/g, name))
fs.mkdirSync(`${path}/src`)
fs.writeFileSync(`${path}/src/${name}.ts`, fs.readFileSync(`${targetJSPath}/$.ts`).toString().replace(/__\$__/g, name))
fs.writeFileSync(`${path}/index.ts`, `export default ['src/${name}']`)
exec(`cd ${path} && npm install && npm run build`, () => {
console.log(`Create Doric JS Project Success`)
})
}) })
} }
function initAndroid(path, name) { function initAndroid(path, name) {
@ -133,7 +124,7 @@ module.exports = function (name) {
if (err) { if (err) {
return console.error(err); return console.error(err);
} }
initJS(`${process.cwd()}/${name}/js`, name) initJS(`${process.cwd()}/${name}`, name)
initAndroid(`${process.cwd()}/${name}/android`, name) initAndroid(`${process.cwd()}/${name}/android`, name)
initiOS(`${process.cwd()}/${name}/iOS`, name) initiOS(`${process.cwd()}/${name}/iOS`, name)
}) })

View File

@ -1,7 +1,4 @@
{ {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {

View File

@ -10,7 +10,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"doric": "0.2.1", "doric": "0.2.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rollup": "^1.27.14", "rollup": "^1.27.14",
"@rollup/plugin-commonjs": "^11.0.0", "@rollup/plugin-commonjs": "^11.0.0",

View File

@ -1,6 +1,4 @@
{ {
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {

View File

@ -20,7 +20,7 @@ android {
sourceSets { sourceSets {
main { main {
assets.srcDirs = [project.getRootDir().getParent() + "/js/bundle"] assets.srcDirs = [project.getRootDir().getParent() + "/bundle"]
} }
} }
@ -28,8 +28,8 @@ android {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "pub.doric:core:0.2.1" implementation "pub.doric:core:0.2.3"
debugImplementation "pub.doric:core:0.2.1" debugImplementation "pub.doric:core:0.2.3"
} }
} }
@ -38,6 +38,6 @@ afterEvaluate {
} }
task buildJSBundle(type: Exec) { task buildJSBundle(type: Exec) {
workingDir project.rootDir.getParent() + "/js" workingDir project.rootDir.getParent()
commandLine 'doric', 'build' commandLine 'doric', 'build'
} }

View File

@ -8,18 +8,19 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
95EDDB7EAB47A65821DBC7EC /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB59FE64F1D814FD13C71BB2 /* Pods_Example.framework */; }; 95EDDB7EAB47A65821DBC7EC /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB59FE64F1D814FD13C71BB2 /* Pods_Example.framework */; };
E2B059BF23C452BB007555C7 /* src in Resources */ = {isa = PBXBuildFile; fileRef = E2B059BE23C452BB007555C7 /* src */; };
E2F64CEF2399359C0006BD9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CEE2399359C0006BD9A /* AppDelegate.m */; }; E2F64CEF2399359C0006BD9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CEE2399359C0006BD9A /* AppDelegate.m */; };
E2F64CF22399359C0006BD9A /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CF12399359C0006BD9A /* SceneDelegate.m */; }; E2F64CF22399359C0006BD9A /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CF12399359C0006BD9A /* SceneDelegate.m */; };
E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CF92399359E0006BD9A /* Assets.xcassets */; }; E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CF92399359E0006BD9A /* Assets.xcassets */; };
E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CFB2399359E0006BD9A /* LaunchScreen.storyboard */; }; E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CFB2399359E0006BD9A /* LaunchScreen.storyboard */; };
E2F64D002399359E0006BD9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CFF2399359E0006BD9A /* main.m */; }; E2F64D002399359E0006BD9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CFF2399359E0006BD9A /* main.m */; };
E2F64D07239936A70006BD9A /* src in Resources */ = {isa = PBXBuildFile; fileRef = E2F64D06239936A70006BD9A /* src */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
197D29BBE572343DDD72F8A6 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; }; 197D29BBE572343DDD72F8A6 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
5D47A9D4EA2836D57373FDF6 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; }; 5D47A9D4EA2836D57373FDF6 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
AB59FE64F1D814FD13C71BB2 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; AB59FE64F1D814FD13C71BB2 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E2B059BE23C452BB007555C7 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../bundle/src; sourceTree = "<group>"; };
E2F64CEA2399359C0006BD9A /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; E2F64CEA2399359C0006BD9A /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
E2F64CED2399359C0006BD9A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; E2F64CED2399359C0006BD9A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
E2F64CEE2399359C0006BD9A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; E2F64CEE2399359C0006BD9A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@ -29,7 +30,6 @@
E2F64CFC2399359E0006BD9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; E2F64CFC2399359E0006BD9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
E2F64CFE2399359E0006BD9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; E2F64CFE2399359E0006BD9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E2F64CFF2399359E0006BD9A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; E2F64CFF2399359E0006BD9A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E2F64D06239936A70006BD9A /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../js/bundle/src; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -56,7 +56,7 @@
E2F64CE12399359C0006BD9A = { E2F64CE12399359C0006BD9A = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E2F64D06239936A70006BD9A /* src */, E2B059BE23C452BB007555C7 /* src */,
E2F64CEC2399359C0006BD9A /* Example */, E2F64CEC2399359C0006BD9A /* Example */,
E2F64CEB2399359C0006BD9A /* Products */, E2F64CEB2399359C0006BD9A /* Products */,
875E7B19E6A1ABA3F802B6B5 /* Pods */, 875E7B19E6A1ABA3F802B6B5 /* Pods */,
@ -102,13 +102,12 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = E2F64D032399359E0006BD9A /* Build configuration list for PBXNativeTarget "Example" */; buildConfigurationList = E2F64D032399359E0006BD9A /* Build configuration list for PBXNativeTarget "Example" */;
buildPhases = ( buildPhases = (
E2F64D0B2399FFB20006BD9A /* Package JS Bundle */,
8E2E7D30FF8381E7791EA41B /* [CP] Check Pods Manifest.lock */, 8E2E7D30FF8381E7791EA41B /* [CP] Check Pods Manifest.lock */,
E2F64D0B2399FFB20006BD9A /* Package JS Bundle */,
E2F64CE62399359C0006BD9A /* Sources */, E2F64CE62399359C0006BD9A /* Sources */,
E2F64CE72399359C0006BD9A /* Frameworks */, E2F64CE72399359C0006BD9A /* Frameworks */,
E2F64CE82399359C0006BD9A /* Resources */, E2F64CE82399359C0006BD9A /* Resources */,
489CC68D7F95811A10DFEC4E /* [CP] Embed Pods Frameworks */, 489CC68D7F95811A10DFEC4E /* [CP] Embed Pods Frameworks */,
825E7E0BA78A39B2E522054D /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@ -156,7 +155,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
E2F64D07239936A70006BD9A /* src in Resources */, E2B059BF23C452BB007555C7 /* src in Resources */,
E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */, E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */,
E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */, E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */,
); );
@ -182,23 +181,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
825E7E0BA78A39B2E522054D /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
8E2E7D30FF8381E7791EA41B /* [CP] Check Pods Manifest.lock */ = { 8E2E7D30FF8381E7791EA41B /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -237,7 +219,7 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n# Type a script or drag a script file from your workspace to insert its path.\n\nexport NVM_DIR=\"$HOME/.nvm\"\n[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\" # This loads nvm\n[ -s \"$NVM_DIR/bash_completion\" ] && \\. \"$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n\ncd ../js && doric build\n"; shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n# Type a script or drag a script file from your workspace to insert its path.\n\nexport NVM_DIR=\"$HOME/.nvm\"\n[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\" # This loads nvm\n[ -s \"$NVM_DIR/bash_completion\" ] && \\. \"$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n\ncd ../ && doric build\n";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */

View File

@ -6,5 +6,5 @@ target 'Example' do
use_frameworks! use_frameworks!
# Pods for Example # Pods for Example
pod 'DoricCore', '~>0.2.1' pod 'DoricCore', '~>0.2.3'
end end