Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript + Monorepo + Various fixes #144

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
root = true

[*]
indent_style = tab
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
node_modules
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"rules": {
"no-warning-comments": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "_"
}
],
"prettier/prettier": [
"error",
{
"tabWidth": 2,
"singleQuote": true,
"semi": false
}
],
"import/no-unresolved": "off",
"import/named": "off",
"import/order": ["error", {"groups": ["builtin", "external", "parent", "sibling", "index"], "newlines-between": "always"}]
}
}
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install and test
- name: Run tests
run: |
node --version
npm --version
npm install
npm test
yarn --version
yarn
yarn test:ci
env:
CI: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
node_modules
.nyc_output
lib
lerna-debug.log
package-lock.json
yarn-error.log
tsconfig.tsbuildinfo
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"name": "Jest Current File",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"${relativeFile}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"**/lib": true
}
}
13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
],
}
165 changes: 87 additions & 78 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,93 @@
'use strict';
const Observable = require('rxjs').Observable;
const logSymbols = require('log-symbols');
const delay = require('delay');
const Listr = require('.');
/* eslint-disable @typescript-eslint/no-var-requires */
'use strict'
const Observable = require('rxjs').Observable
const logSymbols = require('log-symbols')
const delay = require('delay')

const renderer = process.argv[2];
const Listr = require('./packages/listr/lib')

const tasks = new Listr([
{
title: 'Git',
task: () => {
return new Listr([
{
title: 'Checking git status',
task: () => {
return new Observable(observer => {
observer.next('foo');
const renderer = process.argv[2]

delay(2000)
.then(() => {
observer.next('bar');
return delay(2000);
})
.then(() => {
observer.complete();
});
});
}
},
{
title: 'Checking remote history',
task: () => delay(2000)
}
], {concurrent: true});
}
},
{
title: 'Install dependencies with Yarn',
task: (ctx, task) => {
return delay(2000)
.then(() => {
ctx.yarn = false;
const tasks = new Listr(
[
{
title: 'Git',
task: () => {
return new Listr(
[
{
title: 'Checking git status',
task: () => {
return new Observable((observer) => {
observer.next('foo')

task.title = `${task.title} (or not)`;
task.skip('Yarn not available');
});
}
},
{
title: 'Install dependencies with npm',
enabled: ctx => ctx.yarn === false,
task: () => delay(3000)
},
{
title: 'Run tests',
task: () => delay(2000).then(() => {
return new Observable(observer => {
observer.next('clinton && xo && ava');
delay(2000)
.then(() => {
observer.next('bar')
return delay(2000)
})
.then(() => {
observer.complete()
})
})
},
},
{
title: 'Checking remote history',
task: () => delay(2000),
},
],
{ concurrent: true }
)
},
},
{
title: 'Install dependencies with Yarn',
task: (ctx, task) => {
return delay(2000).then(() => {
ctx.yarn = false

delay(2000)
.then(() => {
observer.next(`${logSymbols.success} 7 passed`);
return delay(2000);
})
.then(() => {
observer.complete();
});
});
})
},
{
title: 'Publish package',
task: () => delay(1000).then(() => {
throw new Error('Package name already exists');
})
}
], {
renderer
});
task.title = `${task.title} (or not)`
task.skip('Yarn not available')
})
},
},
{
title: 'Install dependencies with npm',
enabled: (ctx) => ctx.yarn === false,
task: () => delay(3000),
},
{
title: 'Run tests',
task: () =>
delay(2000).then(() => {
return new Observable((observer) => {
observer.next('clinton && xo && ava')

tasks.run().catch(error => {
console.error(error.message);
});
delay(2000)
.then(() => {
observer.next(`${logSymbols.success} 7 passed`)
return delay(2000)
})
.then(() => {
observer.complete()
})
})
}),
},
{
title: 'Publish package',
task: () =>
delay(1000).then(() => {
throw new Error('Package name already exists')
}),
},
],
{
renderer,
}
)

tasks.run().catch((error) => {
console.error(error.message)
})