From 8fc72c95bc5a83dcad2f59ea5784c7387f544c67 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 7 Jan 2020 14:03:07 +0800 Subject: [PATCH] cli:update cli config --- doric-cli/index.js | 7 +++- doric-cli/scripts/init.js | 39 +++++++------------ doric-cli/target/{js => }/$.ts | 0 doric-cli/target/{js => }/_gitignore | 0 doric-cli/target/{js => }/_launch.json | 3 -- doric-cli/target/{js => }/_package.json | 2 +- doric-cli/target/{js => }/_rollup.config.js | 0 doric-cli/target/{js => }/_tasks.json | 2 - doric-cli/target/{js => }/_tsconfig.json | 0 doric-cli/target/android/app/build.gradle | 8 ++-- .../iOS/Example.xcodeproj/project.pbxproj | 30 +++----------- doric-cli/target/iOS/Podfile | 2 +- 12 files changed, 33 insertions(+), 60 deletions(-) rename doric-cli/target/{js => }/$.ts (100%) rename doric-cli/target/{js => }/_gitignore (100%) rename doric-cli/target/{js => }/_launch.json (74%) rename doric-cli/target/{js => }/_package.json (95%) rename doric-cli/target/{js => }/_rollup.config.js (100%) rename doric-cli/target/{js => }/_tasks.json (83%) rename doric-cli/target/{js => }/_tsconfig.json (100%) diff --git a/doric-cli/index.js b/doric-cli/index.js index 5787e282..071d1c13 100755 --- a/doric-cli/index.js +++ b/doric-cli/index.js @@ -4,7 +4,12 @@ var program = require('commander'); program .command('create ') - .option('-n, --native', 'Native') + .action(function (name, cmd) { + console.log('create ' + name + (cmd.native ? ' native' : 'js')) + require('./scripts/init')(name) + }) +program + .command('new ') .action(function (name, cmd) { console.log('create ' + name + (cmd.native ? ' native' : 'js')) require('./scripts/init')(name) diff --git a/doric-cli/scripts/init.js b/doric-cli/scripts/init.js index 43ebdfd0..ae0f75ee 100644 --- a/doric-cli/scripts/init.js +++ b/doric-cli/scripts/init.js @@ -3,7 +3,7 @@ var path = require('path') require('shelljs/global') -const targetJSPath = `${__dirname}/../target/js` +const targetJSPath = `${__dirname}/../target/` const targetAndroidPath = `${__dirname}/../target/android` const targetiOSPath = `${__dirname}/../target/iOS` @@ -65,28 +65,19 @@ function copyFolder(srcDir, tarDir, cb) { } function initJS(path, name) { - if (fs.existsSync(path)) { - console.warn(`Dir:${process.cwd()}/${path} already exists`) - return; - } - fs.mkdir(path, function (err) { - if (err) { - return console.error(err); - } - console.log(`create dir ${path} success`); - fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString().replace(/__\$__/g, name)) - fs.writeFileSync(`${path}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`)) - fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`)) - fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`)) - 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`) - }) + console.log(`create dir ${path} success`); + fs.writeFileSync(`${path}/package.json`, fs.readFileSync(`${targetJSPath}/_package.json`).toString().replace(/__\$__/g, name)) + fs.writeFileSync(`${path}/tsconfig.json`, fs.readFileSync(`${targetJSPath}/_tsconfig.json`)) + fs.writeFileSync(`${path}/rollup.config.js`, fs.readFileSync(`${targetJSPath}/_rollup.config.js`)) + fs.writeFileSync(`${path}/.gitignore`, fs.readFileSync(`${targetJSPath}/_gitignore`)) + 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) { @@ -133,7 +124,7 @@ module.exports = function (name) { if (err) { return console.error(err); } - initJS(`${process.cwd()}/${name}/js`, name) + initJS(`${process.cwd()}/${name}`, name) initAndroid(`${process.cwd()}/${name}/android`, name) initiOS(`${process.cwd()}/${name}/iOS`, name) }) diff --git a/doric-cli/target/js/$.ts b/doric-cli/target/$.ts similarity index 100% rename from doric-cli/target/js/$.ts rename to doric-cli/target/$.ts diff --git a/doric-cli/target/js/_gitignore b/doric-cli/target/_gitignore similarity index 100% rename from doric-cli/target/js/_gitignore rename to doric-cli/target/_gitignore diff --git a/doric-cli/target/js/_launch.json b/doric-cli/target/_launch.json similarity index 74% rename from doric-cli/target/js/_launch.json rename to doric-cli/target/_launch.json index 39c84064..218cdf89 100644 --- a/doric-cli/target/js/_launch.json +++ b/doric-cli/target/_launch.json @@ -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", "configurations": [ { diff --git a/doric-cli/target/js/_package.json b/doric-cli/target/_package.json similarity index 95% rename from doric-cli/target/js/_package.json rename to doric-cli/target/_package.json index 233808c3..e2f4e682 100644 --- a/doric-cli/target/js/_package.json +++ b/doric-cli/target/_package.json @@ -10,7 +10,7 @@ }, "license": "Apache-2.0", "dependencies": { - "doric": "0.2.1", + "doric": "0.2.3", "reflect-metadata": "^0.1.13", "rollup": "^1.27.14", "@rollup/plugin-commonjs": "^11.0.0", diff --git a/doric-cli/target/js/_rollup.config.js b/doric-cli/target/_rollup.config.js similarity index 100% rename from doric-cli/target/js/_rollup.config.js rename to doric-cli/target/_rollup.config.js diff --git a/doric-cli/target/js/_tasks.json b/doric-cli/target/_tasks.json similarity index 83% rename from doric-cli/target/js/_tasks.json rename to doric-cli/target/_tasks.json index d51f6710..4a3a62d9 100644 --- a/doric-cli/target/js/_tasks.json +++ b/doric-cli/target/_tasks.json @@ -1,6 +1,4 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { diff --git a/doric-cli/target/js/_tsconfig.json b/doric-cli/target/_tsconfig.json similarity index 100% rename from doric-cli/target/js/_tsconfig.json rename to doric-cli/target/_tsconfig.json diff --git a/doric-cli/target/android/app/build.gradle b/doric-cli/target/android/app/build.gradle index fd7d0f85..87433c08 100644 --- a/doric-cli/target/android/app/build.gradle +++ b/doric-cli/target/android/app/build.gradle @@ -20,7 +20,7 @@ android { sourceSets { 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 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation "pub.doric:core:0.2.1" - debugImplementation "pub.doric:core:0.2.1" + implementation "pub.doric:core:0.2.3" + debugImplementation "pub.doric:core:0.2.3" } } @@ -38,6 +38,6 @@ afterEvaluate { } task buildJSBundle(type: Exec) { - workingDir project.rootDir.getParent() + "/js" + workingDir project.rootDir.getParent() commandLine 'doric', 'build' } \ No newline at end of file diff --git a/doric-cli/target/iOS/Example.xcodeproj/project.pbxproj b/doric-cli/target/iOS/Example.xcodeproj/project.pbxproj index 9ce4ae76..b6747c33 100644 --- a/doric-cli/target/iOS/Example.xcodeproj/project.pbxproj +++ b/doric-cli/target/iOS/Example.xcodeproj/project.pbxproj @@ -8,18 +8,19 @@ /* Begin PBXBuildFile section */ 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 */; }; E2F64CF22399359C0006BD9A /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CF12399359C0006BD9A /* SceneDelegate.m */; }; E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CF92399359E0006BD9A /* Assets.xcassets */; }; E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2F64CFB2399359E0006BD9A /* LaunchScreen.storyboard */; }; E2F64D002399359E0006BD9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F64CFF2399359E0006BD9A /* main.m */; }; - E2F64D07239936A70006BD9A /* src in Resources */ = {isa = PBXBuildFile; fileRef = E2F64D06239936A70006BD9A /* src */; }; /* End PBXBuildFile 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 = ""; }; 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 = ""; }; 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 = ""; }; 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 = ""; }; E2F64CEE2399359C0006BD9A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -29,7 +30,6 @@ E2F64CFC2399359E0006BD9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; E2F64CFE2399359E0006BD9A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E2F64CFF2399359E0006BD9A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - E2F64D06239936A70006BD9A /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../js/bundle/src; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -56,7 +56,7 @@ E2F64CE12399359C0006BD9A = { isa = PBXGroup; children = ( - E2F64D06239936A70006BD9A /* src */, + E2B059BE23C452BB007555C7 /* src */, E2F64CEC2399359C0006BD9A /* Example */, E2F64CEB2399359C0006BD9A /* Products */, 875E7B19E6A1ABA3F802B6B5 /* Pods */, @@ -102,13 +102,12 @@ isa = PBXNativeTarget; buildConfigurationList = E2F64D032399359E0006BD9A /* Build configuration list for PBXNativeTarget "Example" */; buildPhases = ( - E2F64D0B2399FFB20006BD9A /* Package JS Bundle */, 8E2E7D30FF8381E7791EA41B /* [CP] Check Pods Manifest.lock */, + E2F64D0B2399FFB20006BD9A /* Package JS Bundle */, E2F64CE62399359C0006BD9A /* Sources */, E2F64CE72399359C0006BD9A /* Frameworks */, E2F64CE82399359C0006BD9A /* Resources */, 489CC68D7F95811A10DFEC4E /* [CP] Embed Pods Frameworks */, - 825E7E0BA78A39B2E522054D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -156,7 +155,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - E2F64D07239936A70006BD9A /* src in Resources */, + E2B059BF23C452BB007555C7 /* src in Resources */, E2F64CFD2399359E0006BD9A /* LaunchScreen.storyboard in Resources */, E2F64CFA2399359E0006BD9A /* Assets.xcassets in Resources */, ); @@ -182,23 +181,6 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; 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 */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -237,7 +219,7 @@ ); runOnlyForDeploymentPostprocessing = 0; 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 */ diff --git a/doric-cli/target/iOS/Podfile b/doric-cli/target/iOS/Podfile index 24ff6e2b..a1945a8c 100644 --- a/doric-cli/target/iOS/Podfile +++ b/doric-cli/target/iOS/Podfile @@ -6,5 +6,5 @@ target 'Example' do use_frameworks! # Pods for Example - pod 'DoricCore', '~>0.2.1' + pod 'DoricCore', '~>0.2.3' end