style: global and simpler prettier config
this also removes precommit scripts because they were cumbersome
This commit is contained in:
parent
90d6b31264
commit
23ddc68ade
4
.github/COMMIT_GUIDELINES.md
vendored
4
.github/COMMIT_GUIDELINES.md
vendored
@ -17,9 +17,9 @@ perf
|
||||
refactor
|
||||
revert
|
||||
style
|
||||
test
|
||||
test
|
||||
```
|
||||
|
||||
And where scope is one of ui-toolkit, my-joy-beta, cloudapi-gql, boilerplate, and create-instance.
|
||||
|
||||
*The recommended method to commit should be by running npm run commit.*
|
||||
_The recommended method to commit should be by running npm run commit._
|
||||
|
16
.github/ISSUE_TEMPLATE.md
vendored
16
.github/ISSUE_TEMPLATE.md
vendored
@ -1,27 +1,17 @@
|
||||
## I'm submitting a...
|
||||
|
||||
- [ ] bug report
|
||||
- [ ] feature request
|
||||
- [ ] design request
|
||||
* [ ] bug report
|
||||
* [ ] feature request
|
||||
* [ ] design request
|
||||
|
||||
## What is the current behavior?
|
||||
|
||||
|
||||
|
||||
## If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
|
||||
|
||||
|
||||
|
||||
## What is the expected behavior?
|
||||
|
||||
|
||||
|
||||
## What is the motivation / use case for changing the behavior?
|
||||
|
||||
|
||||
|
||||
## If the current behavior is a bug, please provide your browser
|
||||
|
||||
|
||||
|
||||
## Other information
|
||||
|
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,22 +1,14 @@
|
||||
**Please check if the PR fulfills these requirements**
|
||||
- [ ] The commit message follows our [guidelines](https://github.com/yldio/joyent-portal/blob/master/.github/COMMIT_GUIDELINES.md)
|
||||
- [ ] Tests for the changes have been added (for bug fixes / features)
|
||||
|
||||
* [ ] The commit message follows our [guidelines](https://github.com/yldio/joyent-portal/blob/master/.github/COMMIT_GUIDELINES.md)
|
||||
* [ ] Tests for the changes have been added (for bug fixes / features)
|
||||
|
||||
**What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
|
||||
|
||||
|
||||
|
||||
**Does this PR close an issue?** (If not please create one)
|
||||
|
||||
|
||||
|
||||
**What is the new behavior (if this is a feature change)?**
|
||||
|
||||
|
||||
|
||||
**Does this PR introduce a breaking change?** (What changes might users need to make in their application due to this PR?)
|
||||
|
||||
|
||||
|
||||
**Other information**
|
||||
|
@ -1,11 +1,14 @@
|
||||
{
|
||||
"ignoreDevDependencies": true,
|
||||
"allowedPackages": [{
|
||||
"name": "colors",
|
||||
"extraFieldsForDocumentation": "Licence is MIT, but was not found by tool: https://github.com/Marak/colors.js/blob/v0.5.1/MIT-LICENSE.txt",
|
||||
"date": "17 January 2017",
|
||||
"reason": "MIT Licenced"
|
||||
}],
|
||||
"allowedPackages": [
|
||||
{
|
||||
"name": "colors",
|
||||
"extraFieldsForDocumentation":
|
||||
"Licence is MIT, but was not found by tool: https://github.com/Marak/colors.js/blob/v0.5.1/MIT-LICENSE.txt",
|
||||
"date": "17 January 2017",
|
||||
"reason": "MIT Licenced"
|
||||
}
|
||||
],
|
||||
"allowedLicenses": [
|
||||
"CC-BY-4.0",
|
||||
"CC0-1.0",
|
||||
|
24
.prettierignore
Normal file
24
.prettierignore
Normal file
@ -0,0 +1,24 @@
|
||||
.git/*
|
||||
.DS_Store
|
||||
|
||||
license
|
||||
yarn.lock
|
||||
.travis.yml
|
||||
|
||||
.yarnclean
|
||||
.eslintignore
|
||||
.prettierignore
|
||||
.npmignore
|
||||
.gitignore
|
||||
.dockerignore
|
||||
|
||||
dist
|
||||
build
|
||||
|
||||
*.ico
|
||||
*.html
|
||||
*.log
|
||||
*.svg
|
||||
*.map
|
||||
*.png
|
||||
*.snap
|
31
.prettierrc
Normal file
31
.prettierrc
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"printWidth": 80,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false,
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
".prettierrc",
|
||||
".eslintrc",
|
||||
".babelrc",
|
||||
".tern-project",
|
||||
".stylelintrc",
|
||||
".lighthouserc"
|
||||
],
|
||||
"options": {
|
||||
"parser": "json"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["package.json"],
|
||||
"options": {
|
||||
"printWidth": 180
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
@ -12,4 +9,4 @@
|
||||
"configPath": "./webpack/index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
.vscode/launch.json
vendored
28
.vscode/launch.json
vendored
@ -1,15 +1,15 @@
|
||||
{
|
||||
// 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": [
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Launch Chrome against localhost",
|
||||
"url": "http://localhost:3069/",
|
||||
"webRoot": "${workspaceRoot}"
|
||||
}
|
||||
]
|
||||
}
|
||||
// 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": [
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Launch Chrome against localhost",
|
||||
"url": "http://localhost:3069/",
|
||||
"webRoot": "${workspaceRoot}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
31
package.json
31
package.json
@ -16,29 +16,17 @@
|
||||
"build:test": "lerna run build:test --parallel --stream",
|
||||
"test:run": "lerna run test --parallel --stream",
|
||||
"test:ci:run": "lerna exec 'yarn run test:ci'",
|
||||
"format": "./scripts/format",
|
||||
"lint-staged": "./scripts/run-staged-pkg --lint",
|
||||
"format-staged": "./scripts/format --staged",
|
||||
"lint-license": "./scripts/license-to-fail",
|
||||
"lint-docs": "./scripts/quality-docs",
|
||||
"format": "prettier --config .prettierrc --write '**/*'",
|
||||
"clean": "lerna clean --yes",
|
||||
"commitmsg": "commitlint -e",
|
||||
"precommit": "CI=1 redrun -s lint-staged format-staged",
|
||||
"precommit": "pretty-quick --staged",
|
||||
"commit": "commit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^4.2.1",
|
||||
"@commitlint/config-angular": "^4.2.1",
|
||||
"@commitlint/prompt-cli": "^4.2.1",
|
||||
"apr-awaitify": "^3.0.3",
|
||||
"apr-filter": "^3.0.3",
|
||||
"apr-for-each": "^3.0.3",
|
||||
"apr-main": "^4.0.3",
|
||||
"apr-map": "^3.0.3",
|
||||
"apr-parallel": "^3.0.3",
|
||||
"apr-reduce": "^3.0.3",
|
||||
"babel-eslint": "^8.2.2",
|
||||
"checksum": "^0.1.1",
|
||||
"eslint": "^4.18.1",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-config-react-app": "^2.1.0",
|
||||
@ -49,17 +37,11 @@
|
||||
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
||||
"eslint-plugin-prettier": "^2.6.0",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"execa": "^0.9.0",
|
||||
"force-array": "^3.1.0",
|
||||
"husky": "^0.14.3",
|
||||
"lerna": "^2.9.0",
|
||||
"license-to-fail": "^2.2.0",
|
||||
"lodash.uniq": "^4.5.0",
|
||||
"prettier": "1.11.0",
|
||||
"quality-docs": "^3.3.0",
|
||||
"redrun": "^5.10.5",
|
||||
"staged-git-files": "0.0.4",
|
||||
"yargs": "^10.0.3"
|
||||
"pretty-quick": "^1.4.1",
|
||||
"redrun": "^5.10.5"
|
||||
},
|
||||
"resolutions": {
|
||||
"axios": "0.16.2",
|
||||
@ -74,8 +56,5 @@
|
||||
"breeze-nexttick": "0.2.1",
|
||||
"isarray": "1.0.0"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
"bundle"
|
||||
]
|
||||
"workspaces": ["packages/*", "bundle"]
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
|
@ -1,7 +1,12 @@
|
||||
{
|
||||
"ignore": ["_document.js"],
|
||||
"presets": [["joyent-portal", {
|
||||
"aliases": true,
|
||||
"autoAliases": true
|
||||
}]]
|
||||
"presets": [
|
||||
[
|
||||
"joyent-portal",
|
||||
{
|
||||
"aliases": true,
|
||||
"autoAliases": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
"jsx": true,
|
||||
"node": true,
|
||||
"webpack": {
|
||||
"configPath": "../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
"configPath":
|
||||
"../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,10 @@ export default (opts = {}) => {
|
||||
credentials: 'same-origin',
|
||||
fetch,
|
||||
headers: {
|
||||
'X-CSRF-Token': global.cookie.replace(/(?:(?:^|.*;\s*)crumb\s*=\s*([^;]*).*$)|^.*$/, '$1')
|
||||
'X-CSRF-Token': global.cookie.replace(
|
||||
/(?:(?:^|.*;\s*)crumb\s*=\s*([^;]*).*$)|^.*$/,
|
||||
'$1'
|
||||
)
|
||||
}
|
||||
}),
|
||||
...opts
|
||||
|
@ -1,7 +1,12 @@
|
||||
{
|
||||
"ignore": ["_document.js", "_aliases.js"],
|
||||
"presets": [["joyent-portal", {
|
||||
"aliases": true,
|
||||
"autoAliases": true
|
||||
}]]
|
||||
"presets": [
|
||||
[
|
||||
"joyent-portal",
|
||||
{
|
||||
"aliases": true,
|
||||
"autoAliases": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -5,4 +5,4 @@
|
||||
"href": "http://0.0.0.0:3069"
|
||||
},
|
||||
"extends": "lighthouse:default"
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
"jsx": true,
|
||||
"node": true,
|
||||
"webpack": {
|
||||
"configPath": "../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
"configPath":
|
||||
"../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"test": ["./src/**/*.js"],
|
||||
"extends": ["stylelint-config-joyent-portal"]
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
@ -12,4 +9,4 @@
|
||||
"configPath": "./webpack/index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,9 +343,19 @@ export const Tbody = Baseline(({ children, ...rest }) => (
|
||||
export const Td = Baseline(({ children, ...rest }) => (
|
||||
<Propagate {...rest}>
|
||||
{value => (
|
||||
<BaseTd {...rest} {...value} {...rest} name="td">
|
||||
<BaseTd {...rest} {...value} name="td">
|
||||
{children}
|
||||
</BaseTd>
|
||||
)}
|
||||
</Propagate>
|
||||
));
|
||||
|
||||
export const Pagination = ({ children, colSpan, ...rest }) => (
|
||||
<Tfoot>
|
||||
<Tr {...rest}>
|
||||
<Th colSpan={colSpan} hasBorder="bottom" middle center>
|
||||
{children}
|
||||
</Th>
|
||||
</Tr>
|
||||
</Tfoot>
|
||||
);
|
||||
|
@ -1,15 +1,13 @@
|
||||
{
|
||||
"libs": [
|
||||
"ecmascript",
|
||||
"browser"
|
||||
],
|
||||
"libs": ["ecmascript", "browser"],
|
||||
"plugins": {
|
||||
"doc_comment": true,
|
||||
"local-scope": true,
|
||||
"jsx": true,
|
||||
"node": true,
|
||||
"webpack": {
|
||||
"configPath": "../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
"configPath":
|
||||
"../../node_modules/joyent-react-scripts/src/webpack.config.dev.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,8 @@
|
||||
"dev": "NODE_ENV=development joyent-react-scripts start",
|
||||
"build": "NODE_ENV=production joyent-react-scripts build",
|
||||
"fmt": "prettier --write --single-quote *.js src/*.js src/**/*.js",
|
||||
"lint-ci":
|
||||
"eslint . --fix --ext .js --ext .md && echo 0 `# stylelint './src/**/*.js'`",
|
||||
"lint":
|
||||
"eslint . --fix --ext .js --ext .md && echo 0 `# stylelint './src/**/*.js'`",
|
||||
"lint-ci": "eslint . --fix --ext .js --ext .md && echo 0 `# stylelint './src/**/*.js'`",
|
||||
"lint": "eslint . --fix --ext .js --ext .md && echo 0 `# stylelint './src/**/*.js'`",
|
||||
"prepublish": "echo 0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
12
running.md
12
running.md
@ -1,14 +1,14 @@
|
||||
# How to run the Joyent Portal
|
||||
|
||||
#### Requisites
|
||||
#### Requisites
|
||||
|
||||
* [ ] [Install node.js](https://nodejs.org/en/download/current/)
|
||||
* [ ] [Install Yarn](https://yarnpkg.com/en/docs/install)
|
||||
* [ ] [Setup node-triton](https://github.com/joyent/node-triton#setup)
|
||||
|
||||
- [ ] [Install node.js](https://nodejs.org/en/download/current/)
|
||||
- [ ] [Install Yarn](https://yarnpkg.com/en/docs/install)
|
||||
- [ ] [Setup node-triton](https://github.com/joyent/node-triton#setup)
|
||||
|
||||
## via [webconsole-instances](https://github.com/joyent/webconsole-instances)
|
||||
|
||||
[webconsole-instances](https://github.com/joyent/webconsole-instances) is the stable version of the portal. It gets updated with stable releases from [joyent-portal](http://github.com/yldio/joyent-portal).
|
||||
[webconsole-instances](https://github.com/joyent/webconsole-instances) is the stable version of the portal. It gets updated with stable releases from [joyent-portal](http://github.com/yldio/joyent-portal).
|
||||
|
||||
```
|
||||
➜ git clone https://github.com/joyent/webconsole-instances
|
||||
|
171
scripts/format
171
scripts/format
@ -1,171 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { config } = require('../package.json');
|
||||
const { exists } = require('mz/fs');
|
||||
const sgf = require('staged-git-files');
|
||||
const forceArray = require('force-array');
|
||||
const awaitify = require('apr-awaitify');
|
||||
const asyncFilter = require('apr-filter');
|
||||
const map = require('apr-map');
|
||||
const reduce = require('apr-reduce');
|
||||
const parallel = require('apr-parallel');
|
||||
const execa = require('execa');
|
||||
const globby = require('globby');
|
||||
const main = require('apr-main');
|
||||
const argv = require('yargs').argv;
|
||||
const path = require('path');
|
||||
const checksum = require('checksum');
|
||||
|
||||
const getStaged = awaitify(sgf);
|
||||
const asyncChecksum = awaitify(checksum.file);
|
||||
|
||||
const ROOT = path.join(__dirname, '../');
|
||||
const SCRIPTS = path.resolve(__dirname);
|
||||
|
||||
const statuses = ['Added', 'Modified'];
|
||||
|
||||
const filter = (files = []) =>
|
||||
files
|
||||
.filter(file => !/node_modules|dist/.test(file))
|
||||
.map(file => path.resolve(ROOT, file));
|
||||
|
||||
const run = async (files = []) => {
|
||||
const filteredFiles = filter(files);
|
||||
|
||||
const _files = filteredFiles.reduce(
|
||||
(files, file) => {
|
||||
const ext = path.extname(file).replace(/^./, '');
|
||||
|
||||
if (!ext) {
|
||||
return files;
|
||||
}
|
||||
|
||||
return Object.assign(files, {
|
||||
[ext]: (files[ext] || []).concat(file)
|
||||
});
|
||||
},
|
||||
{
|
||||
js: [],
|
||||
gql: [],
|
||||
json: []
|
||||
}
|
||||
);
|
||||
|
||||
return parallel({
|
||||
js: () =>
|
||||
_files.js.length
|
||||
? execa(
|
||||
'prettier',
|
||||
['--write', '--single-quote', '--parser=babylon'].concat(_files.js),
|
||||
{
|
||||
stdio: 'inherit'
|
||||
}
|
||||
)
|
||||
: Promise.resolve(),
|
||||
gql: () =>
|
||||
_files.gql.length
|
||||
? execa(
|
||||
'prettier',
|
||||
['--write', '--single-quote', '--parser=graphql'].concat(
|
||||
_files.gql
|
||||
),
|
||||
{
|
||||
stdio: 'inherit'
|
||||
}
|
||||
)
|
||||
: Promise.resolve(),
|
||||
json: () =>
|
||||
_files.json.length
|
||||
? execa(
|
||||
'prettier',
|
||||
['--write', '--single-quote', '--parser=json'].concat(_files.json),
|
||||
{
|
||||
stdio: 'inherit'
|
||||
}
|
||||
)
|
||||
: Promise.resolve()
|
||||
});
|
||||
};
|
||||
|
||||
const add = async filename => execa('git', ['add', filename]);
|
||||
|
||||
const all = async () => {
|
||||
const files = await globby(
|
||||
['{packages,prototypes}/**/*.{js,gql,json}', 'scripts/*'],
|
||||
{
|
||||
cwd: path.join(__dirname, '..')
|
||||
}
|
||||
);
|
||||
|
||||
return run(files);
|
||||
};
|
||||
|
||||
const getUnstaged = async () => {
|
||||
const unstaged = await execa('git', ['ls-files', '-m']);
|
||||
return unstaged.stdout.split('\n');
|
||||
};
|
||||
|
||||
const staged = async () => {
|
||||
const unstaged = (await getUnstaged())
|
||||
.map(file => path.resolve(ROOT, file))
|
||||
.filter(file => /\.js|gql|json$/.test(file) || file.indexOf(SCRIPTS) === 0);
|
||||
|
||||
const files = (await getStaged())
|
||||
.filter(({ status }) => statuses.indexOf(status) >= 0)
|
||||
.map(file =>
|
||||
Object.assign({}, file, { filename: path.resolve(ROOT, file.filename) })
|
||||
)
|
||||
.filter(
|
||||
file =>
|
||||
/\.js|gql|json$/.test(file.filename) ||
|
||||
file.filename.indexOf(SCRIPTS) === 0
|
||||
);
|
||||
|
||||
const existing = await asyncFilter(files, ({ filename }) => exists(filename));
|
||||
|
||||
if (!existing.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const checksums = await map(existing, async file => {
|
||||
const checksum = await asyncChecksum(file.filename);
|
||||
return Object.assign({}, file, { checksum });
|
||||
});
|
||||
|
||||
const filenames = existing.map(file => file.filename);
|
||||
await run(filenames);
|
||||
|
||||
const changed = await asyncFilter(
|
||||
checksums,
|
||||
async ({ filename, checksum }) => {
|
||||
const newChecksum = await asyncChecksum(filename);
|
||||
return checksum != newChecksum;
|
||||
}
|
||||
);
|
||||
|
||||
const modifieds = await reduce(
|
||||
changed,
|
||||
async (modifieds, file) => {
|
||||
const isUnstaged = unstaged.filter(f => f === file.filename).length;
|
||||
if (
|
||||
(file.status === 'Modified' || file.status === 'Added') &&
|
||||
isUnstaged
|
||||
) {
|
||||
modifieds.push(file);
|
||||
} else {
|
||||
await add(file.filename);
|
||||
}
|
||||
return modifieds;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
if (modifieds.length) {
|
||||
modifieds.forEach(modified =>
|
||||
console.log('PARTIALLY STAGED FILE ', modified.filename)
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
main(argv._.length ? run(argv._) : argv.staged ? staged() : all());
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const forEach = require('apr-for-each');
|
||||
const execa = require('execa');
|
||||
const globby = require('globby');
|
||||
const main = require('apr-main');
|
||||
const argv = require('yargs').argv;
|
||||
const path = require('path');
|
||||
|
||||
const config = path.join(__dirname, '../.licensesrc.json');
|
||||
const CWD = path.join(__dirname, '..');
|
||||
const BIN = path.join(CWD, 'node_modules/.bin/license-to-fail');
|
||||
|
||||
const run = async (dirs = []) =>
|
||||
forEach(dirs, async dir =>
|
||||
execa(BIN, [config], {
|
||||
cwd: dir,
|
||||
stdio: 'inherit'
|
||||
})
|
||||
);
|
||||
|
||||
const all = async () => {
|
||||
const files = await globby(['{packages,prototypes}/*/', '.'], {
|
||||
cwd: CWD
|
||||
});
|
||||
|
||||
return run(files.filter(pathname => !/node_modules/.test(pathname)));
|
||||
};
|
||||
|
||||
main(argv._.length ? run(argv._) : all());
|
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const forEach = require('apr-for-each');
|
||||
const execa = require('execa');
|
||||
const globby = require('globby');
|
||||
const main = require('apr-main');
|
||||
const argv = require('yargs').argv;
|
||||
const path = require('path');
|
||||
|
||||
const run = async (files = []) =>
|
||||
forEach(files, async file =>
|
||||
execa('quality-docs', [file], {
|
||||
stdio: 'inherit'
|
||||
})
|
||||
);
|
||||
|
||||
const all = async () => {
|
||||
const files = await globby(['{packages,prototypes}/**/*.md', './*.md'], {
|
||||
cwd: path.join(__dirname, '..')
|
||||
});
|
||||
|
||||
return run(files.filter(pathname => !/node_modules/.test(pathname)));
|
||||
};
|
||||
|
||||
main(argv._.length ? run(argv._) : all());
|
@ -1,151 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { readFile, exists } = require('mz/fs');
|
||||
const sgf = require('staged-git-files');
|
||||
const execa = require('execa');
|
||||
const awaitify = require('apr-awaitify');
|
||||
const asyncFilter = require('apr-filter');
|
||||
const main = require('apr-main');
|
||||
const map = require('apr-map');
|
||||
const reduce = require('apr-reduce');
|
||||
const globby = require('globby');
|
||||
const path = require('path');
|
||||
const uniq = require('lodash.uniq');
|
||||
const argv = require('yargs').argv;
|
||||
const checksum = require('checksum');
|
||||
const { lstatSync, readdirSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const ROOT = path.join(__dirname, '..');
|
||||
const getStaged = awaitify(sgf);
|
||||
|
||||
const statuses = [
|
||||
'Added',
|
||||
'Copied',
|
||||
'Deleted',
|
||||
'Modified',
|
||||
'Renamed',
|
||||
'Unmerged'
|
||||
];
|
||||
|
||||
const exec = (args = []) =>
|
||||
execa('lerna', args, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
const lint = scope => exec(['run', 'lint', '--scope', scope]);
|
||||
const test = scope => exec(['run', 'test', '--scope', scope]);
|
||||
|
||||
const run = async scope => {
|
||||
if (argv.lint) {
|
||||
await lint(scope);
|
||||
}
|
||||
|
||||
if (argv.test) {
|
||||
await test(scope);
|
||||
}
|
||||
};
|
||||
|
||||
const runLint = async scope => {
|
||||
await lint(scope);
|
||||
};
|
||||
|
||||
const runTest = async scope => {
|
||||
await test(scope);
|
||||
};
|
||||
|
||||
const getUnstaged = async () => {
|
||||
const unstaged = await execa('git', ['ls-files', '-m']);
|
||||
return unstaged.stdout.split('\n');
|
||||
};
|
||||
|
||||
const asyncChecksum = awaitify(checksum.file);
|
||||
|
||||
const add = async filename => execa('git', ['add', filename]);
|
||||
|
||||
const runLintAndGitAdd = async (staged, pkgs) => {
|
||||
const unstaged = (await getUnstaged()).map(file => path.resolve(ROOT, file));
|
||||
|
||||
const existing = await asyncFilter(staged, ({ filename }) =>
|
||||
exists(filename)
|
||||
);
|
||||
|
||||
const checksums = await map(existing, async file => {
|
||||
const checksum = await asyncChecksum(file.filename);
|
||||
return Object.assign({}, file, { checksum });
|
||||
});
|
||||
|
||||
await map(pkgs.map(({ name }) => name), runLint);
|
||||
|
||||
const changed = await asyncFilter(
|
||||
checksums,
|
||||
async ({ filename, checksum }) => {
|
||||
const newChecksum = await asyncChecksum(filename);
|
||||
return checksum != newChecksum;
|
||||
}
|
||||
);
|
||||
|
||||
const modifieds = await reduce(
|
||||
changed,
|
||||
async (modifieds, file) => {
|
||||
const isUnstaged = unstaged.filter(f => f === file.filename).length;
|
||||
if (
|
||||
(file.status === 'Modified' || file.status === 'Added') &&
|
||||
isUnstaged
|
||||
) {
|
||||
modifieds.push(file);
|
||||
} else {
|
||||
await add(file.filename);
|
||||
}
|
||||
return modifieds;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
if (modifieds.length) {
|
||||
modifieds.forEach(modified =>
|
||||
console.log('PARTIALLY STAGED FILE ', modified.filename)
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
const gather = async () => {
|
||||
const isDirectory = source => lstatSync(source).isDirectory();
|
||||
const getDirectories = source =>
|
||||
readdirSync(source)
|
||||
.map(name => join(source, name))
|
||||
.filter(isDirectory);
|
||||
|
||||
const locations = await globby(
|
||||
getDirectories('./packages').concat(getDirectories('./prototypes')),
|
||||
{ cwd: ROOT }
|
||||
);
|
||||
|
||||
const staged = (await getStaged())
|
||||
.filter(({ status }) => statuses.indexOf(status) >= 0)
|
||||
// .map(({ filename }) => path.resolve(ROOT, filename));
|
||||
.map(file =>
|
||||
Object.assign({}, file, { filename: path.resolve(ROOT, file.filename) })
|
||||
);
|
||||
|
||||
const folders = uniq(
|
||||
locations
|
||||
.map(folder => path.resolve(ROOT, folder))
|
||||
.filter(folder => staged.some(i => i.filename.indexOf(folder) >= 0))
|
||||
);
|
||||
|
||||
const pkgs = await map(folders, async folder =>
|
||||
JSON.parse(await readFile(path.join(folder, 'package.json'), 'utf-8'))
|
||||
);
|
||||
|
||||
if (argv.lint) {
|
||||
await runLintAndGitAdd(staged, pkgs);
|
||||
}
|
||||
|
||||
if (argv.test) {
|
||||
await await map(pkgs.map(({ name }) => name), runTest);
|
||||
}
|
||||
};
|
||||
|
||||
main(gather());
|
Loading…
Reference in New Issue
Block a user