Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Laiff committed May 22, 2017
0 parents commit d4192f2
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
[*]
indent_style = space
end_of_line = lf
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
.idea/
*.iml

node_modules/
build/
coverage/
.DS_Store
.nyc_output/
.happypack/

webpack-assets.json
webpack-stats.json
.tern-project
npm-debug.log
npm-debug.log*
lerna-debug.log
lerna-debug.log*
58 changes: 58 additions & 0 deletions bin/ris.js
@@ -0,0 +1,58 @@
#!/usr/bin/env node
'use strict';

const spawn = require('cross-spawn')
const glob = require('glob')
const path = require('path')

const packageName = process.argv[2]
const command = process.argv[3]
const args = process.argv.slice(4)

const packageNames = glob.sync('./packages/*').reduce((result, packageFolder) => {
const packageJson = require(`../${packageFolder}/package.json`)
const rispaName = packageJson['rispa:name']
if (packageName === 'all' && !(packageJson['scripts'] && command in packageJson['scripts'])) {
return result
}
if (rispaName) {
result[rispaName] = packageFolder
} else {
result[packageJson['name']] = packageFolder
}

return result
}, {})

if (packageName !== 'all' && !packageNames[packageName]) {
console.log(`Can't find package with name: ${packageName}.\n\nList of available packages:\n - ${Object.keys(packageNames).join('\n - ')}`)
process.exit(1)
}


const result = callScript(packageName, packageNames, command, args)
process.exit(result)

function callScript(packageName, packageNames, command, args){
if (packageName === 'all') {
return Object.values(packageNames).reduce( (result, path) => {
const res = spawn.sync(
'yarn',
[command].concat(args),
{
cwd: path,
stdio: 'inherit'
})
return res.status || result
}, 0 )
} else {
return spawn.sync(
'yarn',
[command].concat(args),
{
cwd: packageNames[packageName],
stdio: 'inherit'
}
).status
}
}
29 changes: 29 additions & 0 deletions package.json
@@ -0,0 +1,29 @@
{
"name": "rispa-cli",
"version": "0.1.0",
"description": "Rispa CLI - entry point to project generator",
"main": "/bin/ris.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rispa-io/rispa-cli.git"
},
"keywords": [
"rispa",
"cli",
"project",
"generator"
],
"author": "Andrew Laiff",
"license": "MIT",
"bugs": {
"url": "https://github.com/rispa-io/rispa-cli/issues"
},
"homepage": "https://github.com/rispa-io/rispa-cli#readme",
"dependencies": {
"cross-spawn": "^5.1.0",
"glob": "^7.1.2"
}
}
107 changes: 107 additions & 0 deletions yarn.lock
@@ -0,0 +1,107 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"

brace-expansion@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59"
dependencies:
balanced-match "^0.4.1"
concat-map "0.0.1"

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
lru-cache "^4.0.1"
shebang-command "^1.2.0"
which "^1.2.9"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"

glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"

lru-cache@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e"
dependencies:
pseudomap "^1.0.1"
yallist "^2.0.0"

minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

pseudomap@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
dependencies:
shebang-regex "^1.0.0"

shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"

which@^1.2.9:
version "1.2.14"
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
dependencies:
isexe "^2.0.0"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

yallist@^2.0.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"

0 comments on commit d4192f2

Please sign in to comment.