Skip to content

Commit

Permalink
deps: bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangweiye committed May 29, 2024
1 parent 8a2ae5e commit d432cfc
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 66 deletions.
41 changes: 21 additions & 20 deletions dist/cli.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ function isGitClean() {
}
function getEslintConfigContent(mainConfig, additionalConfigs) {
return `
import eslint from '@jiangweiye/eslint-config';
import eslint from '@jiangweiye/eslint-config'
export default eslint({
${mainConfig}
}${additionalConfigs?.map((config) => `,{
export default eslint({
${mainConfig}
}${additionalConfigs?.map((config) => `,{
${config}
}`)})
`.trimStart();
`.trimStart();
}

// src/cli/stages/update-package-json.ts
Expand All @@ -358,6 +358,7 @@ async function updatePackageJson(result) {
const pkg = JSON.parse(pkgContent);
pkg.devDependencies ??= {};
pkg.devDependencies["@jiangweiye/eslint-config"] = `^${package_default.version}`;
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
const addedPackages = [];
if (result.extra.length) {
result.extra.forEach((item) => {
Expand Down Expand Up @@ -495,15 +496,12 @@ async function run(options = {}) {
if (!argSkipPrompt) {
result = await p4.group(
{
extra: ({ results }) => {
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
if (!results.uncommittedConfirmed || isArgExtraValid)
return;
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
return p4.multiselect({
message: import_picocolors5.default.reset(message),
options: extraOptions,
required: false
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean())
return Promise.resolve(true);
return p4.confirm({
initialValue: false,
message: "There are uncommitted changes in the current repository, are you sure to continue?"
});
},
frameworks: ({ results }) => {
Expand All @@ -517,12 +515,15 @@ async function run(options = {}) {
required: false
});
},
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean())
return Promise.resolve(true);
return p4.confirm({
initialValue: false,
message: "There are uncommitted changes in the current repository, are you sure to continue?"
extra: ({ results }) => {
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
if (!results.uncommittedConfirmed || isArgExtraValid)
return;
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
return p4.multiselect({
message: import_picocolors5.default.reset(message),
options: extraOptions,
required: false
});
},
updateVscodeSettings: ({ results }) => {
Expand Down
41 changes: 21 additions & 20 deletions dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ function isGitClean() {
}
function getEslintConfigContent(mainConfig, additionalConfigs) {
return `
import eslint from '@jiangweiye/eslint-config';
import eslint from '@jiangweiye/eslint-config'
export default eslint({
${mainConfig}
}${additionalConfigs?.map((config) => `,{
export default eslint({
${mainConfig}
}${additionalConfigs?.map((config) => `,{
${config}
}`)})
`.trimStart();
`.trimStart();
}

// src/cli/stages/update-package-json.ts
Expand All @@ -329,6 +329,7 @@ async function updatePackageJson(result) {
const pkg = JSON.parse(pkgContent);
pkg.devDependencies ??= {};
pkg.devDependencies["@jiangweiye/eslint-config"] = `^${package_default.version}`;
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
const addedPackages = [];
if (result.extra.length) {
result.extra.forEach((item) => {
Expand Down Expand Up @@ -466,15 +467,12 @@ async function run(options = {}) {
if (!argSkipPrompt) {
result = await p4.group(
{
extra: ({ results }) => {
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
if (!results.uncommittedConfirmed || isArgExtraValid)
return;
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
return p4.multiselect({
message: c5.reset(message),
options: extraOptions,
required: false
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean())
return Promise.resolve(true);
return p4.confirm({
initialValue: false,
message: "There are uncommitted changes in the current repository, are you sure to continue?"
});
},
frameworks: ({ results }) => {
Expand All @@ -488,12 +486,15 @@ async function run(options = {}) {
required: false
});
},
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean())
return Promise.resolve(true);
return p4.confirm({
initialValue: false,
message: "There are uncommitted changes in the current repository, are you sure to continue?"
extra: ({ results }) => {
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
if (!results.uncommittedConfirmed || isArgExtraValid)
return;
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
return p4.multiselect({
message: c5.reset(message),
options: extraOptions,
required: false
});
},
updateVscodeSettings: ({ results }) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@jiangweiye/eslint-config",
"type": "module",
"version": "0.1.5",
"version": "0.1.5-beta.1",
"description": "A eslint config for jiangweiye",
"author": "jiangweiye <[email protected]> (https://github.com/jwyGithub)",
"license": "SEE LICENSE IN LICENSE.md",
Expand Down
39 changes: 20 additions & 19 deletions src/cli/run.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable perfectionist/sort-objects */
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
Expand Down Expand Up @@ -47,21 +48,12 @@ export async function run(options: CliRunOptions = {}) {
if (!argSkipPrompt) {
result = (await p.group(
{
extra: ({ results }) => {
const isArgExtraValid =
argExtra?.length && !argExtra.filter(element => !extra.includes(<ExtraLibrariesOption>element)).length;

if (!results.uncommittedConfirmed || isArgExtraValid) return;

const message =
!isArgExtraValid && argExtra
? `"${argExtra}" isn't a valid extra util. Please choose from below: `
: 'Select a extra utils:';
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean()) return Promise.resolve(true);

return p.multiselect<PromItem<ExtraLibrariesOption>[], ExtraLibrariesOption>({
message: c.reset(message),
options: extraOptions,
required: false
return p.confirm({
initialValue: false,
message: 'There are uncommitted changes in the current repository, are you sure to continue?'
});
},
frameworks: ({ results }) => {
Expand All @@ -80,12 +72,21 @@ export async function run(options: CliRunOptions = {}) {
required: false
});
},
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean()) return Promise.resolve(true);
extra: ({ results }) => {
const isArgExtraValid =
argExtra?.length && !argExtra.filter(element => !extra.includes(<ExtraLibrariesOption>element)).length;

return p.confirm({
initialValue: false,
message: 'There are uncommitted changes in the current repository, are you sure to continue?'
if (!results.uncommittedConfirmed || isArgExtraValid) return;

const message =
!isArgExtraValid && argExtra
? `"${argExtra}" isn't a valid extra util. Please choose from below: `
: 'Select a extra utils:';

return p.multiselect<PromItem<ExtraLibrariesOption>[], ExtraLibrariesOption>({
message: c.reset(message),
options: extraOptions,
required: false
});
},

Expand Down
2 changes: 1 addition & 1 deletion src/cli/stages/update-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function updatePackageJson(result: PromtResult) {

pkg.devDependencies ??= {};
pkg.devDependencies['@jiangweiye/eslint-config'] = `^${pkgJson.version}`;
// pkg.devDependencies.eslint ??= pkgJson.devDependencies.eslint.replace('npm:eslint-ts-patch@', '').replace(/-\d+$/, '');
pkg.devDependencies.eslint ??= pkgJson.devDependencies.eslint.replace('npm:eslint-ts-patch@', '').replace(/-\d+$/, '');

const addedPackages: string[] = [];

Expand Down
10 changes: 5 additions & 5 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export function isGitClean() {

export function getEslintConfigContent(mainConfig: string, additionalConfigs?: string[]) {
return `
import eslint from '@jiangweiye/eslint-config';
import eslint from '@jiangweiye/eslint-config'
export default eslint({
${mainConfig}
}${additionalConfigs?.map(config => `,{\n${config}\n}`)})
`.trimStart();
export default eslint({
${mainConfig}
}${additionalConfigs?.map(config => `,{\n${config}\n}`)})
`.trimStart();
}

0 comments on commit d432cfc

Please sign in to comment.