Skip to content

Commit

Permalink
初始化项目
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Apr 8, 2018
1 parent 90d8dd6 commit 25f0ca5
Show file tree
Hide file tree
Showing 138 changed files with 17,871 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
.cache
.DS_Store
lerna-debug.log
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SOURCES = packages

bootstrap: clean-all
yarn --ignore-engines
./node_modules/.bin/lerna bootstrap -- --ignore-engines

clean-all:
rm -rf node_modules
rm -rf package-lock.json

$(foreach source, $(SOURCES), \
$(call clean-source-all, $(source)))

define clean-source-all
rm -rf $(1)/*/node_modules
rm -rf $(1)/*/package-lock.json

endef
11 changes: 11 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lerna": "2.10.0",
"packages": [
"packages/*"
],
"version": "0.0.1",
"npmClient": "yarn",
"npmClientArgs": [
"--no-lockfile"
]
}
60 changes: 60 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "taro",
"private": true,
"description": "Nerv-multi多端开发解决方案",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"keywords": [
"nerv",
"taro"
],
"author": "O2Team",
"license": "MIT",
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
"homepage": "https://github.com/NervJS/taro#readme",
"devDependencies": {
"@babel/core": "^7.0.0-beta.42",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.42",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.42",
"@babel/plugin-transform-react-jsx": "^7.0.0-beta.41",
"@babel/preset-env": "^7.0.0-beta.42",
"babel-eslint": "^7.2.3",
"babel-loader": "^8.0.0-beta.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^0.28.10",
"eslint": "^4.18.2",
"eslint-config-standard": "^11.0.0",
"eslint-config-standard-jsx": "^4.0.2",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-standard": "^3.0.1",
"html-webpack-plugin": "^3.0.6",
"husky": "^0.14.3",
"lerna": "^2.10.0",
"lint-staged": "^7.0.0",
"nerv-markdown-loader": "0.0.1",
"node-sass": "^4.7.2",
"rollup": "^0.57.1",
"rollup-plugin-babel": "^4.0.0-beta.2",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-node-resolve": "^3.3.0",
"sass-loader": "^6.0.7",
"style-loader": "^0.20.3",
"ts-loader": "^3.5.0",
"typescript": "^2.7.2",
"webpack": "^3.11.0",
"webpack-cli": "^1.0.12",
"webpack-dev-server": "^2.1.1"
}
}
2 changes: 2 additions & 0 deletions packages/taro-async-await/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @taro/async-await
支持async await写法
5 changes: 5 additions & 0 deletions packages/taro-async-await/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const global = typeof window !== 'undefined' && window.Math === Math
? window : typeof self !== 'undefined' && self.Math === Math ? self : this

global.Promise = require('promise-polyfill')
global.regeneratorRuntime = require('regenerator-runtime/runtime')
26 changes: 26 additions & 0 deletions packages/taro-async-await/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@taro/async-await",
"version": "0.0.1",
"description": "taro async await",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NervJS/taro.git"
},
"keywords": [
"taro"
],
"author": "luckyadam",
"license": "MIT",
"bugs": {
"url": "https://github.com/NervJS/taro/issues"
},
"homepage": "https://github.com/NervJS/taro#readme",
"dependencies": {
"promise-polyfill": "^7.1.2",
"regenerator-runtime": "^0.11.1"
}
}
14 changes: 14 additions & 0 deletions packages/taro-cli/bin/taro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env node

const program = require('commander')

const {
getPkgVersion
} = require('../src/util')

program
.version(getPkgVersion())
.usage('<command> [options]')
.command('init [projectName]', 'Init a project with default templete')
.command('build', 'Build a project with options')
.parse(process.argv)
29 changes: 29 additions & 0 deletions packages/taro-cli/bin/taro-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node
const path = require('path')
const fs = require('fs-extra')
const program = require('commander')
const chalk = require('chalk')

const build = require('../src/build')
const {
getPkgVersion,
PROJECT_CONFIG
} = require('../src/util')
const projectConfPath = path.join(process.cwd(), PROJECT_CONFIG)

program
.option('--type [typeName]', 'Build type, weapp/rn/h5')
.option('--watch', 'Build type, weapp/rn/h5')
.parse(process.argv)

const args = program.args
const { type, watch } = program
console.log(`Taro v${getPkgVersion()}`)
console.log()
if (!fs.existsSync(projectConfPath)) {
console.log(chalk.red(`找不到项目配置文件${PROJECT_CONFIG},请确定当前目录是Taro项目根目录!`))
process.exit(1)
}
const projectConf = require(projectConfPath)
console.log(chalk.green(`开始编译项目 ${chalk.bold(projectConf.projectName)}`))
build(args, { type, watch })
31 changes: 31 additions & 0 deletions packages/taro-cli/bin/taro-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env node

const program = require('commander')

const Project = require('../src/project')

const {
getPkgVersion
} = require('../src/util')

program
.option('--name', '项目名称')
.option('--template', '项目模板')
.option('--description', '项目介绍')
.parse(process.argv)

const args = program.args
const { template, description, name } = program

const projectName = args[0] || name

const project = new Project({
projectName,
template,
description
})

console.log(`Taro v${getPkgVersion()}`)
console.log()

project.create()
38 changes: 38 additions & 0 deletions packages/taro-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@taro/cli",
"version": "0.0.1",
"description": "cli tool for taro",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"taro": "bin/taro"
},
"keywords": [
"taro",
"weapp"
],
"author": "O2Team",
"license": "MIT",
"dependencies": {
"babel-generator": "^6.26.1",
"babel-traverse": "^6.26.0",
"babel-types": "^6.26.0",
"babylon": "^6.18.0",
"chalk": "^2.3.2",
"chokidar": "^2.0.3",
"commander": "^2.15.0",
"cross-spawn": "^6.0.5",
"fs-extra": "^5.0.0",
"glob": "^7.1.2",
"mem-fs": "^1.1.3",
"mem-fs-editor": "^4.0.0",
"nerv-to-mp": "^0.0.1",
"ora": "^2.0.0",
"resolve": "^1.6.0",
"shelljs": "^0.8.1",
"through2": "^2.0.3",
"vinyl-fs": "^3.0.2"
}
}
44 changes: 44 additions & 0 deletions packages/taro-cli/src/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')

const Util = require('./util')
const CONFIG = require('./config')

const appPath = process.cwd()

function build (args, { type, watch }) {
const outputPath = path.join(appPath, CONFIG.OUTPUT_DIR)
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath)
} else {
fs.emptyDirSync(outputPath)
}
switch (type) {
case Util.BUILD_TYPES.H5:
buildForH5({ watch })
break
case Util.BUILD_TYPES.WEAPP:
buildForWeapp({ watch })
break
case Util.BUILD_TYPES.RN:
buildForRN({ watch })
break
default:
console.log(chalk.red('输入类型错误,目前只支持weapp/h5/rn三端类型'))
}
}

function buildForWeapp ({ watch }) {
require('./weapp').build({ watch })
}

function buildForH5 ({ watch }) {
require('./h5').build({ watch })
}

function buildForRN () {

}

module.exports = build
11 changes: 11 additions & 0 deletions packages/taro-cli/src/config/babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
sourceMap: true,
presets: [
'env'
],
plugins: [
'transform-class-properties',
'transform-decorators-legacy',
'transform-object-rest-spread'
]
}
4 changes: 4 additions & 0 deletions packages/taro-cli/src/config/browser_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = [
'Android >= 4',
'iOS >= 6'
]
6 changes: 6 additions & 0 deletions packages/taro-cli/src/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
OUTPUT_DIR: 'dist',
SOURCE_DIR: 'src',
NPM_DIR: 'npm',
ENTRY: 'app.js'
}
Loading

0 comments on commit 25f0ca5

Please sign in to comment.