Skip to content

Commit 660d104

Browse files
committed
fix: add eslint ignore dist folder
1 parent 4d21e48 commit 660d104

23 files changed

+61
-62
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
packages/cache/nuxt/plugin.js
55
packages/nuxt-module/plugins/i18n-cookies.js
66
packages/nuxt-module/plugins/logger.js
7+
packages/cli/dist

packages/cli/src/domains/add/endpoint/helpers/frameworkPages/next-page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'fs';
22
import { existsDirectory } from '../../../../../utils';
33
import { getNextPageCode } from '..';
44

packages/cli/src/domains/add/endpoint/helpers/frameworkPages/nuxt-page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'fs';
22
import { existsDirectory } from '../../../../../utils';
33
import { getNuxtPageCode } from '..';
44

packages/cli/src/domains/add/endpoint/helpers/getCode/getApiMethodCode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export const ${endpoint}: Endpoints['${endpoint}'] = async (
88
99
return { data: 'Hello from ${endpoint} endpoint!' };
1010
};
11-
`
11+
`;

packages/cli/src/domains/add/endpoint/helpers/getCode/getNextPageCode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ export default function Page${capitalizeFirst(endpoint)}() {
2929
);
3030
}
3131
32-
`
32+
`;

packages/cli/src/domains/add/endpoint/helpers/getCode/getNuxtPageCode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ function reset() {
4242
res.value = 'waiting to call ${endpoint}() ...'
4343
}
4444
</script>
45-
`
45+
`;

packages/cli/src/domains/add/endpoint/helpers/getCode/getSdkMethodCode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ export async function ${endpoint}(props: TODO) {
2424
const { data } = await client.post<TODO>('${endpoint}', props);
2525
return data
2626
}
27-
`
27+
`;

packages/cli/src/domains/add/endpoint/helpers/prompts/endpointName.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { intro, isCancel, text } from '@clack/prompts';
22

33
export const endpointName = async (): Promise<string> => {
4-
intro('To create a new endpoint, you need to specify its name')
4+
intro('To create a new endpoint, you need to specify its name');
55
const name = await text({
66
message: 'Enter endpoint name',
77
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -23,4 +23,4 @@ export const endpointName = async (): Promise<string> => {
2323
}
2424

2525
return name;
26-
}
26+
};

packages/cli/src/domains/add/endpoint/helpers/write/writeApiMethod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'fs';
22
import { writeToTypescriptFile } from '..';
33
import { getApiMethodCode } from '../getCode/getApiMethodCode';
44

packages/cli/src/domains/add/endpoint/helpers/write/writePageMethod.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { writeNuxtPageMethod } from '../frameworkPages/nuxt-page';
33
import { writeNextPageMethod } from '../frameworkPages/next-page';
44

55
export const writePageMethod = async (name: string) => {
6-
const frameworkName = getFrameworkName()
6+
const frameworkName = getFrameworkName();
77

88
if (frameworkName === 'nuxt') {
99
await writeNuxtPageMethod(name);
@@ -12,4 +12,4 @@ export const writePageMethod = async (name: string) => {
1212
if (frameworkName === 'next') {
1313
await writeNextPageMethod(name);
1414
}
15-
}
15+
};

packages/cli/src/domains/add/endpoint/helpers/write/writeSdkMethod.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs'
1+
import fs from 'fs';
22
import { getSDKMethodCode } from '..';
33

44
export const writeSDKMethod = async (endpoint: string, isOverwrite: boolean) => {
@@ -12,6 +12,6 @@ export const writeSDKMethod = async (endpoint: string, isOverwrite: boolean) =>
1212
if (!isFileExist) {
1313
fs.appendFileSync('./packages/sdk/src/methods/index.ts', `\nexport { ${endpoint} } from './${endpoint}';`);
1414
}
15-
fs.mkdirSync(sdkMethodPath, { recursive: true })
16-
fs.writeFileSync(`${sdkMethodPath}/index.ts`, getSDKMethodCode(endpoint))
15+
fs.mkdirSync(sdkMethodPath, { recursive: true });
16+
fs.writeFileSync(`${sdkMethodPath}/index.ts`, getSDKMethodCode(endpoint));
1717
};

packages/cli/src/domains/add/endpoint/helpers/write/writeTypescriptFile.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Project } from 'ts-morph'
1+
import { Project } from 'ts-morph';
22

33
export const writeToTypescriptFile = (path: string, endpoint: string) => {
44
const fileName = path;
@@ -30,11 +30,11 @@ export const writeToTypescriptFile = (path: string, endpoint: string) => {
3030
name: endpointName,
3131
parameters: [
3232
{ name: 'context', type: contextType },
33-
{ name: 'params', type: paramsType },
33+
{ name: 'params', type: paramsType }
3434
],
35-
returnType: `Promise<${returnType}>`,
35+
returnType: `Promise<${returnType}>`
3636
});
3737

3838
// Save the modified TypeScript file
3939
sourceFile.saveSync();
40-
}
40+
};

packages/cli/src/domains/add/endpoint/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export const makeMethod = async (name: string) => {
1313
log(`Endpoint ${name} already exists`);
1414

1515
const shouldOverwrite = await confirm({
16-
message: `Do you want to overwrite ${name} enpoint?`,
17-
})
16+
message: `Do you want to overwrite ${name} enpoint?`
17+
});
1818

1919
if (!shouldOverwrite) {
2020
log('Endpoint was not created');
@@ -28,7 +28,7 @@ export const makeMethod = async (name: string) => {
2828
await writeSDKMethod(name, isOverwrite);
2929
await writePageMethod(name);
3030

31-
intro(`Endpoint ${name} has been created`)
31+
intro(`Endpoint ${name} has been created`);
3232
log('Files created:');
3333
log(`- packages/api-client/src/api/${name}`);
3434
log(`- packages/sdk/src/methods/${name}`);
@@ -37,4 +37,4 @@ export const makeMethod = async (name: string) => {
3737
log('- packages/sdk/src/methods/index.ts');
3838
log('- packages/api-client/src/types/api/endpoints.ts');
3939
log(`Run ${picocolors.green('build')} command to build the project and ${picocolors.green('dev')} command to start the playground again`);
40-
}
40+
};

packages/cli/src/domains/create/integration/helpers/cleanUpRepositories.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { removeDir } from '../../../../utils';
33
export const cleanUpRepositories = async (
44
directoryName: string
55
): Promise<void> => {
6-
await removeDir(directoryName, '.git')
7-
await removeDir(directoryName, '.gitHub')
8-
await removeDir(directoryName + '/playground/app', '.git')
9-
await removeDir(directoryName + '/playground/app', '.github')
10-
}
6+
await removeDir(directoryName, '.git');
7+
await removeDir(directoryName, '.gitHub');
8+
await removeDir(directoryName + '/playground/app', '.git');
9+
await removeDir(directoryName + '/playground/app', '.github');
10+
};

packages/cli/src/domains/create/integration/helpers/handleDirectoryName.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const handleDirectoryName = async (projectDir: string): Promise<string> =
99

1010
if (!directoryName) {
1111
directoryName = await text({
12-
message: 'How we will name your integration?',
12+
message: 'How we will name your integration?'
1313
}) as string;
1414

1515
if (isCancel(directoryName)) {
@@ -23,7 +23,7 @@ export const handleDirectoryName = async (projectDir: string): Promise<string> =
2323
if (isDirExists) {
2424
const isOverwrite = await confirm({
2525
message: `Directory ${directoryName} already exists. Do you want to overwrite it?`,
26-
active: 'Yes',
26+
active: 'Yes'
2727
});
2828

2929
if (isCancel(isOverwrite)) {
@@ -33,7 +33,7 @@ export const handleDirectoryName = async (projectDir: string): Promise<string> =
3333

3434
if (isOverwrite) {
3535
sp.start(
36-
picocolors.cyan('deleting directory...'),
36+
picocolors.cyan('deleting directory...')
3737
);
3838
await fs.rmSync(directoryName, { recursive: true, force: true });
3939
await fs.mkdirSync(directoryName);

packages/cli/src/domains/create/integration/helpers/removeEslint.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import path from 'path';
44
const ESLINT_FILES = [
55
'.eslintrc.js',
66
'.eslintignore',
7-
'.eslintrc.json',
7+
'.eslintrc.json'
88
];
99

1010
const COMMITLINT_FILES = [
11-
'commitlint.config.js',
12-
]
11+
'commitlint.config.js'
12+
];
1313

1414
const OTHER_FILES = [
1515
'CHANGELOG.md',

packages/cli/src/utils/commands/checkCommandAndSuggest.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const checkCommandAndSuggest = async ({
1919
commands,
2020
commandArg,
2121
endpoint,
22-
self,
22+
self
2323
}: CheckCommandAndSuggest) => {
2424
const similarCommand = commands.find(({ command }) => isCloseEnough(commandArg, command));
2525

@@ -29,7 +29,7 @@ export const checkCommandAndSuggest = async ({
2929
log(`Command ${picocolors.cyan('add')} ${picocolors.yellow(`${commandArg}`)} does not exist. Did you mean ${picocolors.cyan('add')} ${picocolors.green(`${command}`)}?`);
3030

3131
const shouldRunNewCommand = await confirm({
32-
message: `Do you want to run ${picocolors.green(command)} command?`,
32+
message: `Do you want to run ${picocolors.green(command)} command?`
3333
});
3434

3535
if (isCancel(shouldRunNewCommand) || !shouldRunNewCommand) {
@@ -47,4 +47,4 @@ export const checkCommandAndSuggest = async ({
4747
log(`Command ${picocolors.yellow(commandArg)} does not exist \n\nCommand list:`);
4848
commands.forEach(({ command }) => log(`- ${picocolors.cyan('add')} ${picocolors.green(command)}`));
4949
process.exit(0);
50-
}
50+
};

packages/cli/src/utils/commands/isCloseEnough.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const levenshteinDistance = (a: string, b: string): number => {
2-
if (a.length === 0) return b.length
3-
if (b.length === 0) return a.length
2+
if (a.length === 0) return b.length;
3+
if (b.length === 0) return a.length;
44

5-
if (a[0] === b[0]) return levenshteinDistance(a.substring(1), b.substring(1))
5+
if (a[0] === b[0]) return levenshteinDistance(a.substring(1), b.substring(1));
66

77
return 1 + Math.min(
88
levenshteinDistance(a, b.substring(1)),
99
levenshteinDistance(a.substring(1), b),
1010
levenshteinDistance(a.substring(1), b.substring(1))
11-
)
12-
}
11+
);
12+
};
1313

1414
const countFrequencies = (str: string): Record<string, number> => {
1515
const freq: Record<string, number> = {};
@@ -18,7 +18,7 @@ const countFrequencies = (str: string): Record<string, number> => {
1818
freq[c] = (freq[c] || 0) + 1;
1919
}
2020
return freq;
21-
}
21+
};
2222

2323
const cosineSimilarity = (freq1: Record<string, number>, freq2: Record<string, number>): number => {
2424
const words = Array.from(new Set(Object.keys(freq1).concat(Object.keys(freq2))));
@@ -31,7 +31,7 @@ const cosineSimilarity = (freq1: Record<string, number>, freq2: Record<string, n
3131
norm2 += (freq2[word] || 0) ** 2;
3232
}
3333
return dotProduct / (Math.sqrt(norm1) * Math.sqrt(norm2));
34-
}
34+
};
3535

3636
export const isCloseEnough = (inputStr: string, targetStr: string, threshold = 0.8): boolean => {
3737
// Compute Levenshtein distance
@@ -49,4 +49,4 @@ export const isCloseEnough = (inputStr: string, targetStr: string, threshold = 0
4949
}
5050

5151
return false;
52-
}
52+
};

packages/cli/src/utils/directory/removeDir.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const removeFileOrDirectory = promisify(rimraf);
77
export const removeDir = (projectDir: string, dirName: string): Promise<void> => {
88
return removeFileOrDirectory(path.join(projectDir, dirName));
99

10-
}
10+
};
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
const fs = require('fs')
1+
const fs = require('fs');
22

3-
const nextConfigPath = './playground/app/next.config.js'
4-
const nuxtConfigPath = './playground/app/nuxt.config.ts'
3+
const nextConfigPath = './playground/app/next.config.js';
4+
const nuxtConfigPath = './playground/app/nuxt.config.ts';
55

66
export const getFrameworkName = (): string => {
77
if (fs.existsSync(nextConfigPath)) {
8-
return 'next'
8+
return 'next';
99
}
1010

1111
if (fs.existsSync(nuxtConfigPath)) {
12-
return 'nuxt'
12+
return 'nuxt';
1313
}
1414

15-
const noFramework = 'Could not detect framework. No page will be generated.'
15+
const noFramework = 'Could not detect framework. No page will be generated.';
1616

17-
console.warn(noFramework)
17+
console.warn(noFramework);
1818

19-
return noFramework
20-
}
19+
return noFramework;
20+
};

packages/cli/src/utils/getPackageManager.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const checkPackageManager = async (packageManager: PackageManager): Promise<bool
1212
}
1313

1414
return true;
15-
}
15+
};
1616

1717
export const getPkgManager = async (pkgManager?: PackageManager): Promise<PackageManager> => {
1818
let packageManager = pkgManager || 'yarn';
@@ -30,7 +30,7 @@ export const getPkgManager = async (pkgManager?: PackageManager): Promise<Packag
3030
if (!isPackageManagerExists) {
3131
const useAnotherPackageManager = await confirm({
3232
message: `Package manager ${packageManager} not found. Do you want to use another package manager?`,
33-
active: 'Yes',
33+
active: 'Yes'
3434
});
3535

3636
if (useAnotherPackageManager) {
@@ -48,4 +48,4 @@ export const getPkgManager = async (pkgManager?: PackageManager): Promise<Packag
4848
}
4949

5050
return packageManager;
51-
}
51+
};

packages/cli/src/utils/installDeps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface InstallDepsOptions {
1212
export const installDeps = async ({
1313
path,
1414
entryMessage,
15-
exitMessage,
15+
exitMessage
1616
}: InstallDepsOptions,
1717
packageManager: string
1818
) => {

packages/cli/src/utils/log.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { spinner } from '@clack/prompts';
22

3-
export const log = (
4-
message: string,
5-
): void => {
3+
export const log = (message: string): void => {
64
const sp = spinner();
75
sp.start(message);
86
sp.stop(message);
9-
}
7+
};

0 commit comments

Comments
 (0)