Skip to content

Commit edc9929

Browse files
Update Lib (#6)
1 parent c122fad commit edc9929

25 files changed

+179
-415
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Please check if your PR fulfills the following requirements:
1313
- [ ] I followed GitFlow pattern to create the branch
1414
- [ ] Tests for the changes have been added
1515
- [ ] I created a PR to add / update the documentation (or aren't necessary)
16-
- [ ] The `package.json` version has been upgraded
1716
- [ ] The changes has been added to `CHANGELOG.md`
1817
- [ ] My code produces no warnings or errors
1918

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ This is the CLI for for [@techmmunity/symbiosis](https://github.com/techmmunity/
3535
With yarn
3636

3737
```
38-
yarn add @techmmunity/symbiosis reflect-metadata @techmmunity/symbiosis-cli
38+
yarn add @techmmunity/symbiosis-cli
3939
```
4040

4141
With npm
4242

4343
```
44-
npm i --save @techmmunity/symbiosis reflect-metadata @techmmunity/symbiosis-cli
44+
npm i @techmmunity/symbiosis-cli
4545
```
4646

4747
## Usage
48+
49+
Please, check [the docs](https://symbiosis.techmmunity.com.br/docs/overview/cli) for more information.

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@techmmunity/symbiosis-cli",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"main": "index.js",
55
"types": "index.d.ts",
66
"license": "Apache-2.0",
77
"author": "Techmmunity",
88
"description": "CLI for @techmmunity/symbiosis",
9-
"homepage": "https://github.com/techmmunity/symbiosis-cli#readme",
9+
"homepage": "https://symbiosis.techmmunity.com.br/",
1010
"bin": {
1111
"symb": "./cli/bin/index.js"
1212
},
@@ -28,22 +28,20 @@
2828
"techmmunity-symbiosis"
2929
],
3030
"peerDependencies": {
31-
"@techmmunity/symbiosis": "^0.0.21",
31+
"@techmmunity/symbiosis": "^0.0.24",
3232
"reflect-metadata": "^0.1.13",
3333
"typescript": "^4.4.4"
3434
},
3535
"dependencies": {
36-
"@techmmunity/utils": "^1.4.0",
37-
"@types/glob": "^7.2.0",
36+
"@techmmunity/utils": "^1.5.0",
3837
"chalk": "^4.1.2",
39-
"commander": "^8.3.0",
40-
"glob": "^7.2.0"
38+
"commander": "^8.3.0"
4139
},
4240
"devDependencies": {
43-
"@techmmunity/eslint-config": "^5.0.4",
44-
"@techmmunity/symbiosis": "^0.0.21",
41+
"@techmmunity/eslint-config": "^5.1.2",
42+
"@techmmunity/symbiosis": "^0.0.24",
4543
"@types/jest": "^27.0.1",
46-
"eslint": "^7.32.0",
44+
"eslint": "^8.1.0",
4745
"husky": "^7.0.4",
4846
"jest": "^27.3.1",
4947
"lint-staged": "^11.2.3",
@@ -56,7 +54,7 @@
5654
},
5755
"scripts": {
5856
"prepare": "husky install",
59-
"dev": "env-cmd ts-node src/index.ts",
57+
"dev": "ts-node src/index.ts",
6058
"test": "jest --passWithNoTests",
6159
"test:cov": "jest --coverage --passWithNoTests",
6260
"build": "rimraf ./dist && tsc --build --force && cp -r src/cli/templates dist/cli/templates && rimraf ./dist/tests",

src/cli/bin/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* eslint-disable @typescript-eslint/no-require-imports */
44
/* eslint-disable @typescript-eslint/no-var-requires */
55

6+
import { getRootPath } from "@techmmunity/utils";
67
import { program } from "commander";
78

89
import { loadCommands } from "../commands";
@@ -11,9 +12,13 @@ import { localBinExists } from "../utils/local-bin-exists";
1112
import { loadLocalBinCommandLoader } from "../utils/local-binaries";
1213

1314
const bootstrap = () => {
15+
const packageJsonPath = getRootPath(
16+
"node_modules/@techmmunity/symbiosis-cli/package.json",
17+
);
18+
1419
program
1520
.version(
16-
require("../../package.json").version,
21+
require(packageJsonPath).version,
1722
"-v, --version",
1823
"Output the current version.",
1924
)

src/cli/commands/gen-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { getRootPath } from "@techmmunity/utils";
12
import { writeFileSync } from "fs";
23

3-
import { getRootPath } from "../utils/get-root-path";
44
import { getTemplate } from "../utils/get-template";
55

66
export const genConfig = () => {

src/cli/commands/gen-migration/gen-migration.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
import { existsSync, writeFileSync } from "fs";
44

5-
import { cleanObj, isEmptyObject } from "@techmmunity/utils";
5+
import { cleanObj, getRootPath, isEmptyObject } from "@techmmunity/utils";
6+
import { loadEntities, Logger } from "@techmmunity/symbiosis";
67
import { getConfigFile } from "../../utils/get-config-file";
7-
import { getRootPath } from "../../utils/get-root-path";
8-
import { Logger } from "../../../utils/logger";
98

109
import { getMigrationsPath } from "../../utils/get-migrations-path";
1110
import { MigrationGenerator } from "../../../lib/migration-generator";
1211
import { Plugin } from "../types/plugin";
1312
import { getTemplate } from "../../utils/get-template";
1413
import { getSymbVersion } from "../../utils/get-symb-version";
15-
import { loadEntities } from "../../utils/load-entities";
1614
import { getColType } from "./helpers/get-col-type";
1715

1816
export const genMigrations = async () => {
@@ -23,7 +21,7 @@ export const genMigrations = async () => {
2321
const pluginPath = getRootPath(`node_modules/${plugin}`);
2422

2523
if (!existsSync(pluginPath)) {
26-
Logger.error(`Plugin not found: ${plugin}`);
24+
Logger.cliError(`Plugin not found: ${plugin}`);
2725

2826
process.exit(1);
2927
}

src/cli/commands/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import * as chalk from "chalk";
1+
import { Logger } from "@techmmunity/symbiosis";
2+
import { red } from "chalk";
23
import { Command } from "commander";
3-
import { Logger } from "../../utils/logger";
44

55
import { genConfig } from "./gen-config";
66
import { genMigrations } from "./gen-migration/gen-migration";
77
import { createMigration } from "./migration-create";
88

99
const handleInvalidCommand = (program: Command) => {
1010
program.on("command:*", () => {
11-
Logger.error(`Invalid command: ${chalk.red("%s")}`);
11+
Logger.cliError(`Invalid command: ${red("%s")}`);
1212

13-
Logger.log(
14-
`See ${chalk.red("--help")} for a list of available commands.\n`,
15-
);
13+
Logger.cliLog(`See ${red("--help")} for a list of available commands.\n`);
1614

1715
process.exit(1);
1816
});

src/cli/commands/run-migrations.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
22

33
import { readdirSync } from "fs";
4-
import { isEmptyArray } from "@techmmunity/utils";
4+
import { isEmptyArray, isPackageInstalled } from "@techmmunity/utils";
55

6+
import { loadEntities, Logger } from "@techmmunity/symbiosis";
67
import { getConfigFile } from "../utils/get-config-file";
7-
import { Logger } from "../../utils/logger";
88

99
import { BaseQueryRunner } from "../../lib/query-runner";
1010
import { getMigrationsPath } from "../utils/get-migrations-path";
1111
import { Plugin } from "./types/plugin";
12-
import { loadEntities } from "../utils/load-entities";
13-
import { isPackageInstalled } from "../utils/package-installed";
1412

1513
interface MigrationFile {
1614
Migration: {
@@ -27,7 +25,7 @@ export const runMigrations = async () => {
2725
const { connectionConfig, plugin, entitiesDir } = getConfigFile();
2826

2927
if (!isPackageInstalled(plugin)) {
30-
Logger.error(`Plugin not found: ${plugin}`);
28+
Logger.cliError(`Plugin not found: ${plugin}`);
3129

3230
process.exit(1);
3331
}
@@ -53,7 +51,7 @@ export const runMigrations = async () => {
5351
);
5452

5553
if (isEmptyArray(notExecutedMigrations)) {
56-
Logger.log("Everything is already synced.");
54+
Logger.cliLog("Everything is already synced.");
5755

5856
process.exit(0);
5957
}

src/cli/config/prefixes.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/cli/utils/create-dot-symb-dir.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { getRootPath } from "@techmmunity/utils";
12
import { mkdirSync, existsSync, readFileSync, writeFileSync } from "fs";
2-
import { getRootPath } from "./get-root-path";
33

44
export const createDotSymbiosisDir = (path: string) => {
55
const dotSymbFolderPath = getRootPath(".symbiosis");

0 commit comments

Comments
 (0)