create-airbnb-x-config 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +24 -0
- package/dist/constants/index.js +27 -0
- package/dist/helpers/getArgs.d.ts +33 -0
- package/dist/helpers/getArgs.js +93 -0
- package/dist/helpers/getCommands.d.ts +4 -0
- package/dist/helpers/getCommands.js +40 -0
- package/dist/helpers/getPackageManager.d.ts +9 -0
- package/dist/helpers/getPackageManager.js +22 -0
- package/dist/helpers/installPackages.d.ts +10 -0
- package/dist/helpers/installPackages.js +40 -0
- package/dist/helpers/program.d.ts +7 -0
- package/dist/helpers/program.js +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +192 -0
- package/dist/package.json +56 -0
- package/dist/utils/index.d.ts +27 -0
- package/dist/utils/index.js +48 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +2 -0
- package/package.json +17 -2
- package/CHANGELOG.md +0 -7
- package/index.ts +0 -21
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const languages: {
|
|
2
|
+
readonly REACT: "react";
|
|
3
|
+
readonly NEXT: "next";
|
|
4
|
+
readonly NODE: "node";
|
|
5
|
+
readonly OTHER: "other";
|
|
6
|
+
};
|
|
7
|
+
export declare const configs: {
|
|
8
|
+
readonly BASE: "base";
|
|
9
|
+
readonly NODE: "node";
|
|
10
|
+
readonly REACT: "react";
|
|
11
|
+
readonly NEXT: "next";
|
|
12
|
+
readonly REACT_ROUTER: "reactRouter";
|
|
13
|
+
};
|
|
14
|
+
export declare const defaults: {
|
|
15
|
+
readonly typescript: true;
|
|
16
|
+
readonly language: 0;
|
|
17
|
+
readonly skipInstall: false;
|
|
18
|
+
};
|
|
19
|
+
export declare const packageManagers: {
|
|
20
|
+
readonly NPM: "npm";
|
|
21
|
+
readonly YARN: "yarn";
|
|
22
|
+
readonly PNPM: "pnpm";
|
|
23
|
+
readonly BUN: "bun";
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageManagers = exports.defaults = exports.configs = exports.languages = void 0;
|
|
4
|
+
exports.languages = {
|
|
5
|
+
REACT: 'react',
|
|
6
|
+
NEXT: 'next',
|
|
7
|
+
NODE: 'node',
|
|
8
|
+
OTHER: 'other',
|
|
9
|
+
};
|
|
10
|
+
exports.configs = {
|
|
11
|
+
BASE: 'base',
|
|
12
|
+
NODE: 'node',
|
|
13
|
+
REACT: 'react',
|
|
14
|
+
NEXT: 'next',
|
|
15
|
+
REACT_ROUTER: 'reactRouter',
|
|
16
|
+
};
|
|
17
|
+
exports.defaults = {
|
|
18
|
+
typescript: true,
|
|
19
|
+
language: 0,
|
|
20
|
+
skipInstall: false,
|
|
21
|
+
};
|
|
22
|
+
exports.packageManagers = {
|
|
23
|
+
NPM: 'npm',
|
|
24
|
+
YARN: 'yarn',
|
|
25
|
+
PNPM: 'pnpm',
|
|
26
|
+
BUN: 'bun',
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { configs, languages, packageManagers } from '../constants';
|
|
2
|
+
import type { ValueOf } from '../utils/types';
|
|
3
|
+
export declare const configHelp = "\n/**\n * Configuration Rules:\n * 1. Either Base or Node config should be included (choose one).\n * 2. React config can be used with either Next or Remix/React Router (choose one).\n * 3. Including all configs together is not recommended and may lead to conflicts.\n *\n * Summary:\n * - One from: Base | Node\n * - One from: React + (Next | Remix/React Router)\n * - Avoid selecting all configs at once.\n */";
|
|
4
|
+
type GetConfig = (opts: Partial<ProgramOpts>) => GetArgsOutput['config'];
|
|
5
|
+
export declare const getConfig: GetConfig;
|
|
6
|
+
export interface ProgramOpts {
|
|
7
|
+
typescript: true;
|
|
8
|
+
javascript: true;
|
|
9
|
+
react: true;
|
|
10
|
+
reactRouter: true;
|
|
11
|
+
next: true;
|
|
12
|
+
node: true;
|
|
13
|
+
baseConfig: true;
|
|
14
|
+
nodeConfig: true;
|
|
15
|
+
reactConfig: true;
|
|
16
|
+
nextConfig: true;
|
|
17
|
+
reactRouterConfig: true;
|
|
18
|
+
useNpm: true;
|
|
19
|
+
useYarn: true;
|
|
20
|
+
usePnpm: true;
|
|
21
|
+
useBun: true;
|
|
22
|
+
skipInstall: true;
|
|
23
|
+
}
|
|
24
|
+
export interface GetArgsOutput {
|
|
25
|
+
typescript: boolean | null;
|
|
26
|
+
language: ValueOf<typeof languages> | null;
|
|
27
|
+
config: ValueOf<typeof configs>[] | null;
|
|
28
|
+
packageManager: ValueOf<typeof packageManagers> | null;
|
|
29
|
+
skipInstall: true | null;
|
|
30
|
+
}
|
|
31
|
+
type GetArgs = () => GetArgsOutput;
|
|
32
|
+
declare const getArgs: GetArgs;
|
|
33
|
+
export default getArgs;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getConfig = exports.configHelp = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const program_1 = __importDefault(require("../helpers/program"));
|
|
9
|
+
const getPackageManager_1 = require("../helpers/getPackageManager");
|
|
10
|
+
const getTypescript = (opts) => {
|
|
11
|
+
const { typescript, javascript } = opts;
|
|
12
|
+
if (typescript)
|
|
13
|
+
return true;
|
|
14
|
+
if (javascript)
|
|
15
|
+
return false;
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
const getLanguage = (opts) => {
|
|
19
|
+
const { react, reactRouter, next, node } = opts;
|
|
20
|
+
if (react || reactRouter)
|
|
21
|
+
return constants_1.languages.REACT;
|
|
22
|
+
if (next)
|
|
23
|
+
return constants_1.languages.NEXT;
|
|
24
|
+
if (node)
|
|
25
|
+
return constants_1.languages.NODE;
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
// Get Config
|
|
29
|
+
exports.configHelp = `
|
|
30
|
+
/**
|
|
31
|
+
* Configuration Rules:
|
|
32
|
+
* 1. Either Base or Node config should be included (choose one).
|
|
33
|
+
* 2. React config can be used with either Next or Remix/React Router (choose one).
|
|
34
|
+
* 3. Including all configs together is not recommended and may lead to conflicts.
|
|
35
|
+
*
|
|
36
|
+
* Summary:
|
|
37
|
+
* - One from: Base | Node
|
|
38
|
+
* - One from: React + (Next | Remix/React Router)
|
|
39
|
+
* - Avoid selecting all configs at once.
|
|
40
|
+
*/`;
|
|
41
|
+
const getConfig = (opts) => {
|
|
42
|
+
const { baseConfig, nodeConfig, reactConfig, nextConfig, reactRouterConfig } = opts;
|
|
43
|
+
const config = [];
|
|
44
|
+
if (baseConfig || nodeConfig) {
|
|
45
|
+
if (baseConfig)
|
|
46
|
+
config.push(constants_1.configs.BASE);
|
|
47
|
+
if (nodeConfig)
|
|
48
|
+
config.push(constants_1.configs.NODE);
|
|
49
|
+
return config;
|
|
50
|
+
}
|
|
51
|
+
if (reactConfig || nextConfig || reactRouterConfig) {
|
|
52
|
+
if (reactConfig)
|
|
53
|
+
config.push(constants_1.configs.REACT);
|
|
54
|
+
if (nextConfig)
|
|
55
|
+
config.push(constants_1.configs.NEXT);
|
|
56
|
+
else if (reactRouterConfig)
|
|
57
|
+
config.push(constants_1.configs.REACT_ROUTER);
|
|
58
|
+
return config;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
exports.getConfig = getConfig;
|
|
63
|
+
const getPackageManagerFromOpts = (opts) => {
|
|
64
|
+
const { useNpm, useYarn, usePnpm, useBun } = opts;
|
|
65
|
+
if (useNpm)
|
|
66
|
+
return constants_1.packageManagers.NPM;
|
|
67
|
+
if (useYarn)
|
|
68
|
+
return constants_1.packageManagers.YARN;
|
|
69
|
+
if (usePnpm)
|
|
70
|
+
return constants_1.packageManagers.PNPM;
|
|
71
|
+
if (useBun)
|
|
72
|
+
return constants_1.packageManagers.BUN;
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const getSkipInstall = (opts) => {
|
|
76
|
+
const { skipInstall } = opts;
|
|
77
|
+
if (skipInstall)
|
|
78
|
+
return true;
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
const getArgs = () => {
|
|
82
|
+
var _a;
|
|
83
|
+
const opts = program_1.default.opts();
|
|
84
|
+
const config = (0, exports.getConfig)(opts);
|
|
85
|
+
return {
|
|
86
|
+
typescript: getTypescript(opts),
|
|
87
|
+
language: config ? constants_1.languages.OTHER : getLanguage(opts),
|
|
88
|
+
config,
|
|
89
|
+
packageManager: (_a = getPackageManagerFromOpts(opts)) !== null && _a !== void 0 ? _a : (0, getPackageManager_1.getPackageManager)(),
|
|
90
|
+
skipInstall: getSkipInstall(opts),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
exports.default = getArgs;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const getCommands = (args) => {
|
|
5
|
+
const { typescript, language, config, packageManager } = args;
|
|
6
|
+
const pmInstallationCommand = {
|
|
7
|
+
[constants_1.packageManagers.NPM]: 'npm install',
|
|
8
|
+
[constants_1.packageManagers.YARN]: 'yarn add',
|
|
9
|
+
[constants_1.packageManagers.PNPM]: 'pnpm install',
|
|
10
|
+
[constants_1.packageManagers.BUN]: 'bun add',
|
|
11
|
+
};
|
|
12
|
+
const commands = [
|
|
13
|
+
pmInstallationCommand[packageManager],
|
|
14
|
+
'-D',
|
|
15
|
+
'eslint',
|
|
16
|
+
'eslint-config-airbnb-extended',
|
|
17
|
+
'eslint-plugin-import-x',
|
|
18
|
+
];
|
|
19
|
+
if (typescript) {
|
|
20
|
+
commands.push('eslint-import-resolver-typescript', 'typescript-eslint');
|
|
21
|
+
}
|
|
22
|
+
if (language === constants_1.languages.OTHER) {
|
|
23
|
+
if (config.includes(constants_1.configs.REACT)) {
|
|
24
|
+
commands.push('eslint-plugin-react', 'eslint-plugin-react-hooks', 'eslint-plugin-jsx-a11y');
|
|
25
|
+
}
|
|
26
|
+
if (config.includes(constants_1.configs.NEXT)) {
|
|
27
|
+
commands.push('@next/eslint-plugin-next');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (language === constants_1.languages.REACT || language === constants_1.languages.NEXT) {
|
|
32
|
+
commands.push('eslint-plugin-react', 'eslint-plugin-react-hooks', 'eslint-plugin-jsx-a11y');
|
|
33
|
+
}
|
|
34
|
+
if (language === constants_1.languages.NEXT) {
|
|
35
|
+
commands.push('@next/eslint-plugin-next');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return commands;
|
|
39
|
+
};
|
|
40
|
+
exports.default = getCommands;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ValueOf } from '../utils/types';
|
|
2
|
+
import { packageManagers } from '../constants';
|
|
3
|
+
export type PackageManager = ValueOf<typeof packageManagers>;
|
|
4
|
+
type GetPackageManager = () => PackageManager;
|
|
5
|
+
/**
|
|
6
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/get-pkg-manager.ts
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPackageManager: GetPackageManager;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageManager = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/get-pkg-manager.ts
|
|
7
|
+
*/
|
|
8
|
+
const getPackageManager = () => {
|
|
9
|
+
var _a;
|
|
10
|
+
const userAgent = (_a = process.env.npm_config_user_agent) !== null && _a !== void 0 ? _a : '';
|
|
11
|
+
if (userAgent.startsWith(constants_1.packageManagers.YARN)) {
|
|
12
|
+
return constants_1.packageManagers.YARN;
|
|
13
|
+
}
|
|
14
|
+
if (userAgent.startsWith(constants_1.packageManagers.PNPM)) {
|
|
15
|
+
return constants_1.packageManagers.PNPM;
|
|
16
|
+
}
|
|
17
|
+
if (userAgent.startsWith(constants_1.packageManagers.BUN)) {
|
|
18
|
+
return constants_1.packageManagers.BUN;
|
|
19
|
+
}
|
|
20
|
+
return constants_1.packageManagers.NPM;
|
|
21
|
+
};
|
|
22
|
+
exports.getPackageManager = getPackageManager;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GetArgsOutput } from '../helpers/getArgs';
|
|
2
|
+
export type InstallPackagesArgs = {
|
|
3
|
+
[K in keyof GetArgsOutput]: NonNullable<GetArgsOutput[K]>;
|
|
4
|
+
};
|
|
5
|
+
type InstallPackages = (args: InstallPackagesArgs) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/install.ts
|
|
8
|
+
*/
|
|
9
|
+
declare const install: InstallPackages;
|
|
10
|
+
export default install;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
16
|
+
const getCommands_1 = __importDefault(require("../helpers/getCommands"));
|
|
17
|
+
/**
|
|
18
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/helpers/install.ts
|
|
19
|
+
*/
|
|
20
|
+
const install = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const { packageManager } = args;
|
|
22
|
+
const commands = (0, getCommands_1.default)(args);
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const child = (0, cross_spawn_1.default)(packageManager, commands, {
|
|
25
|
+
stdio: 'inherit',
|
|
26
|
+
env: Object.assign(Object.assign({}, process.env), { ADBLOCK: '1',
|
|
27
|
+
// we set NODE_ENV to development as pnpm skips dev
|
|
28
|
+
// dependencies when production
|
|
29
|
+
NODE_ENV: 'development', DISABLE_OPENCOLLECTIVE: '1' }),
|
|
30
|
+
});
|
|
31
|
+
child.on('close', (code) => {
|
|
32
|
+
if (code !== 0) {
|
|
33
|
+
reject({ command: `${packageManager} ${commands.join(' ')}` });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
resolve();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
exports.default = install;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Program Command
|
|
4
|
+
* @example: pnpm cli:start --ts --js --react --remix --next --node --base-config --node-config --react-config --remix-config --next-config --use-npm --use-yarn --use-pnpm --use-bun --skip-install
|
|
5
|
+
*/
|
|
6
|
+
declare const program: Command;
|
|
7
|
+
export default program;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const package_json_1 = require("../package.json");
|
|
5
|
+
/**
|
|
6
|
+
* Program Command
|
|
7
|
+
* @example: pnpm cli:start --ts --js --react --remix --next --node --base-config --node-config --react-config --remix-config --next-config --use-npm --use-yarn --use-pnpm --use-bun --skip-install
|
|
8
|
+
*/
|
|
9
|
+
const program = new commander_1.Command()
|
|
10
|
+
.name(package_json_1.name)
|
|
11
|
+
.version(package_json_1.version, '-v, --version', 'Output the current version of create-airbnb-x-config.')
|
|
12
|
+
.helpOption('-h, --help', 'Display this help message.')
|
|
13
|
+
.option('--ts, --typescript', 'Generate configuration for a TypeScript project.')
|
|
14
|
+
.option('--js, --javascript', 'Generate configuration for a JavaScript project.')
|
|
15
|
+
.option('--react', 'Include React specific linting rules.')
|
|
16
|
+
.option('--remix, --react-router', 'Include Remix/React Router specific linting rules.')
|
|
17
|
+
.option('--next', 'Include Next.js specific linting rules.')
|
|
18
|
+
.option('--node', 'Include Node.js specific linting rules.')
|
|
19
|
+
.option('--base-config', 'Include only the base Airbnb ESLint configuration.')
|
|
20
|
+
.option('--node-config', 'Include the Node specific ESLint configuration.')
|
|
21
|
+
.option('--react-config', 'Include the React specific ESLint configuration.')
|
|
22
|
+
.option('--next-config', 'Include the Next.js specific ESLint configuration.')
|
|
23
|
+
.option('--remix-config, --react-router-config', 'Include the Remix/React Router specific ESLint configuration.')
|
|
24
|
+
.option('--use-npm', 'Explicitly tell the CLI to use npm.')
|
|
25
|
+
.option('--use-yarn', 'Explicitly tell the CLI to use Yarn.')
|
|
26
|
+
.option('--use-pnpm', 'Explicitly tell the CLI to use pnpm.')
|
|
27
|
+
.option('--use-bun', 'Explicitly tell the CLI to use Bun.')
|
|
28
|
+
.option('--skip-install', 'Explicitly tell the CLI to skip installing packages.')
|
|
29
|
+
.parse(process.argv);
|
|
30
|
+
exports.default = program;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
const picocolors_1 = require("picocolors");
|
|
49
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
50
|
+
const constants_1 = require("./constants");
|
|
51
|
+
const getArgs_1 = __importStar(require("./helpers/getArgs"));
|
|
52
|
+
const utils_1 = require("./utils");
|
|
53
|
+
const installPackages_1 = __importDefault(require("./helpers/installPackages"));
|
|
54
|
+
const getCommands_1 = __importDefault(require("./helpers/getCommands"));
|
|
55
|
+
process.on('SIGINT', utils_1.handleSigTerm);
|
|
56
|
+
process.on('SIGTERM', utils_1.handleSigTerm);
|
|
57
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
let args = (0, getArgs_1.default)();
|
|
59
|
+
if (args.typescript === null) {
|
|
60
|
+
const { typescript } = yield (0, prompts_1.default)({
|
|
61
|
+
type: 'toggle',
|
|
62
|
+
name: 'typescript',
|
|
63
|
+
message: `Are you using ${(0, picocolors_1.blue)('typescript')}?`,
|
|
64
|
+
initial: constants_1.defaults.typescript,
|
|
65
|
+
active: 'Yes',
|
|
66
|
+
inactive: 'No',
|
|
67
|
+
}, {
|
|
68
|
+
onCancel: utils_1.onCancel,
|
|
69
|
+
});
|
|
70
|
+
args = Object.assign(Object.assign({}, args), { typescript });
|
|
71
|
+
}
|
|
72
|
+
if (!args.language) {
|
|
73
|
+
const { language } = yield (0, prompts_1.default)({
|
|
74
|
+
type: 'select',
|
|
75
|
+
name: 'language',
|
|
76
|
+
message: 'Are you using?',
|
|
77
|
+
initial: constants_1.defaults.language,
|
|
78
|
+
choices: [
|
|
79
|
+
{
|
|
80
|
+
title: 'React/React Router',
|
|
81
|
+
description: (0, picocolors_1.cyanBright)('You are using React.js library or Remix ( React Router 7 ) framework'),
|
|
82
|
+
value: constants_1.languages.REACT,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: 'Next',
|
|
86
|
+
description: (0, picocolors_1.blackBright)('You are using Next.js framework'),
|
|
87
|
+
value: constants_1.languages.NEXT,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
title: 'Node',
|
|
91
|
+
description: (0, picocolors_1.greenBright)('You are using Node or any other frameworks of it'),
|
|
92
|
+
value: constants_1.languages.NODE,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: 'Own Customization',
|
|
96
|
+
description: (0, picocolors_1.redBright)('You would like to customize by your own'),
|
|
97
|
+
value: constants_1.languages.OTHER,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
}, {
|
|
101
|
+
onCancel: utils_1.onCancel,
|
|
102
|
+
});
|
|
103
|
+
args = Object.assign(Object.assign({}, args), { language });
|
|
104
|
+
}
|
|
105
|
+
if (!args.config) {
|
|
106
|
+
if (args.language === constants_1.languages.OTHER) {
|
|
107
|
+
const { config } = yield (0, prompts_1.default)({
|
|
108
|
+
type: 'multiselect',
|
|
109
|
+
name: 'config',
|
|
110
|
+
message: 'Select Config:',
|
|
111
|
+
min: 1,
|
|
112
|
+
choices: [
|
|
113
|
+
{
|
|
114
|
+
title: 'Base',
|
|
115
|
+
description: (0, picocolors_1.yellowBright)('Base config without React/JSX configurations'),
|
|
116
|
+
value: constants_1.configs.BASE,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
title: 'Node',
|
|
120
|
+
description: (0, picocolors_1.greenBright)('Node config with Base config'),
|
|
121
|
+
value: constants_1.configs.NODE,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
title: 'React',
|
|
125
|
+
description: (0, picocolors_1.cyanBright)('React config with base config'),
|
|
126
|
+
value: constants_1.configs.REACT,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
title: 'Next',
|
|
130
|
+
description: (0, picocolors_1.blackBright)('Next.js config with base config'),
|
|
131
|
+
value: constants_1.configs.NEXT,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: 'Remix (React Router)',
|
|
135
|
+
description: (0, picocolors_1.redBright)('Remix (React Router) config with base config'),
|
|
136
|
+
value: constants_1.configs.REACT_ROUTER,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
format: (prev) => {
|
|
140
|
+
const values = prev;
|
|
141
|
+
const opts = values.reduce((acc, value) => {
|
|
142
|
+
return Object.assign(Object.assign({}, acc), { [`${value}Config`]: true });
|
|
143
|
+
}, {});
|
|
144
|
+
return (0, getArgs_1.getConfig)(opts);
|
|
145
|
+
},
|
|
146
|
+
hint: getArgs_1.configHelp,
|
|
147
|
+
}, {
|
|
148
|
+
onCancel: utils_1.onCancel,
|
|
149
|
+
});
|
|
150
|
+
args = Object.assign(Object.assign({}, args), { config });
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
args = Object.assign(Object.assign({}, args), { config: [] });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (args.skipInstall === null) {
|
|
157
|
+
const { skipInstall } = yield (0, prompts_1.default)({
|
|
158
|
+
type: 'toggle',
|
|
159
|
+
name: 'skipInstall',
|
|
160
|
+
message: `Do you want to skip the package installation?`,
|
|
161
|
+
initial: constants_1.defaults.skipInstall,
|
|
162
|
+
active: 'Yes',
|
|
163
|
+
inactive: 'No',
|
|
164
|
+
}, {
|
|
165
|
+
onCancel: utils_1.onCancel,
|
|
166
|
+
});
|
|
167
|
+
args = Object.assign(Object.assign({}, args), { skipInstall });
|
|
168
|
+
}
|
|
169
|
+
const newArgs = args;
|
|
170
|
+
const commands = (0, getCommands_1.default)(newArgs);
|
|
171
|
+
console.log();
|
|
172
|
+
if (args.skipInstall) {
|
|
173
|
+
const command = commands.join(' ');
|
|
174
|
+
console.log(`${(0, picocolors_1.yellowBright)('No Worries')}, you can install the packages yourself using your ${(0, picocolors_1.blue)('favourite')} package manager (${newArgs.packageManager}, maybe? 🤔)`);
|
|
175
|
+
console.log();
|
|
176
|
+
console.log((0, picocolors_1.cyan)('Command:'));
|
|
177
|
+
console.log(command);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
console.log(`${(0, picocolors_1.blue)('Installing')} packages using ${(0, picocolors_1.cyanBright)(newArgs.packageManager)}, please wait...`);
|
|
181
|
+
yield (0, installPackages_1.default)(newArgs);
|
|
182
|
+
console.log();
|
|
183
|
+
console.log((0, picocolors_1.yellowBright)('Installation Completed'));
|
|
184
|
+
}
|
|
185
|
+
console.log();
|
|
186
|
+
console.log((0, picocolors_1.cyan)('Config:'));
|
|
187
|
+
console.log();
|
|
188
|
+
console.log((0, picocolors_1.red)('WIP'));
|
|
189
|
+
console.log();
|
|
190
|
+
});
|
|
191
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
192
|
+
run().then(utils_1.success).catch(utils_1.exit);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-airbnb-x-config",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Airbnb Extended Config CLI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"airbnb",
|
|
8
|
+
"eslint config cli",
|
|
9
|
+
"eslint config cli x",
|
|
10
|
+
"eslint config cli extended",
|
|
11
|
+
"airbnb cli",
|
|
12
|
+
"airbnb config",
|
|
13
|
+
"airbnb config cli",
|
|
14
|
+
"airbnb config cli x",
|
|
15
|
+
"airbnb config cli extended"
|
|
16
|
+
],
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/NishargShah/eslint-config-airbnb-extended/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/NishargShah/eslint-config-airbnb-extended.git",
|
|
23
|
+
"directory": "packages/create-airbnb-x-config"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "Nisharg Shah <nishargshah3101@gmail.com>",
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"bin": {
|
|
31
|
+
"create-airbnb-extended-config": "./dist/index.js",
|
|
32
|
+
"create-airbnb-x-config": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"postbuild": "tsc-alias",
|
|
37
|
+
"dev": "nodemon index.ts",
|
|
38
|
+
"start": "ts-node index.ts",
|
|
39
|
+
"typecheck": "tsc --noEmit"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"commander": "^13.1.0",
|
|
43
|
+
"cross-spawn": "^7.0.6",
|
|
44
|
+
"picocolors": "^1.1.1",
|
|
45
|
+
"prompts": "^2.4.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/cross-spawn": "^6.0.6",
|
|
49
|
+
"@types/prompts": "^2.4.9",
|
|
50
|
+
"nodemon": "^3.1.9",
|
|
51
|
+
"ts-node": "^10.9.2",
|
|
52
|
+
"tsc-alias": "^1.8.13",
|
|
53
|
+
"tsconfig-paths": "^4.2.0",
|
|
54
|
+
"typescript": "^5.8.2"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InitialReturnValue } from 'prompts';
|
|
2
|
+
export declare const handleSigTerm: () => void;
|
|
3
|
+
interface PromptStateProps {
|
|
4
|
+
value: InitialReturnValue;
|
|
5
|
+
aborted: boolean;
|
|
6
|
+
exited: boolean;
|
|
7
|
+
}
|
|
8
|
+
type PromptState = (state: PromptStateProps) => void;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L26C1-L38C2
|
|
11
|
+
*/
|
|
12
|
+
export declare const onPromptState: PromptState;
|
|
13
|
+
/**
|
|
14
|
+
* User inputs Ctrl+C or Ctrl+D to exit the prompt. We should close the
|
|
15
|
+
* process and not write to the file system.
|
|
16
|
+
*/
|
|
17
|
+
export declare const onCancel: () => void;
|
|
18
|
+
export declare const success: () => void;
|
|
19
|
+
interface ExitReason {
|
|
20
|
+
command?: string;
|
|
21
|
+
}
|
|
22
|
+
type Exit = (reason: ExitReason) => void;
|
|
23
|
+
/**
|
|
24
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L499
|
|
25
|
+
*/
|
|
26
|
+
export declare const exit: Exit;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exit = exports.success = exports.onCancel = exports.onPromptState = exports.handleSigTerm = void 0;
|
|
4
|
+
const picocolors_1 = require("picocolors");
|
|
5
|
+
// Handle Sigterm
|
|
6
|
+
const handleSigTerm = () => process.exit(0);
|
|
7
|
+
exports.handleSigTerm = handleSigTerm;
|
|
8
|
+
/**
|
|
9
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L26C1-L38C2
|
|
10
|
+
*/
|
|
11
|
+
const onPromptState = (state) => {
|
|
12
|
+
if (state.aborted) {
|
|
13
|
+
// If we don't re-enable the terminal cursor before exiting
|
|
14
|
+
// the program, the cursor will remain hidden
|
|
15
|
+
process.stdout.write('\u001B[?25h');
|
|
16
|
+
process.stdout.write('\n');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.onPromptState = onPromptState;
|
|
21
|
+
/**
|
|
22
|
+
* User inputs Ctrl+C or Ctrl+D to exit the prompt. We should close the
|
|
23
|
+
* process and not write to the file system.
|
|
24
|
+
*/
|
|
25
|
+
const onCancel = () => {
|
|
26
|
+
console.error('👋 Exiting, bye bye.');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
};
|
|
29
|
+
exports.onCancel = onCancel;
|
|
30
|
+
// Run Function Then block
|
|
31
|
+
const success = () => {
|
|
32
|
+
// noop
|
|
33
|
+
};
|
|
34
|
+
exports.success = success;
|
|
35
|
+
/**
|
|
36
|
+
* @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L499
|
|
37
|
+
*/
|
|
38
|
+
const exit = (reason) => {
|
|
39
|
+
console.log('Aborting installation.');
|
|
40
|
+
if (reason.command) {
|
|
41
|
+
console.log(`${(0, picocolors_1.red)(reason.command)} has failed.`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log((0, picocolors_1.red)('Unexpected error. Please report it as a bug:') + '\n', reason);
|
|
45
|
+
}
|
|
46
|
+
process.exit(1);
|
|
47
|
+
};
|
|
48
|
+
exports.exit = exit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-airbnb-x-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Airbnb Extended Config CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -27,15 +27,30 @@
|
|
|
27
27
|
"type": "commonjs",
|
|
28
28
|
"main": "dist/index.js",
|
|
29
29
|
"types": "dist/index.d.ts",
|
|
30
|
+
"bin": {
|
|
31
|
+
"create-airbnb-extended-config": "./dist/index.js",
|
|
32
|
+
"create-airbnb-x-config": "./dist/index.js"
|
|
33
|
+
},
|
|
30
34
|
"dependencies": {
|
|
35
|
+
"commander": "^13.1.0",
|
|
36
|
+
"cross-spawn": "^7.0.6",
|
|
37
|
+
"picocolors": "^1.1.1",
|
|
31
38
|
"prompts": "^2.4.2"
|
|
32
39
|
},
|
|
33
40
|
"devDependencies": {
|
|
41
|
+
"@types/cross-spawn": "^6.0.6",
|
|
34
42
|
"@types/prompts": "^2.4.9",
|
|
43
|
+
"nodemon": "^3.1.9",
|
|
44
|
+
"ts-node": "^10.9.2",
|
|
45
|
+
"tsc-alias": "^1.8.13",
|
|
46
|
+
"tsconfig-paths": "^4.2.0",
|
|
35
47
|
"typescript": "^5.8.2"
|
|
36
48
|
},
|
|
37
49
|
"scripts": {
|
|
38
|
-
"build": "",
|
|
50
|
+
"build": "tsc",
|
|
51
|
+
"postbuild": "tsc-alias",
|
|
52
|
+
"dev": "nodemon index.ts",
|
|
53
|
+
"start": "ts-node index.ts",
|
|
39
54
|
"typecheck": "tsc --noEmit"
|
|
40
55
|
}
|
|
41
56
|
}
|
package/CHANGELOG.md
DELETED
package/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
|
|
3
|
-
const getCLI = async () => {
|
|
4
|
-
const response = await prompts({
|
|
5
|
-
type: 'number',
|
|
6
|
-
name: 'value',
|
|
7
|
-
message: 'How old are you?',
|
|
8
|
-
validate: (value) => (value < 18 ? `Nightclub is 18+ only` : true),
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
console.log(response); // => { value: 24 }
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
getCLI()
|
|
15
|
-
.then(() => {
|
|
16
|
-
return;
|
|
17
|
-
})
|
|
18
|
-
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
19
|
-
.catch(() => {
|
|
20
|
-
// noop
|
|
21
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ES6",
|
|
5
|
-
"module": "CommonJS",
|
|
6
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"declaration": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs", "**/*.mts"],
|
|
16
|
-
"exclude": ["node_modules", "dist"]
|
|
17
|
-
}
|