Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
Merge 49838e7 into 3750a6d
Browse files Browse the repository at this point in the history
  • Loading branch information
Alorel committed Sep 29, 2018
2 parents 3750a6d + 49838e7 commit 0c4518d
Show file tree
Hide file tree
Showing 124 changed files with 5,985 additions and 376 deletions.
9 changes: 9 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- Please only include exactly one feature/bugfix per commit.
- Please use the [Angular commit message format](https://github.com/bcoe/conventional-changelog-standard/blob/61da424c2aabf93ff9302b42d6fc2c17ff95c087/convention.md) for your commits.
- When applicable, please use an appropriate scope, e.g. if fixing a bug in the *foo* feature, the commit message could look something like `fix(foo): The hug() method no longer eats babies`.
- Please ensure that your branch is up to date with master before opening the pull request.
- Please ensure that there is adequate test coverage for your code: run `yarn test` and see the `coverage` directory.
- Please lint your work; see [package.json](https://github.com/Alorel/personal-build-tools/blob/master/package.json).
- Please ensure that your code is well-documented. Add README entries if applicable.
- If your pull request is a work in progress, please start the title with `[WIP]`, e.g. `[WIP] One glorious feature`
- Please ensure you use [yarn package manager](https://yarnpkg.com) and not npm.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [ ] I have read the README and API docs (if applicable); the issue is not covered there.
- [ ] I have searched the repository issues and pull requests; my query is not covered there.

-----

Issue goes here.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug Report
about: Something isn't working

---

- [ ] I have read the README and API docs (if applicable); the issue is not covered there.
- [ ] I have searched the repository issues and pull requests; my query is not covered there.

-----

- **Expected behaviour**: XXXXX
- **Actual behaviour**: XXXXX
- **Environment**:
- **Node version**: x.y.z
- **Browser and browser version (if applicable)**: XXXXX
- **Steps to reproduce**:
- Step 1
- Step 2
- ...
- Step n
- **Reproducible code sample**:
- **[stackblitz.com](https://stackblitz.com)** (preferred):
- **Git repository** (*only* if a Stackblitz example is not possible):

-----

Additional information, screenshots etc go here.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature Request
about: I want new functionality

---

- [ ] I have read the README and API docs (if applicable); the issue is not covered there.
- [ ] I have searched the repository issues and pull requests; my query is not covered there.

-----

- **Describe the feature**: XXXXX
- **Why it is needed** (include use cases): XXXXX
- **Pseudocode** (non-functional schematic of how it could operate):
```javascript
const code = await getCode();
await makePR(code);
```
- [ ] I would be able to implement this feature and make a pull request.

-----

Additional information goes here.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/guidance_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Guidance Request
about: I don't know how to do something

---

- [ ] I have read the README and API docs (if applicable); the issue is not covered there.
- [ ] I have searched the repository issues and pull requests; my query is not covered there.

-----

- **Desired outcome**: XXXXX
- **My attempts**:
- **On [stackblitz.com](https://stackblitz.com)** (preferred):
- **Git repository** (*only* if a Stackblitz example is not possible):

-----

Additional information goes here.
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- [ ] I have read and followed the [contribution guidelines](https://github.com/Alorel/personal-build-tools/blob/master/.github/CONTRIBUTING.md).

My pull request is a:

- [ ] Feature
- [ ] Bug fix
- [ ] Documentation fix
- [ ] Other

-----
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/.tmp/
/package-lock.json
/git_gpg_keys.asc
/tmp.ts
/tmp.js
/tmp.sh
.idea/
node_modules/
package-lock.json
!test/fixtures/reinstall/node_modules/
!test/fixtures/reinstall/package-lock.json
dist/
coverage/
.nyc_output/
Expand Down
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ before_install:

install: yarn install --check-files --ignore-engines

script: yarn run tslint && yarn run build --noEmit && yarn test --forbid-only --forbid-pending
script:
- yarn run tslint
- yarn run build --noEmit
- if [[ $GH_TOKEN ]]; then yarn test --forbid-only --forbid-pending; else yarn test --forbid-only; fi;

after_script: if [[ $GH_TOKEN ]]; then greenkeeper-lockfile-upload; fi;
after_success: cat ./coverage/lcov.info | coveralls

cache:
yarn: true
directories:
- /home/travis/.cache/alobuild

stages:
- Test
Expand All @@ -32,8 +37,8 @@ jobs:
- npm i -g yarn
- *prepKey
before_script:
- yarn run build
- node dist/alo copy-files
- yarn run build
- node dist/alo copy-files
script: semantic-release
after_success: []
after_script: []
Binary file modified git_gpg_keys.asc.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--full-trace
-r ts-node/register
-r source-map-support/register
-t 10000
-t 20000
--trace-deprecation
--trace-warnings
--throw-deprecation
Expand Down
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,26 @@
"test:watch": "npm run test -- --watch"
},
"dependencies": {
"chalk": "^2.4.0",
"cross-spawn": "^6.0.0",
"custom-tslint-formatters": "2.4.0",
"delete-empty": "^2.0.0",
"fs-extra": "^7.0.0",
"glob": "^7.0.0",
"js-base64": "^2.4.0",
"json-to-graphql-query": "^1.7.0",
"json5": "^2.0.0",
"lodash": "^4.17.0",
"log-symbols": "^2.2.0",
"readline-sync": "^1.4.0",
"reflect-metadata": "^0.1.12",
"request": "^2.88.0",
"request-promise": "^4.2.0",
"rimraf": "^2.6.0",
"tmp": "~0.0.33",
"tslib": "^1.9.0",
"tslint": "5.11.0",
"typescript": "~3.1.1",
"typescript-lazy-get-decorator": "^1.2.0",
"yamljs": "^0.3.0",
"yargs": "^12.0.0"
Expand All @@ -61,27 +70,29 @@
"@types/delete-empty": "~2.0.0",
"@types/fs-extra": "~5.0.4",
"@types/glob": "~7.1.0",
"@types/js-base64": "~2.3.1",
"@types/json5": "~0.0.30",
"@types/lodash": "~4.14.116",
"@types/log-symbols": "~2.0.0",
"@types/mocha": "~5.2.5",
"@types/node": "~10.11.0",
"@types/readline-sync": "~1.4.3",
"@types/request": "~2.47.1",
"@types/request-promise": "~4.1.42",
"@types/rimraf": "~2.0.2",
"@types/tmp": "~0.0.33",
"@types/uuid": "~3.4.4",
"@types/yamljs": "~0.2.30",
"@types/yargs": "~12.0.0",
"bluebird": "~3.5.1",
"chai": "~4.1.2",
"chai": "~4.2.0",
"coveralls": "~3.0.2",
"cross-env": "~5.2.0",
"mocha": "~5.2.0",
"nyc": "~13.0.0",
"rimraf": "~2.6.2",
"semantic-release": "~15.9.9",
"source-map-support": "~0.5.9",
"tmp": "~0.0.33",
"ts-node": "~7.0.1",
"typescript": "~3.0.1",
"uuid": "~3.3.2"
}
}
2 changes: 1 addition & 1 deletion prepare-gpg-key.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

openssl aes-256-cbc -K $encrypted_8237d5525e3f_key -iv $encrypted_8237d5525e3f_iv -in git_gpg_keys.asc.enc -out /tmp/git_gpg_keys.asc -d
openssl aes-256-cbc -K $encrypted_3a21a8693830_key -iv $encrypted_3a21a8693830_iv -in git_gpg_keys.asc.enc -out /tmp/git_gpg_keys.asc -d
chmod 600 /tmp/git_gpg_keys.asc
gpg --batch --yes --import /tmp/git_gpg_keys.asc
echo '/usr/bin/gpg2 --passphrase ${GPG_PASSPHRASE} --batch --no-tty "$@"' > /tmp/gpg-with-passphrase && chmod +x /tmp/gpg-with-passphrase
Expand Down
6 changes: 3 additions & 3 deletions src/alo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from 'path';
import * as yargs from 'yargs';
import {addCommandDir} from './fns/addCommandDir';
import {applyGlobalGroup} from './fns/applyGlobalGroup';
import {addCommandDir} from './fns/add-cmd/addCommandDir';
import {applyGlobalGroup} from './fns/add-cmd/applyGlobalGroup';

const argv = addCommandDir(join(__dirname, 'commands'), yargs)
.scriptName('alo')
Expand All @@ -24,6 +24,6 @@ export function alo(args: string | string[]): Promise<string> {
});
}

if (!process.env.RUNNING_PERSONAL_BUILD_TOOLS_TESTS) {
if (!process.env.RUNNING_PERSONAL_BUILD_TOOLS_TESTS || process.env.RUNNING_PERSONAL_BUILD_TOOLS_TESTS_FORCE) {
argv.global('config').parse();
}
2 changes: 1 addition & 1 deletion src/commands/cfg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {noop} from 'lodash';
import {join} from 'path';
import {CommandModule} from 'yargs';
import {addCommandDir} from '../fns/addCommandDir';
import {addCommandDir} from '../fns/add-cmd/addCommandDir';
import {cmdName} from '../fns/cmdName';

const cmd: CommandModule = {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/cfg/clear.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as readline from 'readline-sync';
import {CommandModule} from 'yargs';
import {applyGlobalGroup} from '../../fns/applyGlobalGroup';
import {applyGlobalGroup} from '../../fns/add-cmd/applyGlobalGroup';
import {cmdName} from '../../fns/cmdName';
import {ConfigWriter} from '../../lib/ConfigWriter';

function prompt(): boolean {
return readline.keyInYNStrict('Are you sure you want to remove shared config?');
return readline.keyInYNStrict('Are you sure you want to remove shared config? ');
}

const cmd: CommandModule = {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cfg/rm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CommandModule} from 'yargs';
import {addCfgKey, addCfgScope, CfgRmConf} from '../../commons/cfg';
import {applyGlobalGroup} from '../../fns/applyGlobalGroup';
import {applyGlobalGroup} from '../../fns/add-cmd/applyGlobalGroup';
import {cmdName} from '../../fns/cmdName';
import {ConfigWriter} from '../../lib/ConfigWriter';

Expand Down
63 changes: 50 additions & 13 deletions src/commands/cfg/set.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,73 @@
import * as fs from 'fs';
import * as JSON5 from 'json5';
import {CommandModule} from 'yargs';
import {addCfgKey, addCfgScope, CfgRmConf} from '../../commons/cfg';
import {applyGlobalGroup} from '../../fns/applyGlobalGroup';
import {addCfgKey, addCfgScope, addEncrypt, addPwd, CfgRmConf} from '../../commons/cfg';
import {applyGlobalGroup} from '../../fns/add-cmd/applyGlobalGroup';
import {cmdName} from '../../fns/cmdName';
import {ConfigWriter} from '../../lib/ConfigWriter';
import {Crypt} from '../../lib/Crypt';
import {PromptableConfig} from '../../lib/PromptableConfig';

interface CfgSetConf extends CfgRmConf {
encrypt: boolean;

fromFile: boolean;

password: string;

value: any;
}

function tryJson5Parse(v: any): any {
try {
return JSON5.parse(v);
} catch {
return v;
}
}

const cmd: CommandModule = {
builder(argv) {
addCfgKey(argv);
applyGlobalGroup(argv);
addEncrypt(argv);

argv.option('from-file', {
default: false,
describe: 'Get the value from a file instead of the positional argument. '
+ 'The positional value argument then acts as a filepath.',
type: 'boolean'
});

addPwd(argv);

argv.positional('value', {
coerce(v: any): any {
try {
return JSON5.parse(v);
} catch {
return v;
}
},
describe: 'Config value. Can optionally be a JSON5-parseable item.'
coerce: tryJson5Parse,
describe: 'Config value. Can be a JSON5-parseable item. Optional only if the --stdin option is present.'
});

return addCfgScope(argv);
},
command: `${cmdName(__filename)} <key> <value> [scope]`,
command: `${cmdName(__filename)} <key> [value] [scope]`,
describe: 'Set a config option shared by all projects',
handler(c: CfgSetConf) {
new ConfigWriter().set(c.key, c.value, c.scope).save();
handler(c$: CfgSetConf) {
if (c$.fromFile) {
c$.value = tryJson5Parse(fs.readFileSync(c$.value, 'utf8'));
}

let val: any;

if (c$.encrypt) {
if (typeof c$.value !== 'string') {
throw new Error('Only strings can be encrypted');
}
const c = new PromptableConfig(c$);
val = Crypt.encryptVar(c$.value, c.promptedEncryptionPassword());
} else {
val = c$.value;
}

new ConfigWriter().set(c$.key, val, c$.scope).save();
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/commands/clean-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as deleteEmpty from 'delete-empty';
import * as fs from 'fs';
import {basename, dirname, join} from 'path';
import {CommandModule} from 'yargs';
import {addConfig} from '../fns/addConfig';
import {addConfig} from '../fns/add-cmd/addConfig';
import {cmdName} from '../fns/cmdName';
import {getFiles} from '../fns/getFiles';

Expand Down
4 changes: 2 additions & 2 deletions src/commands/clean-pkg-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import {has, isEmpty, unset} from 'lodash';
import {CommandModule} from 'yargs';
import {depFields} from '../const/depFields';
import {addConfig} from '../fns/addConfig';
import {addConfig} from '../fns/add-cmd/addConfig';
import {cmdName} from '../fns/cmdName';
import {flatGlobDirs} from '../fns/getFiles';
import {sortObjectByKey} from '../fns/sortObjectByKey';
Expand Down Expand Up @@ -174,7 +174,7 @@ const cmd: CommandModule = {
}

//tslint:disable-next-line:no-magic-numbers
fs.writeFileSync(file, JSON.stringify(contents, null, 2));
fs.writeFileSync(file, JSON.stringify(contents, null, 2).trim() + '\n');
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/commands/copy-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {IOptions, sync as glob} from 'glob';
import * as _ from 'lodash';
import {basename, dirname, join} from 'path';
import {CommandModule} from 'yargs';
import {addConfig} from '../fns/addConfig';
import {addConfig} from '../fns/add-cmd/addConfig';
import {cmdName} from '../fns/cmdName';
import {flattenGlob} from '../fns/flattenGlob';

Expand Down

0 comments on commit 0c4518d

Please sign in to comment.