Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
sourceType: 'module'
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
],
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'prettier/prettier': ['none', { trailingComma: 'es5' }],
},
}
'@typescript-eslint/no-unused-vars': 'error'
}
};
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"trailingComma": "none",
"endOfLine": "auto",
"singleQuote": true,
"printWidth": 120
}
15 changes: 0 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# Changelog

<a name="next"></a>
## next

### Changed

- 🔧 ci: fix global install script [[c549323](https://github.com/ngx-devs/ngx-devs-cli/commit/c5493238feb4f9138538632e6189cbdc7d8a80ce)]
- 🔧 ci: install changelog globally [[b57ca29](https://github.com/ngx-devs/ngx-devs-cli/commit/b57ca298fc97b37ddd018b31ae585c6e2c8df4c3)]
- 🔧 ci: update changelog script [[33993dd](https://github.com/ngx-devs/ngx-devs-cli/commit/33993dd500ed44f60f45836231f86ac58780458a)]

### Miscellaneous

- 🚧 chore: remove other changelog plugins [[0719447](https://github.com/ngx-devs/ngx-devs-cli/commit/0719447e49ba7ca83d66933052a3bd017d93ddb0)]
- 🚧 chore: change releaserc from js to json [[6909cd3](https://github.com/ngx-devs/ngx-devs-cli/commit/6909cd3f53a438016bd1db4036f5111731dee124)]


<a name="1.9.0"></a>
## 1.9.0 (2022-05-28)

Expand Down
3 changes: 0 additions & 3 deletions cli-test-setup.ts

This file was deleted.

7 changes: 6 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
module.exports = { extends: ['gitmoji'] };
module.exports = {
extends: ['gitmoji'],
rules: {
'header-max-length': [0, 'always', 80]
}
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
testPathIgnorePatterns: ['/build/', '/templates/'],
globals: {
'ts-jest': {
tsConfig: 'tsconfig.spec.json'
tsconfig: 'tsconfig.spec.json'
}
}
};
46 changes: 34 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ ngxd g c sample

</div>

---

## :robot: Commands

```bash
Expand All @@ -89,22 +91,22 @@ ngxd new <project-name>

### Components

##### :hammer_and_wrench: **basic**
##### :hammer_and_wrench: **common**

```bash
# create a new basic component
ngxd generate component basic <component-name>
# create a new common component
ngxd generate component common <component-name>
# or
ngxd g c b <component-name>
ngxd g c c <component-name>
```

##### :hammer_and_wrench: **widget**
##### :hammer_and_wrench: **dialog**

```bash
# create a new widget component
ngxd generate component widget <component-name>
# create a new dialog component
ngxd generate component dialog <component-name>
# or
ngxd g c w <component-name>
ngxd g c d <component-name>
```

##### :hammer_and_wrench: **page**
Expand All @@ -116,13 +118,33 @@ ngxd generate component page <component-name>
ngxd g c p <component-name>
```

##### :hammer_and_wrench: **dialog**
##### :hammer_and_wrench: **widget**

```bash
# create a new dialog component
ngxd generate component dialog <component-name>
# create a new widget component
ngxd generate component widget <component-name>
# or
ngxd g c d <component-name>
ngxd g c w <component-name>
```

### Services

##### :hammer_and_wrench: **common**

```bash
# create a new common service
ngxd generate service common <service-name>
# or
ngxd g s c <service-name>
```

##### :hammer_and_wrench: **api**

```bash
# create a new api service
ngxd generate service api <service-name>
# or
ngxd g s a <service-name>
```

## :boy: **Author**
Expand Down
12 changes: 2 additions & 10 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ async function run(argv) {
.brand('ngx-devs-cli')
.src(__dirname)
.plugins('./node_modules', { matching: 'ngx-devs-cli-*', hidden: true })
.exclude([
'meta',
'semver',
'system',
'http',
'patching',
'package-manager'
])
.exclude(['meta', 'semver', 'system', 'http', 'patching', 'package-manager'])
.create();

const toolbox = await cli.run(argv);
return toolbox;
return cli.run(argv);
}

module.exports = { run };
8 changes: 4 additions & 4 deletions src/commands/generate/component/common/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filesystem } from 'gluegun';

import { cli } from '@ngxd/cli-test-setup';
import { runNgxdCLI } from '../../../../utils/cli-test-setup';

describe('[Commands: generate common component]', () => {
beforeEach(() => {
Expand All @@ -14,7 +14,7 @@ describe('[Commands: generate common component]', () => {

test('should generate a common component with 3 files', async () => {
const name = 'sample-with-three-files';
await cli(`g c c ${name}`);
await runNgxdCLI(`g c c ${name}`);

const html = filesystem.read(`${name}/${name}.component.html`);
const scss = filesystem.read(`${name}/${name}.component.scss`);
Expand All @@ -29,7 +29,7 @@ describe('[Commands: generate common component]', () => {
test('should generate a common component html with default template <p>sample works</p>', async () => {
const name = 'sample-with-default-template';

await cli(`g c c ${name}`);
await runNgxdCLI(`g c c ${name}`);

const html = filesystem.read(`${name}/${name}.component.html`);

Expand All @@ -39,7 +39,7 @@ describe('[Commands: generate common component]', () => {

test('should generate a common component with correct templateUrl: and styleUrls ', async () => {
const name = 'sample-style-template-url';
await cli(`g c c ${name}`);
await runNgxdCLI(`g c c ${name}`);

const ts = filesystem.read(`${name}/${name}.component.ts`);

Expand Down
6 changes: 3 additions & 3 deletions src/commands/generate/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { findCommand } from '../../../utils/functions.helper';
const COMMAND: GluegunCommand = {
name: 'component',
alias: ['c'],
description: 'Cria um componente Angular de tipo específico',
description: 'Cria um componente Angular',

run: async (toolbox: GluegunToolbox) => {
const { parameters, prompt } = toolbox;

let componentName = parameters.first;
const componentName = parameters.first;

const QUESTION = 'Qual tipo de componente você deseja criar?';
const TYPES = ['common', 'page', 'widget', 'layout', 'dialog'];
Expand All @@ -27,7 +27,7 @@ const COMMAND: GluegunCommand = {
const command = findCommand(toolbox, componentType);

toolbox.parameters.first = componentName;
command.run(toolbox);
command?.run(toolbox);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/commands/generate/component/dialog/dialog.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filesystem } from 'gluegun';

import { cli } from '@ngxd/cli-test-setup';
import { runNgxdCLI } from '../../../../utils/cli-test-setup';

describe('[Commands: generate dialog component]', () => {
const name = 'gdc';
Expand All @@ -16,7 +16,7 @@ describe('[Commands: generate dialog component]', () => {
});

test('should generate a dialog component with 3 files', async () => {
await cli(`g c d ${name}`);
await runNgxdCLI(`g c d ${name}`);

const html = filesystem.read(`${name}/${name}.dialog.html`);
const scss = filesystem.read(`${name}/${name}.dialog.scss`);
Expand All @@ -28,14 +28,14 @@ describe('[Commands: generate dialog component]', () => {
});

test('should generate a dialog component html with default template <p>sample works</p>', async () => {
await cli(`g c d ${name}`);
await runNgxdCLI(`g c d ${name}`);
const html = filesystem.read(`${name}/${name}.dialog.html`);

expect(html).toContain(`<p>${name} works</p>`);
});

test('should generate a dialog component with correct templateUrl: and styleUrls ', async () => {
await cli(`g c d ${name}`);
await runNgxdCLI(`g c d ${name}`);

const ts = filesystem.read(`${name}/${name}.dialog.ts`);

Expand Down
8 changes: 4 additions & 4 deletions src/commands/generate/component/page/page.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filesystem } from 'gluegun';

import { cli } from '@ngxd/cli-test-setup';
import { runNgxdCLI } from '../../../../utils/cli-test-setup';

describe('[Commands: generate page component]', () => {
const name = 'gpc';
Expand All @@ -16,7 +16,7 @@ describe('[Commands: generate page component]', () => {
});

test('should generate a page component with 3 files', async () => {
await cli(`g c p ${name}`);
await runNgxdCLI(`g c p ${name}`);

const html = filesystem.read(`${name}/${name}.page.html`);
const scss = filesystem.read(`${name}/${name}.page.scss`);
Expand All @@ -28,14 +28,14 @@ describe('[Commands: generate page component]', () => {
});

test('should generate a page component html with default template <p>sample works</p>', async () => {
await cli(`g c p ${name}`);
await runNgxdCLI(`g c p ${name}`);
const html = filesystem.read(`${name}/${name}.page.html`);

expect(html).toContain(`<p>${name} works</p>`);
});

test('should generate a page component with correct templateUrl: and styleUrls ', async () => {
await cli(`g c p ${name}`);
await runNgxdCLI(`g c p ${name}`);

const ts = filesystem.read(`${name}/${name}.page.ts`);

Expand Down
10 changes: 5 additions & 5 deletions src/commands/generate/component/widget/widget.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filesystem } from 'gluegun';

import { cli } from '@ngxd/cli-test-setup';
import { runNgxdCLI } from '../../../../utils/cli-test-setup';

describe('[Commands: generate widget component]', () => {
const name = 'gwc';
Expand All @@ -17,7 +17,7 @@ describe('[Commands: generate widget component]', () => {

test('should generate a widget component on provided path', async () => {
const path = 'sample-project/components';
await cli(`g c w ${name} --path=${path}`);
await runNgxdCLI(`g c w ${name} --path=${path}`);

const html = filesystem.read(`${path}/${name}/${name}.component.html`);
const scss = filesystem.read(`${path}/${name}/${name}.component.scss`);
Expand All @@ -33,7 +33,7 @@ describe('[Commands: generate widget component]', () => {
});

test('should generate widget component with 4 files', async () => {
await cli(`g c w ${name}`);
await runNgxdCLI(`g c w ${name}`);

const html = filesystem.read(`${name}/${name}.component.html`);
const scss = filesystem.read(`${name}/${name}.component.scss`);
Expand All @@ -47,14 +47,14 @@ describe('[Commands: generate widget component]', () => {
});

test('should generate widget component html with default template <p>sample works</p>', async () => {
await cli(`g c w ${name}`);
await runNgxdCLI(`g c w ${name}`);
const html = filesystem.read(`${name}/${name}.component.html`);

expect(html).toContain(`<p>${name} works</p>`);
});

test('should generate a widget component with correct templateUrl: and styleUrls ', async () => {
await cli(`g c w ${name}`);
await runNgxdCLI(`g c w ${name}`);

const ts = filesystem.read(`${name}/${name}.component.ts`);

Expand Down
27 changes: 10 additions & 17 deletions src/commands/generate/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,22 @@ const COMMAND: GluegunCommand = {
description: 'Cria uma nova entidade',
alias: ['g'],
run: async (toolbox: GluegunToolbox) => {
const { prompt } = toolbox
const { prompt } = toolbox;

const GENERATE_MODEL_TYPE_QUESTION =
'Qual o tipo de entidade que você deseja criar?'
const GENERATE_MODEL_TYPE_QUESTION = 'Qual o tipo de entidade que você deseja criar?';

const GENERATE_MODEL_TYPE_OPTIONS = [
'component',
'directive',
'guard',
'interceptor',
'module',
]
const GENERATE_MODEL_TYPE_OPTIONS = ['component', 'directive', 'guard', 'interceptor', 'module'];

const modelTypeResponse: GluegunAskResponse = await prompt.ask({
type: 'select',
name: 'type',
message: GENERATE_MODEL_TYPE_QUESTION,
choices: GENERATE_MODEL_TYPE_OPTIONS,
})
choices: GENERATE_MODEL_TYPE_OPTIONS
});

const command = findCommand(toolbox, modelTypeResponse.type)
command.run(toolbox)
},
}
const command = findCommand(toolbox, modelTypeResponse.type);
command?.run(toolbox);
}
};

module.exports = COMMAND
module.exports = COMMAND;
Loading