FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor: split out logger/tasks/output/spinners into package (#4527) · ionic-team/ionic-cli@58f4d2e · GitHub

Repository navigation

Commit 58f4d2e

Browse files
authored
refactor: split out logger/tasks/output/spinners into package (#4527)
1 parent a534c4a commit 58f4d2e

29 files changed

Lines changed: 380 additions & 165 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Drifty Co
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
of the Software, and to permit persons to whom the Software is furnished to do
10+
so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @ionic/cli-framework-output
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../../jest.config.base');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../../lint-staged.config.base');
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "@ionic/cli-framework-output",
3+
"version": "1.0.0",
4+
"description": "The log/tasks/spinners portion of Ionic CLI Framework",
5+
"homepage": "https://ionicframework.com/",
6+
"author": "Ionic Team <hi@ionic.io> (https://ionicframework.com)",
7+
"main": "./dist/index.js",
8+
"types": "./dist/index.d.ts",
9+
"engines": {
10+
"node": ">=10.3.0"
11+
},
12+
"files": [
13+
"dist/",
14+
"LICENSE",
15+
"README.md"
16+
],
17+
"scripts": {
18+
"clean": "rimraf dist",
19+
"lint": "tslint --project tsconfig.json",
20+
"build": "npm run clean && tsc",
21+
"watch": "tsc -w --preserveWatchOutput",
22+
"test": "jest --maxWorkers=4",
23+
"prepublishOnly": "npm run build"
24+
},
25+
"license": "MIT",
26+
"dependencies": {
27+
"debug": "^4.0.0",
28+
"log-update": "^4.0.0",
29+
"slice-ansi": "^4.0.0",
30+
"string-width": "^4.1.0",
31+
"strip-ansi": "^6.0.0",
32+
"tslib": "1.11.2",
33+
"wrap-ansi": "^7.0.0"
34+
},
35+
"devDependencies": {
36+
"@ionic/utils-stream": "3.1.3",
37+
"@types/debug": "^4.1.1",
38+
"@types/inquirer": "0.0.43",
39+
"@types/jest": "^25.1.0",
40+
"@types/node": "~10.17.13",
41+
"@types/slice-ansi": "^4.0.0",
42+
"@types/wrap-ansi": "^3.0.0",
43+
"jest": "^25.1.0",
44+
"jest-cli": "^26.0.1",
45+
"lint-staged": "^10.0.2",
46+
"ts-jest": "~25.4.0",
47+
"tslint": "^5.9.1",
48+
"typescript": "~3.8.2"
49+
}
50+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { wordWrap } from '../format';
2+
3+
describe('@ionic/cli-framework-output', () => {
4+
5+
describe('format', () => {
6+
7+
describe('wordWrap', () => {
8+
9+
it('should do nothing to empty string', () => {
10+
const result = wordWrap('', {});
11+
expect(result).toEqual('');
12+
});
13+
14+
it('should do nothing to newline', () => {
15+
const result = wordWrap('\n', {});
16+
expect(result).toEqual('\n');
17+
});
18+
19+
it('should wrap words', () => {
20+
const result = wordWrap('hello world', { width: 5 });
21+
expect(result).toEqual('hello\nworld');
22+
});
23+
24+
it('should wrap words with proper indentation', () => {
25+
const result = wordWrap('hello world', { width: 5, indentation: 5 });
26+
expect(result).toEqual('hello\n world');
27+
});
28+
29+
it('should wrap many words', () => {
30+
const result = wordWrap(`I'm sorry Dave, I'm afraid I can't do that.`, { width: 10 });
31+
expect(result).toEqual(`I'm sorry\nDave, I'm\nafraid I\ncan't do\nthat.`);
32+
});
33+
34+
it('should wrap a command and append a character', () => {
35+
const result = wordWrap(`git commit -m 'Initial commit' --no-gpg-sign`, { width: 40, indentation: 4, append: ' \\' });
36+
expect(result).toEqual(`git commit -m 'Initial commit' \\\n --no-gpg-sign`);
37+
});
38+
39+
});
40+
41+
});
42+
43+
});

packages/@ionic/cli-framework/src/lib/__tests__/logger.ts renamed to packages/@ionic/cli-framework-output/src/__tests__/logger.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { WritableStreamBuffer } from '@ionic/utils-stream';
2-
import stripAnsi = require('strip-ansi');
3-
4-
import { wordWrap } from '../../utils/format';
52

63
import { LOGGER_LEVELS, Logger, LoggerHandler, StreamHandler, createPrefixedFormatter, createTaggedFormatter } from '../logger';
4+
import { stripAnsi, wordWrap } from '../format';
75

8-
describe('@ionic/cli-framework', () => {
6+
describe('@ionic/cli-framework-output', () => {
97

10-
describe('lib/logger', () => {
8+
describe('logger', () => {
119

1210
describe('Logger', () => {
1311

packages/@ionic/cli-framework/src/lib/__tests__/tasks.ts renamed to packages/@ionic/cli-framework-output/src/__tests__/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Task, TaskChain } from '../tasks';
22

3-
describe('@ionic/cli-framework', () => {
3+
describe('@ionic/cli-framework-output', () => {
44

5-
describe('lib/tasks', () => {
5+
describe('tasks', () => {
66

77
describe('Task', () => {
88

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL