esmate 0.0.10 → 0.0.12

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/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Rslib project
2
+
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ pnpm install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ pnpm build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ pnpm dev
23
+ ```
@@ -0,0 +1,11 @@
1
+ export declare const fmt: import("citty").CommandDef<{
2
+ check: {
3
+ type: "boolean";
4
+ description: string;
5
+ };
6
+ files: {
7
+ type: "positional";
8
+ description: string;
9
+ required: false;
10
+ };
11
+ }>;
@@ -0,0 +1,36 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
4
+ const fmt = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
5
+ meta: {
6
+ name: "fmt",
7
+ description: "Format source files"
8
+ },
9
+ args: {
10
+ check: {
11
+ type: "boolean",
12
+ description: "Check if the source files are formatted"
13
+ },
14
+ files: {
15
+ type: "positional",
16
+ description: "Files, folders, or globs to format",
17
+ required: false
18
+ }
19
+ },
20
+ async run ({ args }) {
21
+ try {
22
+ const options = [];
23
+ const files = args._;
24
+ if (args.check) options.push("--check");
25
+ else options.push("--write");
26
+ options.push("--cache");
27
+ options.push("--cache-location");
28
+ options.push("'./node_modules/.cache/prettier/.prettier-cache'");
29
+ if (0 === files.length) files.push(".");
30
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.npx)(`prettier ${options.join(" ")} ${files.join(" ")}`);
31
+ } catch (error) {
32
+ __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
33
+ }
34
+ }
35
+ });
36
+ export { fmt };
@@ -0,0 +1,11 @@
1
+ export declare const lint: import("citty").CommandDef<{
2
+ fix: {
3
+ type: "boolean";
4
+ description: string;
5
+ };
6
+ files: {
7
+ type: "positional";
8
+ description: string;
9
+ required: false;
10
+ };
11
+ }>;
@@ -0,0 +1,35 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
4
+ const lint = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
5
+ meta: {
6
+ name: "lint",
7
+ description: "Lint JavaScript/TypeScript source code"
8
+ },
9
+ args: {
10
+ fix: {
11
+ type: "boolean",
12
+ description: "Fix any linting errors for rules that support it"
13
+ },
14
+ files: {
15
+ type: "positional",
16
+ description: "Files, folders, or globs to lint",
17
+ required: false
18
+ }
19
+ },
20
+ async run (c) {
21
+ try {
22
+ const options = [];
23
+ const files = c.args._;
24
+ if (c.args.fix) options.push("--fix");
25
+ options.push("--cache");
26
+ options.push("--cache-location");
27
+ options.push("'./node_modules/.cache/eslint/.eslint-cache'");
28
+ if (0 === files.length) files.push(".");
29
+ (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.npx)(`eslint ${options.join(" ")} ${files.join(" ")}`);
30
+ } catch (error) {
31
+ __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
32
+ }
33
+ }
34
+ });
35
+ export { lint };
@@ -0,0 +1,7 @@
1
+ export declare const task: import("citty").CommandDef<{
2
+ task: {
3
+ type: "positional";
4
+ description: string;
5
+ required: false;
6
+ };
7
+ }>;
@@ -0,0 +1,30 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_es_toolkit_82663681__ from "es-toolkit";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__pkg_js_ce8daa14__ from "../pkg.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
6
+ const task_task = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
7
+ meta: {
8
+ name: "task",
9
+ description: "Run a task defined in the package.json"
10
+ },
11
+ args: {
12
+ task: {
13
+ type: "positional",
14
+ description: "A task to run",
15
+ required: false
16
+ }
17
+ },
18
+ async run ({ args }) {
19
+ try {
20
+ const task = __WEBPACK_EXTERNAL_MODULE__pkg_js_ce8daa14__.pkg.tasks[args.task];
21
+ if (!task) return void __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(`Task "${args.task}" not found in package.json`);
22
+ const isParallel = (0, __WEBPACK_EXTERNAL_MODULE_es_toolkit_82663681__.isJSONObject)(task);
23
+ if (isParallel) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execParallelly)(task);
24
+ else (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execSingly)(task);
25
+ } catch (error) {
26
+ __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
27
+ }
28
+ }
29
+ });
30
+ export { task_task as task };
@@ -0,0 +1 @@
1
+ export * from "@esmate/eslint";
@@ -0,0 +1 @@
1
+ export * from "@esmate/eslint";
@@ -0,0 +1 @@
1
+ export * from "@esmate/prettier";
@@ -0,0 +1 @@
1
+ export * from "@esmate/prettier";
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ export declare const meta: {
3
+ name: string;
4
+ version: string;
5
+ description: string;
6
+ };
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__commands_fmt_js_e5e4d2b0__ from "./commands/fmt.js";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__commands_lint_js_e7950167__ from "./commands/lint.js";
6
+ import * as __WEBPACK_EXTERNAL_MODULE__commands_task_js_1beabf38__ from "./commands/task.js";
7
+ const meta = (()=>{
8
+ const pkgPath = new URL("../package.json", import.meta.url);
9
+ return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(pkgPath, "utf-8"));
10
+ })();
11
+ const main = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
12
+ meta,
13
+ subCommands: {
14
+ fmt: __WEBPACK_EXTERNAL_MODULE__commands_fmt_js_e5e4d2b0__.fmt,
15
+ lint: __WEBPACK_EXTERNAL_MODULE__commands_lint_js_e7950167__.lint,
16
+ task: __WEBPACK_EXTERNAL_MODULE__commands_task_js_1beabf38__.task
17
+ }
18
+ });
19
+ (0, __WEBPACK_EXTERNAL_MODULE_citty__.runMain)(main);
20
+ export { meta };
package/dist/pkg.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ type Task = string | string[] | Record<string, string | string[]>;
2
+ declare class Pkg {
3
+ path: string;
4
+ tasks: Record<string, Task>;
5
+ constructor();
6
+ }
7
+ export declare const pkg: Pkg;
8
+ export {};
package/dist/pkg.js ADDED
@@ -0,0 +1,13 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_find_up_69e9ea2b__ from "find-up";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
3
+ class Pkg {
4
+ path;
5
+ tasks;
6
+ constructor(){
7
+ this.path = (0, __WEBPACK_EXTERNAL_MODULE_find_up_69e9ea2b__.findUpSync)("package.json");
8
+ const pkg = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.readJsonSync)(this.path);
9
+ this.tasks = pkg.tasks || {};
10
+ }
11
+ }
12
+ const pkg_pkg = new Pkg();
13
+ export { pkg_pkg as pkg };
@@ -0,0 +1,5 @@
1
+ import type { JsonValue } from "type-fest";
2
+ export declare function execSingly(command: string | string[]): void;
3
+ export declare function execParallelly(commands: Record<string, string | string[]>): Promise<void>;
4
+ export declare function npx(command: string): void;
5
+ export declare function readJsonSync(filePath: string): JsonValue;
package/dist/utils.js ADDED
@@ -0,0 +1,37 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_concurrently__ from "concurrently";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
5
+ function execSingly(command) {
6
+ const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
7
+ const cmd = Array.isArray(command) ? command.join(" && ") : command;
8
+ (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.spawnSync)(cmd, {
9
+ shell: true,
10
+ stdio: "inherit",
11
+ env
12
+ });
13
+ }
14
+ async function execParallelly(commands) {
15
+ const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
16
+ const concurrentCommands = [];
17
+ for (const [name, command] of Object.entries(commands)){
18
+ const cmd = Array.isArray(command) ? command.join(" && ") : command;
19
+ concurrentCommands.push({
20
+ name,
21
+ command: cmd,
22
+ env
23
+ });
24
+ }
25
+ await (0, __WEBPACK_EXTERNAL_MODULE_concurrently__["default"])(concurrentCommands, {
26
+ handleInput: true,
27
+ prefixColors: "auto",
28
+ killOthers: "failure"
29
+ }).result.then(()=>{}).catch(()=>{});
30
+ }
31
+ function npx(command) {
32
+ execSingly(`npx --yes ${command}`);
33
+ }
34
+ function readJsonSync(filePath) {
35
+ return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, "utf-8"));
36
+ }
37
+ export { execParallelly, execSingly, npx, readJsonSync };
package/package.json CHANGED
@@ -1,52 +1,43 @@
1
1
  {
2
2
  "name": "esmate",
3
- "version": "0.0.10",
4
- "license": "MIT",
5
- "esmate": "lib",
6
3
  "type": "module",
4
+ "version": "0.0.12",
5
+ "description": "Uncomplicate JavaScript",
6
+ "license": "MIT",
7
+ "exports": {
8
+ "./*": {
9
+ "types": "./dist/exports/*.d.ts",
10
+ "import": "./dist/exports/*.js"
11
+ }
12
+ },
13
+ "bin": {
14
+ "esm": "./dist/index.js",
15
+ "esmate": "./dist/index.js"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
7
20
  "dependencies": {
8
- "@inquirer/prompts": "^7.4.1",
9
- "@vitejs/plugin-react-swc": "^3.8.1",
10
- "commander": "^13.1.0",
21
+ "citty": "^0.1.6",
11
22
  "concurrently": "^9.1.2",
12
- "es-toolkit": "^1.34.1",
13
- "eslint": "^9.24.0",
14
- "eslint-config-flat-gitignore": "^2.1.0",
15
- "eslint-config-prettier": "^10.1.1",
16
- "eslint-plugin-prettier": "^5.2.6",
17
- "eslint-plugin-react-hooks": "^5.2.0",
18
- "eslint-plugin-react-refresh": "^0.4.19",
23
+ "consola": "^3.4.2",
24
+ "es-toolkit": "^1.35.0",
19
25
  "find-up": "^7.0.0",
20
- "fs-extra": "^11.3.0",
21
- "globby": "^14.1.0",
22
- "npm-check-updates": "^17.1.18",
23
- "prettier": "^3.5.3",
24
- "prettier-plugin-organize-imports": "^4.1.0",
25
- "prettier-plugin-tailwindcss": "^0.6.11",
26
- "tsc-alias": "^1.8.15",
27
- "typescript": "^5.8.3",
28
- "typescript-eslint": "^8.29.0",
29
- "vite": "^6.2.5",
30
- "vite-plugin-pages": "^0.33.0",
31
- "vite-tsconfig-paths": "^5.1.4",
32
- "zod": "^3.24.2"
26
+ "nypm": "^0.6.0",
27
+ "@esmate/eslint": "0.0.21",
28
+ "@esmate/prettier": "0.0.2"
33
29
  },
34
- "bin": {
35
- "esm": "./cli/index.js",
36
- "esmate": "./cli/index.js"
30
+ "devDependencies": {
31
+ "@rslib/core": "^0.7.1",
32
+ "@types/node": "^22.8.1",
33
+ "tsx": "^4.19.4",
34
+ "type-fest": "^4.41.0",
35
+ "typescript": "^5.8.3"
37
36
  },
38
- "exports": {
39
- "./eslint": {
40
- "import": "./eslint/index.js",
41
- "types": "./eslint/index.d.ts"
42
- },
43
- "./prettier": {
44
- "import": "./prettier/index.js",
45
- "types": "./prettier/index.d.ts"
46
- },
47
- "./vite": {
48
- "import": "./vite/index.js",
49
- "types": "./vite/index.d.ts"
50
- }
37
+ "scripts": {
38
+ "build": "rslib build",
39
+ "dev": "rslib build --watch",
40
+ "fix": "prettier --write . && eslint --fix .",
41
+ "check": "prettier --check . && eslint ."
51
42
  }
52
- }
43
+ }
package/cli/esmate.d.ts DELETED
@@ -1,14 +0,0 @@
1
- declare class ESMate {
2
- private schema;
3
- private path;
4
- private package;
5
- private exports;
6
- constructor();
7
- get mode(): "app" | "lib";
8
- get version(): string;
9
- private write;
10
- private includeFiles;
11
- build(): void;
12
- }
13
- export declare const esmate: ESMate;
14
- export {};
package/cli/esmate.js DELETED
@@ -1,121 +0,0 @@
1
- import { z } from 'zod';
2
- import path from 'node:path';
3
- import { globbySync } from 'globby';
4
- import { findUpSync } from 'find-up';
5
- import fs from 'fs-extra';
6
- class ESMate {
7
- constructor() {
8
- Object.defineProperty(this, "schema", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: z.object({
13
- name: z.string(),
14
- version: z.string(),
15
- private: z.literal(true),
16
- esmate: z.enum(['app', 'lib']),
17
- type: z.literal('module'),
18
- main: z.undefined({ message: 'The "main" field is not needed for ESM projects.' }),
19
- module: z.undefined({ message: 'The "module" field is not needed for ESM projects.' }),
20
- scripts: z.record(z.string(), z.string()).optional(),
21
- bin: z
22
- .record(z.string(), z
23
- .string()
24
- .refine((value) => fs.existsSync(value), (value) => ({
25
- message: 'No file matches this bin value: ' + value,
26
- }))
27
- .refine((value) => value.startsWith('./src/'), () => ({
28
- message: 'A bin value must start with ./src/',
29
- })))
30
- .optional(),
31
- exports: z
32
- .record(z
33
- .string()
34
- .refine((key) => this.exports[key].replace('src/', '').startsWith(key), {
35
- message: 'An export value must be prefixed by its own key.',
36
- })
37
- .refine((key) => key.startsWith('./'), () => ({
38
- message: 'An export key must start with ./',
39
- })), z
40
- .string()
41
- .refine((value) => !value.includes('**'), (value) => ({
42
- message: 'Avoid cross-directory matching in this export value: ' + value,
43
- }))
44
- .refine((value) => value.startsWith('./src/'), () => ({
45
- message: 'An export value must start with ./src/',
46
- }))
47
- .refine((value) => globbySync(value).length > 0, (value) => ({
48
- message: 'No file matches this export value: ' + value,
49
- })))
50
- .optional(),
51
- files: z
52
- .array(z.string().refine((value) => globbySync(value).length > 0, (value) => ({
53
- message: 'No file matches this include value: ' + value,
54
- })))
55
- .optional(),
56
- })
57
- });
58
- Object.defineProperty(this, "path", {
59
- enumerable: true,
60
- configurable: true,
61
- writable: true,
62
- value: findUpSync('package.json')
63
- });
64
- Object.defineProperty(this, "package", {
65
- enumerable: true,
66
- configurable: true,
67
- writable: true,
68
- value: fs.readJSONSync(this.path)
69
- });
70
- Object.defineProperty(this, "exports", {
71
- enumerable: true,
72
- configurable: true,
73
- writable: true,
74
- value: this.package.exports || {}
75
- });
76
- this.schema.parse(this.package);
77
- }
78
- get mode() {
79
- return this.package.esmate;
80
- }
81
- get version() {
82
- return this.package.version;
83
- }
84
- write() {
85
- const { dir, base } = path.parse(this.path);
86
- const newPackage = Object.assign(Object.assign({}, this.package), { files: undefined, scripts: undefined, private: undefined, devDependencies: undefined, bin: (() => {
87
- const newBin = {};
88
- for (const key in this.package.bin) {
89
- const value = this.package.bin[key];
90
- const { dir, name } = path.parse(value);
91
- newBin[key] = `${dir.replace('/src/', '/')}/${name}.js`;
92
- }
93
- return newBin;
94
- })(), exports: (() => {
95
- const newExports = {};
96
- for (const key in this.package.exports) {
97
- const value = this.package.exports[key];
98
- const { dir, name } = path.parse(value);
99
- const out = `${dir.replace('/src/', '/')}/${name}`;
100
- newExports[key] = {
101
- import: out + '.js',
102
- types: out + '.d.ts',
103
- };
104
- }
105
- return newExports;
106
- })() });
107
- const newPath = path.join(dir, 'dist', base);
108
- fs.ensureFileSync(newPath);
109
- fs.writeJsonSync(newPath, newPackage, { spaces: 2 });
110
- }
111
- includeFiles() {
112
- for (const filePath of globbySync(this.package.files || [], { gitignore: true })) {
113
- fs.copy(filePath, filePath.replace('src/', 'dist/'));
114
- }
115
- }
116
- build() {
117
- this.write();
118
- this.includeFiles();
119
- }
120
- }
121
- export const esmate = new ESMate();
package/cli/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env -S node
2
- export {};
package/cli/index.js DELETED
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env -S node
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
- import { Command } from 'commander';
12
- import { confirm } from '@inquirer/prompts';
13
- import { esmate } from './esmate.js';
14
- import { app, lib } from './modes.js';
15
- import { executeOne, userArgs } from './utils.js';
16
- const program = new Command();
17
- program
18
- .name('esmate')
19
- .description('Build apps and libs with TypeScript following the ECMAScript standard.')
20
- .version(esmate.version)
21
- .action(() => {
22
- program.help();
23
- });
24
- program
25
- .command('run')
26
- .description('run a program')
27
- .allowExcessArguments(true)
28
- .allowUnknownOption()
29
- .option('-h, --help')
30
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
31
- yield executeOne({
32
- name: 'tsx',
33
- command: 'npx tsx',
34
- args: userArgs,
35
- prefixColor: 'blue',
36
- });
37
- }));
38
- switch (esmate.mode) {
39
- case 'app':
40
- app(program);
41
- break;
42
- case 'lib':
43
- lib(program);
44
- break;
45
- }
46
- program
47
- .command('lint')
48
- .description('lint and format code')
49
- .allowExcessArguments(true)
50
- .allowUnknownOption()
51
- .option('-h, --help')
52
- .action(() => __awaiter(void 0, void 0, void 0, function* () {
53
- yield executeOne({
54
- name: 'eslint',
55
- command: 'npx eslint',
56
- args: [...userArgs, '.'],
57
- });
58
- yield executeOne({
59
- name: 'prettier',
60
- command: 'npx prettier',
61
- args: [
62
- '--log-level',
63
- 'warn',
64
- '--ignore-unknown',
65
- (() => {
66
- if (userArgs.includes('--fix')) {
67
- return '--write';
68
- }
69
- else if (userArgs.includes('--fix-dry-run')) {
70
- return '--list-different';
71
- }
72
- else {
73
- return '--check';
74
- }
75
- })(),
76
- '.',
77
- ],
78
- prefixColor: 'cyan',
79
- });
80
- }));
81
- program
82
- .command('update')
83
- .description('check and update packages')
84
- .allowExcessArguments(true)
85
- .allowUnknownOption()
86
- .option('-h, --help')
87
- .action((script) => __awaiter(void 0, void 0, void 0, function* () {
88
- let answer = yield confirm({ message: 'Do you want to update to the latest packages?', default: false });
89
- executeOne({
90
- name: 'ncu',
91
- command: 'ncu',
92
- args: ['--interactive', '--target', answer ? 'semver' : 'latest'],
93
- });
94
- }));
95
- program.parse(process.argv);
package/cli/modes.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function app(program: Command): void;
3
- export declare function lib(program: Command): void;
package/cli/modes.js DELETED
@@ -1,92 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { executeMany, executeOne, userArgs } from './utils.js';
11
- import { esmate } from './esmate.js';
12
- export function app(program) {
13
- program
14
- .command('dev')
15
- .description('start dev server')
16
- .allowExcessArguments(true)
17
- .allowUnknownOption()
18
- .option('-h, --help')
19
- .action(() => __awaiter(this, void 0, void 0, function* () {
20
- yield executeMany([
21
- {
22
- name: 'vite',
23
- command: 'npx vite',
24
- args: userArgs,
25
- prefixColor: 'cyan',
26
- },
27
- ]);
28
- // https://www.npmjs.com/package/glob-watcher
29
- // watch files to fix and format
30
- }));
31
- program
32
- .command('build')
33
- .description('build for production')
34
- .allowExcessArguments(true)
35
- .allowUnknownOption()
36
- .option('-h, --help')
37
- .action(() => __awaiter(this, void 0, void 0, function* () {
38
- yield executeOne({
39
- name: 'typescript',
40
- command: 'npx tsc --noEmit',
41
- args: [],
42
- prefixColor: 'blue',
43
- });
44
- yield executeOne({
45
- name: 'vite',
46
- command: 'npx vite build',
47
- args: [...userArgs, '--emptyOutDir'],
48
- prefixColor: 'cyan',
49
- });
50
- }));
51
- program
52
- .command('start')
53
- .description('serve production build')
54
- .allowExcessArguments(true)
55
- .allowUnknownOption()
56
- .option('-h, --help')
57
- .action(() => __awaiter(this, void 0, void 0, function* () {
58
- yield executeOne({
59
- name: 'vite',
60
- command: 'npx vite preview',
61
- args: userArgs,
62
- prefixColor: 'cyan',
63
- });
64
- }));
65
- }
66
- export function lib(program) {
67
- program
68
- .command('dev')
69
- .description('watch and build')
70
- .allowExcessArguments(true)
71
- .allowUnknownOption()
72
- .option('-h, --help')
73
- .action(() => __awaiter(this, void 0, void 0, function* () {
74
- esmate.build();
75
- yield executeMany([
76
- {
77
- name: 'deves',
78
- command: 'npx tsc --watch',
79
- args: [],
80
- prefixColor: 'blue',
81
- },
82
- // {
83
- // name: 'deves',
84
- // command: 'npx tsc-alias --watch',
85
- // args: [],
86
- // prefixColor: 'cyan',
87
- // },
88
- ]);
89
- // https://www.npmjs.com/package/glob-watcher
90
- // watch files to fix and format
91
- }));
92
- }
package/cli/utils.d.ts DELETED
@@ -1,10 +0,0 @@
1
- interface Command {
2
- name: string;
3
- command: string;
4
- args: string[];
5
- prefixColor?: string;
6
- }
7
- export declare const userArgs: string[];
8
- export declare function executeOne(command: Command): Promise<void>;
9
- export declare function executeMany(commands: Command[]): Promise<void>;
10
- export {};
package/cli/utils.js DELETED
@@ -1,35 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import concurrently from 'concurrently';
11
- import { spawnSync } from 'node:child_process';
12
- export const userArgs = process.argv.slice(3);
13
- export function executeOne(command) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- spawnSync(command.command, command.args, {
16
- cwd: process.cwd(),
17
- stdio: 'inherit',
18
- shell: true,
19
- });
20
- });
21
- }
22
- export function executeMany(commands) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- commands = commands.map((cmd) => {
25
- const args = ' ' + cmd.args.map((arg) => arg.trim()).join(' ');
26
- const command = cmd.command.trim() + args;
27
- return Object.assign(Object.assign({}, cmd), { command, cwd: process.cwd() });
28
- });
29
- yield concurrently(commands, {
30
- killOthers: ['failure', 'success'],
31
- })
32
- .result.then(() => { })
33
- .catch(() => { });
34
- });
35
- }
package/eslint/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from './shared.js';
2
- export { react } from './react.js';
package/eslint/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from './shared.js';
2
- export { react } from './react.js';
package/eslint/node.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function node(): import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
package/eslint/node.js DELETED
@@ -1,15 +0,0 @@
1
- import globals from 'globals';
2
- import javaScript from '@eslint/js';
3
- import typeScript from 'typescript-eslint';
4
- import gitIgnore from 'eslint-config-flat-gitignore';
5
- import { prettier } from './shared.js';
6
- import { defineConfig, languageOptions } from './shared.js';
7
- export function node() {
8
- return defineConfig([
9
- {
10
- files: ['**/*.?(c|m)[jt]s?(x)'],
11
- languageOptions: Object.assign(Object.assign({}, languageOptions), { globals: globals.node }),
12
- extends: [gitIgnore(), javaScript.configs.recommended, ...typeScript.configs.recommended, prettier()],
13
- },
14
- ]);
15
- }
package/eslint/react.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function react(): import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
package/eslint/react.js DELETED
@@ -1,22 +0,0 @@
1
- import globals from 'globals';
2
- import javaScript from '@eslint/js';
3
- import typeScript from 'typescript-eslint';
4
- import reactHooks from 'eslint-plugin-react-hooks';
5
- import reactRefresh from 'eslint-plugin-react-refresh';
6
- import gitIgnore from 'eslint-config-flat-gitignore';
7
- import { prettier } from './shared.js';
8
- import { defineConfig, languageOptions } from './shared.js';
9
- export function react() {
10
- return defineConfig([
11
- {
12
- files: ['**/*.?(c|m)[jt]s?(x)'],
13
- languageOptions: Object.assign(Object.assign({}, languageOptions), { globals: globals.browser }),
14
- extends: [gitIgnore(), javaScript.configs.recommended, ...typeScript.configs.recommended, prettier()],
15
- plugins: {
16
- 'react-hooks': reactHooks,
17
- 'react-refresh': reactRefresh,
18
- },
19
- rules: Object.assign(Object.assign({}, reactHooks.configs.recommended.rules), { 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }] }),
20
- },
21
- ]);
22
- }
@@ -1,5 +0,0 @@
1
- import { Linter } from 'eslint';
2
- import { defineConfig } from 'eslint/config';
3
- export { defineConfig };
4
- export declare function prettier(): Linter.Config<Linter.RulesRecord>[];
5
- export declare const languageOptions: Linter.LanguageOptions;
package/eslint/shared.js DELETED
@@ -1,20 +0,0 @@
1
- import { defineConfig } from 'eslint/config';
2
- import prettierPlugin from 'eslint-plugin-prettier';
3
- import prettierConfig from 'eslint-config-prettier';
4
- export { defineConfig };
5
- export function prettier() {
6
- return defineConfig([
7
- {
8
- plugins: {
9
- prettier: prettierPlugin,
10
- },
11
- extends: [prettierConfig],
12
- rules: {
13
- 'prettier/prettier': ['warn'],
14
- },
15
- },
16
- ]);
17
- }
18
- export const languageOptions = {
19
- ecmaVersion: 2020,
20
- };
@@ -1,2 +0,0 @@
1
- export { defineConfig } from './shared.js';
2
- export { tailwind } from './tailwind.js';
package/prettier/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from './shared.js';
2
- export { tailwind } from './tailwind.js';
@@ -1,2 +0,0 @@
1
- import { Config } from 'prettier';
2
- export declare function defineConfig(configs: Config[]): Config;
@@ -1,33 +0,0 @@
1
- import { uniq } from 'es-toolkit';
2
- export function defineConfig(configs) {
3
- const defaultConfig = {
4
- semi: true,
5
- tabWidth: 2,
6
- printWidth: 120,
7
- singleQuote: true,
8
- trailingComma: 'none',
9
- plugins: ['prettier-plugin-organize-imports'],
10
- };
11
- for (const config of configs) {
12
- for (const key in config) {
13
- const value = config[key];
14
- if (key === 'plugins') {
15
- const plugins = defaultConfig.plugins || [];
16
- defaultConfig.plugins = uniq([...plugins, ...value]);
17
- }
18
- else {
19
- defaultConfig[key] = value;
20
- }
21
- // if (isJSONArray(value)) {
22
- // const array = (defaultConfig[key] as undefined) || [];
23
- // defaultConfig[key] = uniq([...array, ...value]);
24
- // } else if (isJSONObject(value)) {
25
- // const object = (defaultConfig[key] as undefined) || {};
26
- // defaultConfig[key] = { ...object, ...value };
27
- // } else {
28
- // defaultConfig[key] = value;
29
- // }
30
- }
31
- }
32
- return defaultConfig;
33
- }
@@ -1,10 +0,0 @@
1
- interface Options {
2
- tailwindFunctions: string[];
3
- tailwindConfig?: string;
4
- tailwindStylesheet?: string;
5
- tailwindAttributes?: string[];
6
- tailwindPreserveWhitespace?: boolean;
7
- tailwindPreserveDuplicates?: boolean;
8
- }
9
- export declare function tailwind(options: Options): import("prettier").Config;
10
- export {};
@@ -1,4 +0,0 @@
1
- import { defineConfig } from './shared.js';
2
- export function tailwind(options) {
3
- return defineConfig([Object.assign({ plugins: ['prettier-plugin-tailwindcss'] }, options)]);
4
- }
package/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const rootDir: string;
package/utils.js DELETED
@@ -1,3 +0,0 @@
1
- import { findUpSync } from 'find-up';
2
- import path from 'node:path';
3
- export const rootDir = path.dirname(findUpSync('package.json'));
package/vite/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from 'vite';
2
- export * as react from './react.js';
package/vite/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { defineConfig } from 'vite';
2
- export * as react from './react.js';
package/vite/react.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import pages from 'vite-plugin-pages';
2
- import paths from 'vite-tsconfig-paths';
3
- import react from '@vitejs/plugin-react-swc';
4
- interface SpaOptions {
5
- react: Parameters<typeof react>[0];
6
- pages: Parameters<typeof pages>[0];
7
- paths: Parameters<typeof paths>[0];
8
- }
9
- export declare function spa(options?: SpaOptions): {
10
- name: string;
11
- config: () => {
12
- publicDir: string;
13
- root: string;
14
- build: {
15
- outDir: string;
16
- };
17
- plugins: (import("vite").Plugin<any> | import("vite").PluginOption[])[];
18
- };
19
- };
20
- export declare function lib(): {};
21
- export {};
package/vite/react.js DELETED
@@ -1,21 +0,0 @@
1
- import pages from 'vite-plugin-pages';
2
- import paths from 'vite-tsconfig-paths';
3
- import react from '@vitejs/plugin-react-swc';
4
- import path from 'node:path';
5
- import { rootDir } from '../utils.js';
6
- export function spa(options) {
7
- return {
8
- name: 'react-app',
9
- config: () => ({
10
- publicDir: path.join(rootDir, 'public'),
11
- root: path.join(rootDir, 'src'),
12
- build: {
13
- outDir: path.join(rootDir, 'dist'),
14
- },
15
- plugins: [paths(options === null || options === void 0 ? void 0 : options.paths), pages(options === null || options === void 0 ? void 0 : options.pages), react(options === null || options === void 0 ? void 0 : options.react)],
16
- }),
17
- };
18
- }
19
- export function lib() {
20
- return {};
21
- }