@cyberskill/shared 1.45.0 → 1.47.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/README.md +12 -18
- package/dist/_tsup-dts-rollup.d.cts +39 -29
- package/dist/_tsup-dts-rollup.d.ts +39 -29
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/configs/eslint/base.cjs +1 -1
- package/dist/configs/eslint/base.js +1 -1
- package/dist/configs/eslint/nestjs.cjs +1 -1
- package/dist/configs/eslint/nestjs.js +1 -1
- package/dist/configs/eslint/nextjs.cjs +1 -1
- package/dist/configs/eslint/nextjs.js +1 -1
- package/dist/configs/eslint/nodejs.cjs +1 -1
- package/dist/configs/eslint/nodejs.js +1 -1
- package/dist/configs/eslint/vite-react.cjs +1 -1
- package/dist/configs/eslint/vite-react.js +1 -1
- package/dist/configs/graphql/graphql-codegen.cjs +1 -1
- package/dist/configs/graphql/graphql-codegen.js +1 -1
- package/dist/configs/graphql/index.cjs +1 -1
- package/dist/configs/graphql/index.js +1 -1
- package/dist/configs/index.cjs +1 -1
- package/dist/configs/index.js +1 -1
- package/dist/configs/lint-staged/base.cjs +1 -1
- package/dist/configs/lint-staged/base.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/nodejs/index.cjs +1 -1
- package/dist/nodejs/index.d.cts +0 -1
- package/dist/nodejs/index.d.ts +0 -1
- package/dist/nodejs/index.js +1 -1
- package/dist/nodejs/mongo.cjs +1 -1
- package/dist/nodejs/mongo.d.cts +0 -1
- package/dist/nodejs/mongo.d.ts +0 -1
- package/dist/nodejs/mongo.js +1 -1
- package/dist/typescript/index.cjs +1 -1
- package/dist/typescript/index.js +1 -1
- package/dist/typescript/mongo.cjs +1 -1
- package/dist/typescript/mongo.js +1 -1
- package/dist/utils/index-nodejs.cjs +1 -1
- package/dist/utils/index-nodejs.d.cts +1 -0
- package/dist/utils/index-nodejs.d.ts +1 -0
- package/dist/utils/index-nodejs.js +1 -1
- package/dist/utils/npm-package.cjs +1 -1
- package/dist/utils/npm-package.d.cts +1 -0
- package/dist/utils/npm-package.d.ts +1 -0
- package/dist/utils/npm-package.js +1 -1
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -39,32 +39,26 @@ CyberSkill Shared is a modular utility library designed to:
|
|
|
39
39
|
|
|
40
40
|
## 🚀 **Installation**
|
|
41
41
|
|
|
42
|
-
Install via **
|
|
42
|
+
Install via **pnpm**:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Install via **yarn**:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
yarn add @cyberskill/shared
|
|
45
|
+
pnpm install @cyberskill/shared
|
|
52
46
|
```
|
|
53
47
|
|
|
54
48
|
---
|
|
55
49
|
|
|
56
50
|
## 🛠️ **Scripts**
|
|
57
51
|
|
|
58
|
-
| Command
|
|
59
|
-
|
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
52
|
+
| Command | Description |
|
|
53
|
+
| ----------------------- | ----------------------------------- |
|
|
54
|
+
| `pnpm run dev` | Start development mode 🚧 |
|
|
55
|
+
| `pnpm run build` | Build for production 🚀 |
|
|
56
|
+
| `pnpm run lint` | Check for linting issues ✅ |
|
|
57
|
+
| `pnpm run lint:fix` | Fix linting issues 🔧 |
|
|
58
|
+
| `pnpm run lint:inspect` | Inspect linting config 🧐 |
|
|
59
|
+
| `pnpm run setup` | Project setup 🏗️ |
|
|
60
|
+
| `pnpm run reset` | Reset the project ♻️ |
|
|
61
|
+
| `pnpm run inspect` | Inspect the project dependencies 🔍 |
|
|
68
62
|
|
|
69
63
|
---
|
|
70
64
|
|
|
@@ -9,7 +9,6 @@ import type { ClientSession } from 'mongoose';
|
|
|
9
9
|
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
10
10
|
import { Collection } from 'mongodb';
|
|
11
11
|
import type { ComponentType } from 'react';
|
|
12
|
-
import { ConfigNames } from '@antfu/eslint-config';
|
|
13
12
|
import { Context } from 'react';
|
|
14
13
|
import { Db } from 'mongodb';
|
|
15
14
|
import type { DeleteResult } from 'mongodb';
|
|
@@ -18,7 +17,6 @@ import type { ErrorHandlingMiddlewareFunction } from 'mongoose';
|
|
|
18
17
|
import type { ErrorHandlingMiddlewareWithOption } from 'mongoose';
|
|
19
18
|
import type { Filter } from 'mongodb';
|
|
20
19
|
import type { FilterQuery } from 'mongoose';
|
|
21
|
-
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
22
20
|
import type { InitOptions } from 'i18next';
|
|
23
21
|
import type { InsertManyOptions } from 'mongoose';
|
|
24
22
|
import type { InsertManyResult } from 'mongodb';
|
|
@@ -27,8 +25,9 @@ import type { JSX } from 'react';
|
|
|
27
25
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
28
26
|
import type { Locale } from 'date-fns';
|
|
29
27
|
import { Model } from 'mongoose';
|
|
30
|
-
import type
|
|
28
|
+
import type mongoose from 'mongoose';
|
|
31
29
|
import mongoosePaginate from 'mongoose-paginate-v2';
|
|
30
|
+
import type mongooseRaw from 'mongoose';
|
|
32
31
|
import type { OptionalUnlessRequiredId } from 'mongodb';
|
|
33
32
|
import type { PaginateModel } from 'mongoose';
|
|
34
33
|
import type { PaginateOptions } from 'mongoose';
|
|
@@ -48,11 +47,10 @@ import type { Schema } from 'mongoose';
|
|
|
48
47
|
import type { SchemaDefinition } from 'mongoose';
|
|
49
48
|
import { TFunction } from 'i18next';
|
|
50
49
|
import type { Timezone } from 'next-intl';
|
|
51
|
-
import { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
52
50
|
import type { UpdateQuery } from 'mongoose';
|
|
53
51
|
import type { UpdateResult } from 'mongodb';
|
|
54
52
|
import type { UserConfig } from 'vite';
|
|
55
|
-
import { useTranslations } from '
|
|
53
|
+
import { useTranslations } from 'next-intl';
|
|
56
54
|
import type { WithId } from 'mongodb';
|
|
57
55
|
|
|
58
56
|
export { aggregatePaginate }
|
|
@@ -130,7 +128,7 @@ export { deepMerge as deepMerge_alias_1 }
|
|
|
130
128
|
export { deepMerge as deepMerge_alias_2 }
|
|
131
129
|
|
|
132
130
|
export declare const default_alias: {
|
|
133
|
-
merge: (type
|
|
131
|
+
merge: (type: string, ...configs: I_Config_2[]) => Promise<object>;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
134
|
export declare const default_alias_1: {
|
|
@@ -6292,7 +6290,7 @@ declare interface I_MongooseModelMiddleware_2<T extends Partial<C_Document_2>> {
|
|
|
6292
6290
|
}
|
|
6293
6291
|
|
|
6294
6292
|
declare interface I_MongooseOptions<T extends Partial<C_Document>> {
|
|
6295
|
-
mongoose: typeof
|
|
6293
|
+
mongoose: typeof mongoose;
|
|
6296
6294
|
virtuals?: {
|
|
6297
6295
|
name: keyof T | string;
|
|
6298
6296
|
options?: I_VirtualOptions_2;
|
|
@@ -6304,7 +6302,7 @@ export { I_MongooseOptions as I_MongooseOptions_alias_1 }
|
|
|
6304
6302
|
export { I_MongooseOptions as I_MongooseOptions_alias_2 }
|
|
6305
6303
|
|
|
6306
6304
|
declare interface I_MongooseOptions_2<T extends Partial<C_Document_2>> {
|
|
6307
|
-
mongoose: typeof
|
|
6305
|
+
mongoose: typeof mongoose;
|
|
6308
6306
|
virtuals?: {
|
|
6309
6307
|
name: keyof T | string;
|
|
6310
6308
|
options?: I_VirtualOptions;
|
|
@@ -6475,6 +6473,11 @@ export { initNodePersist }
|
|
|
6475
6473
|
export { initNodePersist as initNodePersist_alias_1 }
|
|
6476
6474
|
export { initNodePersist as initNodePersist_alias_2 }
|
|
6477
6475
|
|
|
6476
|
+
declare function installDependencies(): Promise<void>;
|
|
6477
|
+
export { installDependencies }
|
|
6478
|
+
export { installDependencies as installDependencies_alias_1 }
|
|
6479
|
+
export { installDependencies as installDependencies_alias_2 }
|
|
6480
|
+
|
|
6478
6481
|
declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
|
|
6479
6482
|
export { isCurrentProject }
|
|
6480
6483
|
export { isCurrentProject as isCurrentProject_alias_1 }
|
|
@@ -6512,6 +6515,29 @@ declare const mongo: {
|
|
|
6512
6515
|
createGenericFields({ returnDateAs, }?: {
|
|
6513
6516
|
returnDateAs?: "string" | "date";
|
|
6514
6517
|
}): I_GenericDocument_2;
|
|
6518
|
+
applyPlugins<T>(schema: T_MongooseShema_2<T>, plugins: Array<T_MongoosePlugin_2 | false>): void;
|
|
6519
|
+
applyMiddlewares<T extends Partial<C_Document_2>>(schema: T_MongooseShema_2<T>, middlewares: I_MongooseModelMiddleware_2<T>[]): void;
|
|
6520
|
+
createGenericSchema(mongoose: typeof mongooseRaw): mongooseRaw.Schema<I_GenericDocument_2, mongooseRaw.Model<I_GenericDocument_2, any, any, any, mongooseRaw.Document<unknown, any, I_GenericDocument_2> & I_GenericDocument_2 & Required<{
|
|
6521
|
+
_id: unknown;
|
|
6522
|
+
}> & {
|
|
6523
|
+
__v: number;
|
|
6524
|
+
}, any>, {}, {}, {}, {}, mongooseRaw.DefaultSchemaOptions, I_GenericDocument_2, mongooseRaw.Document<unknown, {}, mongooseRaw.FlatRecord<I_GenericDocument_2>> & mongooseRaw.FlatRecord<I_GenericDocument_2> & Required<{
|
|
6525
|
+
_id: unknown;
|
|
6526
|
+
}> & {
|
|
6527
|
+
__v: number;
|
|
6528
|
+
}>;
|
|
6529
|
+
createSchema<T extends Partial<C_Document_2>>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions_2<T>): T_MongooseShema_2<T>;
|
|
6530
|
+
createModel<T extends Partial<C_Document_2>>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions_2<T>): I_ExtendedModel_2<T>;
|
|
6531
|
+
createSlugQuery<T>(slug: string, filters?: T_FilterQuery_2<T>, id?: string): T_CreateSlugQueryResponse_2<T>;
|
|
6532
|
+
validator: {
|
|
6533
|
+
isEmpty<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
6534
|
+
isUnique<T extends {
|
|
6535
|
+
constructor: {
|
|
6536
|
+
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
6537
|
+
};
|
|
6538
|
+
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
6539
|
+
matchesRegex(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
6540
|
+
};
|
|
6515
6541
|
};
|
|
6516
6542
|
export { mongo }
|
|
6517
6543
|
export { mongo as mongo_alias_1 }
|
|
@@ -6570,24 +6596,6 @@ export { MongoController }
|
|
|
6570
6596
|
export { MongoController as MongoController_alias_1 }
|
|
6571
6597
|
export { MongoController as MongoController_alias_2 }
|
|
6572
6598
|
|
|
6573
|
-
declare const mongoose: {
|
|
6574
|
-
createSchema<T extends Partial<C_Document_2>>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions_2<T>): T_MongooseShema_2<T>;
|
|
6575
|
-
createModel<T extends Partial<C_Document_2>>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions_2<T>): I_ExtendedModel_2<T>;
|
|
6576
|
-
createSlugQuery<T>(slug: string, filters?: T_FilterQuery_2<T>, id?: string): T_CreateSlugQueryResponse_2<T>;
|
|
6577
|
-
validator: {
|
|
6578
|
-
isEmpty<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
6579
|
-
isUnique<T extends {
|
|
6580
|
-
constructor: {
|
|
6581
|
-
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
6582
|
-
};
|
|
6583
|
-
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
6584
|
-
matchesRegex(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
6585
|
-
};
|
|
6586
|
-
};
|
|
6587
|
-
export { mongoose }
|
|
6588
|
-
export { mongoose as mongoose_alias_1 }
|
|
6589
|
-
export { mongoose as mongoose_alias_2 }
|
|
6590
|
-
|
|
6591
6599
|
declare class MongooseController<T extends Partial<C_Document_2>> {
|
|
6592
6600
|
private model;
|
|
6593
6601
|
constructor(model: I_ExtendedModel_2<T>);
|
|
@@ -7074,12 +7082,14 @@ export { T_MongoosePlugin }
|
|
|
7074
7082
|
export { T_MongoosePlugin as T_MongoosePlugin_alias_1 }
|
|
7075
7083
|
export { T_MongoosePlugin as T_MongoosePlugin_alias_2 }
|
|
7076
7084
|
|
|
7077
|
-
declare type
|
|
7085
|
+
declare type T_MongoosePlugin_2 = (schema: Schema, options?: Record<string, unknown>) => void;
|
|
7086
|
+
|
|
7087
|
+
declare type T_MongooseShema<T> = mongoose.Schema<T>;
|
|
7078
7088
|
export { T_MongooseShema }
|
|
7079
7089
|
export { T_MongooseShema as T_MongooseShema_alias_1 }
|
|
7080
7090
|
export { T_MongooseShema as T_MongooseShema_alias_2 }
|
|
7081
7091
|
|
|
7082
|
-
declare type T_MongooseShema_2<T> =
|
|
7092
|
+
declare type T_MongooseShema_2<T> = mongoose.Schema<T>;
|
|
7083
7093
|
|
|
7084
7094
|
declare type T_NextIntlMessageList = Record<string, AbstractIntlMessages>;
|
|
7085
7095
|
export { T_NextIntlMessageList }
|
|
@@ -7251,7 +7261,7 @@ export { useStorage }
|
|
|
7251
7261
|
export { useStorage as useStorage_alias_1 }
|
|
7252
7262
|
export { useStorage as useStorage_alias_2 }
|
|
7253
7263
|
|
|
7254
|
-
declare const useTranslateNextIntl: useTranslations;
|
|
7264
|
+
declare const useTranslateNextIntl: typeof useTranslations;
|
|
7255
7265
|
export { useTranslateNextIntl }
|
|
7256
7266
|
export { useTranslateNextIntl as useTranslateNextIntl_alias_1 }
|
|
7257
7267
|
export { useTranslateNextIntl as useTranslateNextIntl_alias_2 }
|
|
@@ -9,7 +9,6 @@ import type { ClientSession } from 'mongoose';
|
|
|
9
9
|
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
10
10
|
import { Collection } from 'mongodb';
|
|
11
11
|
import type { ComponentType } from 'react';
|
|
12
|
-
import { ConfigNames } from '@antfu/eslint-config';
|
|
13
12
|
import { Context } from 'react';
|
|
14
13
|
import { Db } from 'mongodb';
|
|
15
14
|
import type { DeleteResult } from 'mongodb';
|
|
@@ -18,7 +17,6 @@ import type { ErrorHandlingMiddlewareFunction } from 'mongoose';
|
|
|
18
17
|
import type { ErrorHandlingMiddlewareWithOption } from 'mongoose';
|
|
19
18
|
import type { Filter } from 'mongodb';
|
|
20
19
|
import type { FilterQuery } from 'mongoose';
|
|
21
|
-
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
22
20
|
import type { InitOptions } from 'i18next';
|
|
23
21
|
import type { InsertManyOptions } from 'mongoose';
|
|
24
22
|
import type { InsertManyResult } from 'mongodb';
|
|
@@ -27,8 +25,9 @@ import type { JSX } from 'react';
|
|
|
27
25
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
28
26
|
import type { Locale } from 'date-fns';
|
|
29
27
|
import { Model } from 'mongoose';
|
|
30
|
-
import type
|
|
28
|
+
import type mongoose from 'mongoose';
|
|
31
29
|
import mongoosePaginate from 'mongoose-paginate-v2';
|
|
30
|
+
import type mongooseRaw from 'mongoose';
|
|
32
31
|
import type { OptionalUnlessRequiredId } from 'mongodb';
|
|
33
32
|
import type { PaginateModel } from 'mongoose';
|
|
34
33
|
import type { PaginateOptions } from 'mongoose';
|
|
@@ -48,11 +47,10 @@ import type { Schema } from 'mongoose';
|
|
|
48
47
|
import type { SchemaDefinition } from 'mongoose';
|
|
49
48
|
import { TFunction } from 'i18next';
|
|
50
49
|
import type { Timezone } from 'next-intl';
|
|
51
|
-
import { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
52
50
|
import type { UpdateQuery } from 'mongoose';
|
|
53
51
|
import type { UpdateResult } from 'mongodb';
|
|
54
52
|
import type { UserConfig } from 'vite';
|
|
55
|
-
import { useTranslations } from '
|
|
53
|
+
import { useTranslations } from 'next-intl';
|
|
56
54
|
import type { WithId } from 'mongodb';
|
|
57
55
|
|
|
58
56
|
export { aggregatePaginate }
|
|
@@ -130,7 +128,7 @@ export { deepMerge as deepMerge_alias_1 }
|
|
|
130
128
|
export { deepMerge as deepMerge_alias_2 }
|
|
131
129
|
|
|
132
130
|
export declare const default_alias: {
|
|
133
|
-
merge: (type
|
|
131
|
+
merge: (type: string, ...configs: I_Config_2[]) => Promise<object>;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
134
|
export declare const default_alias_1: {
|
|
@@ -6292,7 +6290,7 @@ declare interface I_MongooseModelMiddleware_2<T extends Partial<C_Document_2>> {
|
|
|
6292
6290
|
}
|
|
6293
6291
|
|
|
6294
6292
|
declare interface I_MongooseOptions<T extends Partial<C_Document>> {
|
|
6295
|
-
mongoose: typeof
|
|
6293
|
+
mongoose: typeof mongoose;
|
|
6296
6294
|
virtuals?: {
|
|
6297
6295
|
name: keyof T | string;
|
|
6298
6296
|
options?: I_VirtualOptions_2;
|
|
@@ -6304,7 +6302,7 @@ export { I_MongooseOptions as I_MongooseOptions_alias_1 }
|
|
|
6304
6302
|
export { I_MongooseOptions as I_MongooseOptions_alias_2 }
|
|
6305
6303
|
|
|
6306
6304
|
declare interface I_MongooseOptions_2<T extends Partial<C_Document_2>> {
|
|
6307
|
-
mongoose: typeof
|
|
6305
|
+
mongoose: typeof mongoose;
|
|
6308
6306
|
virtuals?: {
|
|
6309
6307
|
name: keyof T | string;
|
|
6310
6308
|
options?: I_VirtualOptions;
|
|
@@ -6475,6 +6473,11 @@ export { initNodePersist }
|
|
|
6475
6473
|
export { initNodePersist as initNodePersist_alias_1 }
|
|
6476
6474
|
export { initNodePersist as initNodePersist_alias_2 }
|
|
6477
6475
|
|
|
6476
|
+
declare function installDependencies(): Promise<void>;
|
|
6477
|
+
export { installDependencies }
|
|
6478
|
+
export { installDependencies as installDependencies_alias_1 }
|
|
6479
|
+
export { installDependencies as installDependencies_alias_2 }
|
|
6480
|
+
|
|
6478
6481
|
declare function isCurrentProject(WORKING_DIRECTORY: string, PACKAGE_NAME: string): boolean;
|
|
6479
6482
|
export { isCurrentProject }
|
|
6480
6483
|
export { isCurrentProject as isCurrentProject_alias_1 }
|
|
@@ -6512,6 +6515,29 @@ declare const mongo: {
|
|
|
6512
6515
|
createGenericFields({ returnDateAs, }?: {
|
|
6513
6516
|
returnDateAs?: "string" | "date";
|
|
6514
6517
|
}): I_GenericDocument_2;
|
|
6518
|
+
applyPlugins<T>(schema: T_MongooseShema_2<T>, plugins: Array<T_MongoosePlugin_2 | false>): void;
|
|
6519
|
+
applyMiddlewares<T extends Partial<C_Document_2>>(schema: T_MongooseShema_2<T>, middlewares: I_MongooseModelMiddleware_2<T>[]): void;
|
|
6520
|
+
createGenericSchema(mongoose: typeof mongooseRaw): mongooseRaw.Schema<I_GenericDocument_2, mongooseRaw.Model<I_GenericDocument_2, any, any, any, mongooseRaw.Document<unknown, any, I_GenericDocument_2> & I_GenericDocument_2 & Required<{
|
|
6521
|
+
_id: unknown;
|
|
6522
|
+
}> & {
|
|
6523
|
+
__v: number;
|
|
6524
|
+
}, any>, {}, {}, {}, {}, mongooseRaw.DefaultSchemaOptions, I_GenericDocument_2, mongooseRaw.Document<unknown, {}, mongooseRaw.FlatRecord<I_GenericDocument_2>> & mongooseRaw.FlatRecord<I_GenericDocument_2> & Required<{
|
|
6525
|
+
_id: unknown;
|
|
6526
|
+
}> & {
|
|
6527
|
+
__v: number;
|
|
6528
|
+
}>;
|
|
6529
|
+
createSchema<T extends Partial<C_Document_2>>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions_2<T>): T_MongooseShema_2<T>;
|
|
6530
|
+
createModel<T extends Partial<C_Document_2>>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions_2<T>): I_ExtendedModel_2<T>;
|
|
6531
|
+
createSlugQuery<T>(slug: string, filters?: T_FilterQuery_2<T>, id?: string): T_CreateSlugQueryResponse_2<T>;
|
|
6532
|
+
validator: {
|
|
6533
|
+
isEmpty<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
6534
|
+
isUnique<T extends {
|
|
6535
|
+
constructor: {
|
|
6536
|
+
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
6537
|
+
};
|
|
6538
|
+
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
6539
|
+
matchesRegex(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
6540
|
+
};
|
|
6515
6541
|
};
|
|
6516
6542
|
export { mongo }
|
|
6517
6543
|
export { mongo as mongo_alias_1 }
|
|
@@ -6570,24 +6596,6 @@ export { MongoController }
|
|
|
6570
6596
|
export { MongoController as MongoController_alias_1 }
|
|
6571
6597
|
export { MongoController as MongoController_alias_2 }
|
|
6572
6598
|
|
|
6573
|
-
declare const mongoose: {
|
|
6574
|
-
createSchema<T extends Partial<C_Document_2>>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions_2<T>): T_MongooseShema_2<T>;
|
|
6575
|
-
createModel<T extends Partial<C_Document_2>>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions_2<T>): I_ExtendedModel_2<T>;
|
|
6576
|
-
createSlugQuery<T>(slug: string, filters?: T_FilterQuery_2<T>, id?: string): T_CreateSlugQueryResponse_2<T>;
|
|
6577
|
-
validator: {
|
|
6578
|
-
isEmpty<T>(): (this: T, value: unknown) => Promise<boolean>;
|
|
6579
|
-
isUnique<T extends {
|
|
6580
|
-
constructor: {
|
|
6581
|
-
findOne: (query: Record<string, unknown>) => Promise<unknown>;
|
|
6582
|
-
};
|
|
6583
|
-
}>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
|
|
6584
|
-
matchesRegex(regexArray: RegExp[]): (value: string) => Promise<boolean>;
|
|
6585
|
-
};
|
|
6586
|
-
};
|
|
6587
|
-
export { mongoose }
|
|
6588
|
-
export { mongoose as mongoose_alias_1 }
|
|
6589
|
-
export { mongoose as mongoose_alias_2 }
|
|
6590
|
-
|
|
6591
6599
|
declare class MongooseController<T extends Partial<C_Document_2>> {
|
|
6592
6600
|
private model;
|
|
6593
6601
|
constructor(model: I_ExtendedModel_2<T>);
|
|
@@ -7074,12 +7082,14 @@ export { T_MongoosePlugin }
|
|
|
7074
7082
|
export { T_MongoosePlugin as T_MongoosePlugin_alias_1 }
|
|
7075
7083
|
export { T_MongoosePlugin as T_MongoosePlugin_alias_2 }
|
|
7076
7084
|
|
|
7077
|
-
declare type
|
|
7085
|
+
declare type T_MongoosePlugin_2 = (schema: Schema, options?: Record<string, unknown>) => void;
|
|
7086
|
+
|
|
7087
|
+
declare type T_MongooseShema<T> = mongoose.Schema<T>;
|
|
7078
7088
|
export { T_MongooseShema }
|
|
7079
7089
|
export { T_MongooseShema as T_MongooseShema_alias_1 }
|
|
7080
7090
|
export { T_MongooseShema as T_MongooseShema_alias_2 }
|
|
7081
7091
|
|
|
7082
|
-
declare type T_MongooseShema_2<T> =
|
|
7092
|
+
declare type T_MongooseShema_2<T> = mongoose.Schema<T>;
|
|
7083
7093
|
|
|
7084
7094
|
declare type T_NextIntlMessageList = Record<string, AbstractIntlMessages>;
|
|
7085
7095
|
export { T_NextIntlMessageList }
|
|
@@ -7251,7 +7261,7 @@ export { useStorage }
|
|
|
7251
7261
|
export { useStorage as useStorage_alias_1 }
|
|
7252
7262
|
export { useStorage as useStorage_alias_2 }
|
|
7253
7263
|
|
|
7254
|
-
declare const useTranslateNextIntl: useTranslations;
|
|
7264
|
+
declare const useTranslateNextIntl: typeof useTranslations;
|
|
7255
7265
|
export { useTranslateNextIntl }
|
|
7256
7266
|
export { useTranslateNextIntl as useTranslateNextIntl_alias_1 }
|
|
7257
7267
|
export { useTranslateNextIntl as useTranslateNextIntl_alias_2 }
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";function e(e,t,n,r,s,i,c){try{var o=e[i](c);var a=o.value}catch(e){n(e);return}if(o.done){t(a)}else{Promise.resolve(a).then(r,s)}}function t(t){return function(){var n=this,r=arguments;return new Promise(function(s,i){var c=t.apply(n,r);function o(t){e(c,s,i,o,a,"next",t)}function a(t){e(c,s,i,o,a,"throw",t)}o(undefined)})}}function n(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var s=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){s=s.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}s.forEach(function(t){n(e,t,r[t])})}return e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function i(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{s(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function c(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function o(e,t){var n,r,s,i,c={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(e){return function(t){return a([e,t])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c)try{if(n=1,r&&(s=i[0]&2?r["return"]:i[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,i[1])).done)return s;if(r=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:c.label++;return{value:i[1],done:false};case 5:c.label++;r=i[1];i=[0];continue;case 7:i=c.ops.pop();c.trys.pop();continue;default:if(!(s=c.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){c=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){c.label=i[1];break}if(i[0]===6&&c.label<s[1]){c.label=s[1];s=i;break}if(s&&c.label<s[2]){c.label=s[2];c.ops.push(i);break}if(s[2])c.ops.pop();c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e];r=0}finally{n=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var a=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var h=function(e,t,n,r){var s=true,i=false,o=undefined;if(t&&(typeof t==="undefined"?"undefined":c(t))=="object"||typeof t=="function")try{var a=function(){var s=h.value;!d.call(e,s)&&s!==n&&u(e,s,{get:function(){return t[s]},enumerable:!(r=l(t,s))||r.enumerable})};for(var p=f(t)[Symbol.iterator](),h;!(s=(h=p.next()).done);s=true)a()}catch(e){i=true;o=e}finally{try{if(!s&&p.return!=null){p.return()}}finally{if(i){throw o}}}return e};var g=function(e,t,n){return n=e!=null?a(p(e)):{},h(t||!e||!e.__esModule?u(n,"default",{value:e,enumerable:!0}):n,e)};var y=function(){return(typeof document==="undefined"?"undefined":c(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=y();var v=g(require("fs"),1),b=g(require("path"),1),w=g(require("process"),1),S=require("yargs/helpers"),_=g(require("yargs/yargs"),1);var O=require("path"),T=g(require("process"),1),A=require("url"),P=(0,A.fileURLToPath)(m),k=(0,O.dirname)(P),E=T.default.env.INIT_CWD||T.default.cwd();var I=g(require("boxen"),1),j=g(require("chalk"),1),N=require("child_process"),C=g(require("process"),1),G=g(require("util"),1);var x=g(require("node-persist"),1),F=g(require("os"),1),H=g(require("path"),1),M=g(require("process"),1),L=M.default.env.CYBERSKILL_STORAGE_DIR||H.default.join(F.default.homedir(),".cyberskill-storage");function R(){return K.apply(this,arguments)}function K(){K=t(function(){var e;return o(this,function(t){switch(t.label){case 0:e=x.default.defaultInstance;if(e)return[3,2];return[4,x.default.init({dir:L,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return K.apply(this,arguments)}var q={get:function e(e){return t(function(){var t,n;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,R()];case 1:r.sent();return[4,x.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,n){return t(function(){var t;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,R()];case 1:r.sent();return[4,x.default.setItem(e,n)];case 2:r.sent();return[3,4];case 3:t=r.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return t(function(){var t;return o(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,R()];case 1:n.sent();return[4,x.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return t(function(){var e,t;return o(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,R()];case 1:n.sent();return[4,x.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return t(function(){return o(this,function(t){try{return[2,"".concat(L," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var D=C.default.env.DEBUG==="true",U=G.promisify(N.exec),J=j.default,B=J.gray,W=J.blue,Y=function(){return B("[".concat(new Date().toLocaleTimeString(),"]"))};function $(e){var t=j.default[e];return typeof t=="function"?t:j.default.green}function z(e,t,n,r){var s=$(t);console.log("".concat(Y()," ").concat(s("".concat(n," ").concat(e))," ").concat(r))}function Q(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.color,s=r===void 0?"green":r,i=n.padding,c=i===void 0?1:i,o=n.margin,a=o===void 0?1:o,u=n.borderStyle,l=u===void 0?"round":u,f=n.titleColor,p=f===void 0?"bold":f;var d=$(s),h=$(p);if(typeof t=="string"){console.log((0,I.default)(h(d("".concat(e,"\n").concat(t))),{padding:c,margin:a,borderStyle:l,borderColor:s}));return}Array.isArray(t)&&t.length&&(t.forEach(function(e){var t=e.file,n=e.position,r=e.rule,s=e.message;console.log("".concat(Y()," ").concat(d("File:")," ").concat(W("".concat(t).concat(n?":".concat(n):"")))),r&&console.log(" ".concat(d("Rule:")," ").concat(d(r))),console.log(" ".concat(d("Message:")," ").concat(d(s)))}),console.log((0,I.default)(h(d("".concat(e,": ").concat(t.length))),{padding:c,margin:a,borderStyle:l,borderColor:s})),console.log(B("─".repeat(40))))}var V={success:function(e){return z("SUCCESS","green","✔",e)},error:function(e){return z("ERROR","red","✖",e)},warning:function(e){return z("WARNING","yellow","⚠",e)},info:function(e){return z("INFO","blue","ℹ",e)},printBoxedLog:Q},X=function(e){return"error_list:".concat(e)};function Z(e){return ee.apply(this,arguments)}function ee(){ee=t(function(e){var n,r,s;return o(this,function(i){switch(i.label){case 0:if(e.length===0)return[2];n=Date.now(),r=X(n);i.label=1;case 1:i.trys.push([1,3,,4]);return[4,q.set(r,{errors:e,timestamp:n})];case 2:i.sent(),setTimeout(/*#__PURE__*/t(function(){var e;return o(this,function(t){switch(t.label){case 0:return[4,q.getLogLink(r)];case 1:e=t.sent();e&&V.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:s=i.sent();V.error("Failed to save errors: ".concat(s.message));return[3,4];case 4:return[2]}})});return ee.apply(this,arguments)}function et(){return en.apply(this,arguments)}function en(){en=t(function(){var e,n,r;return o(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,q.keys()];case 1:e=s.sent(),n=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(n.map(/*#__PURE__*/function(){var e=t(function(e){var t;return o(this,function(n){switch(n.label){case 0:return[4,q.get(e)];case 1:return[2,((t=n.sent())===null||t===void 0?void 0:t.errors)||[]]}})});return function(t){return e.apply(this,arguments)}}()))];case 2:return[2,s.sent().flat()];case 3:r=s.sent();return[2,(V.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return en.apply(this,arguments)}function er(){return es.apply(this,arguments)}function es(){es=t(function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,q.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return q.remove(e)}))];case 2:r.sent();return[3,4];case 3:n=r.sent();V.error("Failed to clear error lists: ".concat(n.message));return[3,4];case 4:return[2]}})});return es.apply(this,arguments)}function ei(e){var t=[],n=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,i=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var o=s.exec(e)||[],a=i.exec(e)||[],u=c.exec(e)||[];o.length&&r?t.push({file:r,position:"".concat(o[1],":").concat(o[2]),type:o[3]==="error"?"error":"warning",message:o[4].trim(),rule:o[5].trim()}):a.length?t.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4]==="error"?"error":"warning",message:a[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):n.push(e.trim())}}),t.length&&Z(t),n.length&&D&&(V.warning("Unmatched lines:"),n.forEach(function(e){return console.log(" ".concat(e))}))}function ec(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,i=e.column,c=e.ruleId,o=e.message;n.push({type:r===2?"error":"warning",file:t,position:"".concat(s,":").concat(i),rule:c,message:o})})}),n.length&&Z(n)}catch(t){ei(e)}}function eo(e){return ea.apply(this,arguments)}function ea(){ea=t(function(e){var t,n,r,s,i,c,a,u,l;var f=arguments;return o(this,function(o){switch(o.label){case 0:t=f.length>1&&f[1]!==void 0?f[1]:ec;n=new AbortController;C.default.on("SIGINT",function(){V.warning("Process interrupted. Terminating..."),n.abort(),C.default.exit()});o.label=1;case 1:o.trys.push([1,3,,4]);return[4,U(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=o.sent(),s=r.stdout,i=r.stderr;[s,i].forEach(function(e){return e&&t(e)});return[3,4];case 3:c=o.sent();a=c.stdout,u=c.stderr,l=c.message;[a,u].forEach(function(e){return e&&t(e)}),!u&&!a&&V.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return ea.apply(this,arguments)}var eu=g(require("fs"),1),el=function(e){return eu.existsSync(e)};var ef=g(require("node-fetch"),1),ep=g(require("fs"),1),ed=g(require("path"),1);var eh=24*60*60*1e3;function eg(e){return e?ed.default.join(E,"node_modules",e,"package.json"):ed.default.join(E,"package.json")}function ey(e){return em.apply(this,arguments)}function em(){em=t(function(e){var t,n,r,s,i,c,a,u,l,f;var p=arguments;return o(this,function(o){switch(o.label){case 0:t=p.length>1&&p[1]!==void 0?p[1]:!1;n="npm_version:".concat(e),r="npm_metadata:".concat(e);return[4,q.get(n)];case 1:s=o.sent();return[4,q.get(r)];case 2:i=o.sent(),c=s&&Date.now()-s.timestamp<eh;if(!t&&c)return[2,s.version];a={};(i===null||i===void 0?void 0:i.etag)&&(a["If-None-Match"]=i.etag),(i===null||i===void 0?void 0:i.lastModified)&&(a["If-Modified-Since"]=i.lastModified);o.label=3;case 3:o.trys.push([3,8,,9]);return[4,(0,ef.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:a})];case 4:u=o.sent();if(u.status===304&&s)return[2,s.version];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=o.sent().version;return[4,q.set(n,{version:l,timestamp:Date.now()})];case 6:o.sent();return[4,q.set(r,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(o.sent(),l)];case 8:f=o.sent();if(V.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),s)return[2,(V.warning("Falling back to cached version for ".concat(e,": ").concat(s.version)),s.version)];throw f;case 9:return[2]}})});return em.apply(this,arguments)}function ev(e){return eb.apply(this,arguments)}function eb(){eb=t(function(e){var t,n,r,s,i;var c=arguments;return o(this,function(o){switch(o.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:!0;o.label=1;case 1:o.trys.push([1,3,,4]);n=eg(e);if(!ep.default.existsSync(n))return[2,(V.info("".concat(e," is not installed.")),!0)];r=JSON.parse(ep.default.readFileSync(n,"utf-8")).version;return[4,ey(e,t)];case 2:s=o.sent();return[2,(V.info("Installed version of ".concat(e,": ").concat(r)),V.info("Latest version of ".concat(e,": ").concat(s)),r!==s)];case 3:i=o.sent();return[2,(V.warning("Failed to check version for ".concat(e,": ").concat(i.message)),!0)];case 4:return[2]}})});return eb.apply(this,arguments)}function ew(e){return eS.apply(this,arguments)}function eS(){eS=t(function(e){var t,s,c,a;return o(this,function(o){switch(o.label){case 0:o.trys.push([0,4,,5]);return[4,ey(e,!0)];case 1:t=o.sent(),s=eg();if(!ep.default.existsSync(s)){V.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(ep.default.readFileSync(s,"utf-8"));c.dependencies=i(r({},c.dependencies),n({},e,t)),ep.default.writeFileSync(s,JSON.stringify(c,null,2)),V.info("Updated ".concat(e," to version ").concat(t));return[4,eo("npm i -f")];case 2:o.sent();return[4,eo("npm run lint:fix")];case 3:o.sent(),V.success("".concat(e," updated successfully."));return[3,5];case 4:a=o.sent();throw V.error("Failed to update ".concat(e,": ").concat(a.message)),a;case 5:return[2]}})});return eS.apply(this,arguments)}function e_(e,t){try{var n=ed.default.join(e,"package.json");return ep.default.existsSync(n)?JSON.parse(ep.default.readFileSync(n,"utf-8")).name===t:!1}catch(e){return V.error("Error reading package.json: ".concat(e.message)),!1}}var eO={TS_CONFIG_PATH:b.resolve(E,"tsconfig.json"),HUSKY_PATH:b.resolve(E,".husky"),GIT_HOOK_PATH:b.resolve(E,".git/hooks"),GIT_COMMIT_MSG:b.resolve(E,".git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:b.resolve(E,".simple-git-hooks.json"),PACKAGE_JSON_PATH:b.resolve(E,"package.json"),PACKAGE_LOCK_PATH:b.resolve(E,"package-lock.json"),PACKAGE_NAME:"@cyberskill/shared",LINT_STAGED_CONFIG_PATH:b.resolve(k,"./configs/lint-staged/base.js"),COMMITLINT_CONFIG_PATH:b.resolve(k,"./configs/commitlint/base.js"),UNIT_TEST_CONFIG_PATH:b.resolve(k,"./configs/vitest/react/unit.js"),E2E_TEST_CONFIG_PATH:b.resolve(k,"./configs/vitest/react/e2e.js"),HOOKS_CONFIG:{"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"}};function eT(e,t){return eA.apply(this,arguments)}function eA(){eA=t(function(e,t){return o(this,function(n){switch(n.label){case 0:V.info("".concat(e,"..."));return[4,eo(t)];case 1:n.sent(),V.success("".concat(e," completed."));return[2]}})});return eA.apply(this,arguments)}function eP(){return ek.apply(this,arguments)}function ek(){ek=t(function(){var e;return o(this,function(t){switch(t.label){case 0:if(!el(eO.TS_CONFIG_PATH))return[3,2];return[4,eT("Running TypeScript check","npx tsc -p ".concat(eO.TS_CONFIG_PATH," --noEmit"))];case 1:e=t.sent();return[3,3];case 2:e=V.warning("TypeScript config not found. Skipping TypeScript check.");t.label=3;case 3:e;return[2]}})});return ek.apply(this,arguments)}function eE(){return eI.apply(this,arguments)}function eI(){eI=t(function(){var e;var t=arguments;return o(this,function(n){switch(n.label){case 0:e=t.length>0&&t[0]!==void 0?t[0]:!1;return[4,eT("Running ESLint ".concat(e?"(with fix)":"(without fix)"),"npx eslint ".concat(E).concat(e?" --fix":""))];case 1:n.sent();return[2]}})});return eI.apply(this,arguments)}function ej(){return eN.apply(this,arguments)}function eN(){eN=t(function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:return[4,et()];case 1:e=r.sent(),t=e.filter(function(e){return e.type==="error"}),n=e.filter(function(e){return e.type==="warning"});!t.length&&!n.length?V.printBoxedLog("✔ NO ISSUES FOUND","",{color:"green"}):(V.printBoxedLog("⚠ Warnings",n,{color:"yellow"}),V.printBoxedLog("✖ Errors",t,{color:"red"}));return[2]}})});return eN.apply(this,arguments)}function eC(){return eG.apply(this,arguments)}function eG(){eG=t(function(){var e;return o(this,function(t){switch(t.label){case 0:if(!e_(E,eO.PACKAGE_NAME))return[3,5];t.label=1;case 1:t.trys.push([1,4,,5]);return[4,eT("Building @cyberskill/shared","npm run build")];case 2:t.sent();return[4,eo("git add dist")];case 3:t.sent(),V.success("Built and staged @cyberskill/shared");return[3,5];case 4:e=t.sent();throw V.error("Failed to build and stage @cyberskill/shared: ".concat(e.message)),e;case 5:return[4,eT("Running lint-staged","npx lint-staged --config ".concat(eO.LINT_STAGED_CONFIG_PATH))];case 6:t.sent(),ej();return[2]}})});return eG.apply(this,arguments)}function ex(){return eF.apply(this,arguments)}function eF(){eF=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Inspecting ESLint rules","npx @eslint/config-inspector")];case 1:e.sent();return[2]}})});return eF.apply(this,arguments)}function eH(){return eM.apply(this,arguments)}function eM(){eM=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,er()];case 1:e.sent();return[4,Promise.all([eP(),eE()])];case 2:e.sent(),ej();return[2]}})});return eM.apply(this,arguments)}function eL(){return eR.apply(this,arguments)}function eR(){eR=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,er()];case 1:e.sent();return[4,Promise.all([eP(),eE(!0)])];case 2:e.sent(),ej();return[2]}})});return eR.apply(this,arguments)}function eK(){return eq.apply(this,arguments)}function eq(){eq=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Running commit lint","npx commitlint --edit ".concat(eO.GIT_COMMIT_MSG," --config ").concat(eO.COMMITLINT_CONFIG_PATH))];case 1:e.sent(),ej();return[2]}})});return eq.apply(this,arguments)}function eD(){return eU.apply(this,arguments)}function eU(){eU=t(function(){var e,t,n,r,s,i;return o(this,function(c){switch(c.label){case 0:if(V.info("Starting project setup..."),!el(eO.PACKAGE_JSON_PATH)){V.error("package.json not found. Aborting setup.");return[2]}c.label=1;case 1:c.trys.push([1,9,,10]);t=JSON.parse(v.readFileSync(eO.PACKAGE_JSON_PATH,"utf-8"));r=e_(E,eO.PACKAGE_NAME);if(r)return[3,4];s=(e=t.dependencies)===null||e===void 0?void 0:e[eO.PACKAGE_NAME];if(!s)return[3,3];return[4,ev(eO.PACKAGE_NAME)];case 2:s=!c.sent();c.label=3;case 3:r=s;c.label=4;case 4:if(!r)return[3,5];n=V.success("Cyberskill package is already up to date.");return[3,7];case 5:V.info("\uD83D\uDCE6 Updating Cyberskill package...");return[4,ew(eO.PACKAGE_NAME)];case 6:n=(c.sent(),V.success("Cyberskill package updated successfully."));c.label=7;case 7:n;return[4,eJ()];case 8:c.sent(),V.success("Project setup completed.");return[3,10];case 9:i=c.sent();throw V.error("Failed to setup project: ".concat(i.message)),i;case 10:return[2]}})});return eU.apply(this,arguments)}function eJ(){return eB.apply(this,arguments)}function eB(){eB=t(function(){var e,t;return o(this,function(n){switch(n.label){case 0:V.info("Setting up Git hooks...");e=el(eO.HUSKY_PATH);if(!e)return[3,3];return[4,eo("npx rimraf ".concat(eO.HUSKY_PATH," ").concat(eO.GIT_HOOK_PATH))];case 1:n.sent();return[4,eo("git config core.hooksPath ".concat(eO.GIT_HOOK_PATH))];case 2:e=n.sent();n.label=3;case 3:e,v.writeFileSync(eO.SIMPLE_GIT_HOOKS_PATH,JSON.stringify(eO.HOOKS_CONFIG,null,4));t=b.resolve(".gitignore");el(t)?v.readFileSync(t,"utf8").split("\n").includes(".simple-git-hooks.json")?V.info(".simple-git-hooks.json is already ignored in .gitignore"):(v.appendFileSync(t,"\n# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),V.info("Added .simple-git-hooks.json to .gitignore")):(v.writeFileSync(t,"# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),V.info("Created .gitignore and added .simple-git-hooks.json"));return[4,eo("npx simple-git-hooks")];case 4:n.sent(),V.success("Git hooks configured successfully.");return[2]}})});return eB.apply(this,arguments)}function eW(){return eY.apply(this,arguments)}function eY(){eY=t(function(){var e,t,n,r,s,i,c,a,u,l,f;return o(this,function(o){switch(o.label){case 0:e=[{command:"npm install",message:"Standard installation"},{command:"npm install --legacy-peer-deps",message:"Attempting installation with --legacy-peer-deps"},{command:"npm install --force",message:"Attempting forced installation"}];t=true,n=false,r=undefined;o.label=1;case 1:o.trys.push([1,8,9,10]);s=e[Symbol.iterator]();o.label=2;case 2:if(!!(t=(i=s.next()).done))return[3,7];c=i.value,a=c.command,u=c.message;o.label=3;case 3:o.trys.push([3,5,,6]);V.info("".concat(u,"..."));return[4,eo(a)];case 4:o.sent(),V.success("Dependencies installed using: ".concat(a));return[2];case 5:l=o.sent();V.warning("Failed with: ".concat(a)),V.error("Error: ".concat(l.message));return[3,6];case 6:t=true;return[3,2];case 7:return[3,10];case 8:f=o.sent();n=true;r=f;return[3,10];case 9:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 10:throw new Error("Failed to install dependencies after multiple attempts.")}})});return eY.apply(this,arguments)}function e$(){return ez.apply(this,arguments)}function ez(){ez=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Resetting project","npx rimraf ".concat(E,"/node_modules ").concat(eO.PACKAGE_LOCK_PATH))];case 1:e.sent();return[4,eW()];case 2:e.sent();return[4,eJ()];case 3:e.sent();return[2]}})});return ez.apply(this,arguments)}function eQ(){return eV.apply(this,arguments)}function eV(){eV=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Inspecting project dependencies","npx node-modules-inspector")];case 1:e.sent();return[2]}})});return eV.apply(this,arguments)}function eX(){return eZ.apply(this,arguments)}function eZ(){eZ=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Running unit tests","npx vitest --config ".concat(eO.UNIT_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eZ.apply(this,arguments)}function e0(){return e1.apply(this,arguments)}function e1(){e1=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eT("Running E2E tests","npx vitest --config ".concat(eO.E2E_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return e1.apply(this,arguments)}(0,_.default)((0,S.hideBin)(w.default.argv)).command("lint","Run linting checks",eH).command("lint:fix","Fix linting issues",eL).command("lint:inspect","Inspect linting rules",ex).command("lint-staged","Run lint-staged",eC).command("commitlint","Run commitlint",eK).command("setup","Run project setup",eD).command("reset","Reset project dependencies",e$).command("inspect","Inspect project dependencies",eQ).command("test:unit","Run unit tests",eX).command("test:e2e","Run e2e tests",e0).help().parse();
|
|
2
|
+
"use strict";function e(e,t,n,r,s,i,c){try{var o=e[i](c);var a=o.value}catch(e){n(e);return}if(o.done){t(a)}else{Promise.resolve(a).then(r,s)}}function t(t){return function(){var n=this,r=arguments;return new Promise(function(s,i){var c=t.apply(n,r);function o(t){e(c,s,i,o,a,"next",t)}function a(t){e(c,s,i,o,a,"throw",t)}o(undefined)})}}function n(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};var s=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){s=s.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}s.forEach(function(t){n(e,t,r[t])})}return e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function i(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{s(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function c(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function o(e,t){var n,r,s,i,c={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return i={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function o(e){return function(t){return a([e,t])}}function a(i){if(n)throw new TypeError("Generator is already executing.");while(c)try{if(n=1,r&&(s=i[0]&2?r["return"]:i[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,i[1])).done)return s;if(r=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:c.label++;return{value:i[1],done:false};case 5:c.label++;r=i[1];i=[0];continue;case 7:i=c.ops.pop();c.trys.pop();continue;default:if(!(s=c.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){c=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){c.label=i[1];break}if(i[0]===6&&c.label<s[1]){c.label=s[1];s=i;break}if(s&&c.label<s[2]){c.label=s[2];c.ops.push(i);break}if(s[2])c.ops.pop();c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e];r=0}finally{n=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}}var a=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var h=function(e,t,n,r){var s=true,i=false,o=undefined;if(t&&(typeof t==="undefined"?"undefined":c(t))=="object"||typeof t=="function")try{var a=function(){var s=h.value;!d.call(e,s)&&s!==n&&u(e,s,{get:function(){return t[s]},enumerable:!(r=l(t,s))||r.enumerable})};for(var p=f(t)[Symbol.iterator](),h;!(s=(h=p.next()).done);s=true)a()}catch(e){i=true;o=e}finally{try{if(!s&&p.return!=null){p.return()}}finally{if(i){throw o}}}return e};var g=function(e,t,n){return n=e!=null?a(p(e)):{},h(t||!e||!e.__esModule?u(n,"default",{value:e,enumerable:!0}):n,e)};var y=function(){return(typeof document==="undefined"?"undefined":c(document))>"u"?new URL("file:".concat(__filename)).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href},m=y();var v=g(require("fs"),1),b=g(require("path"),1),w=g(require("process"),1),O=require("yargs/helpers"),_=g(require("yargs/yargs"),1);var S=require("path"),A=g(require("process"),1),T=require("url"),P=(0,T.fileURLToPath)(m),E=(0,S.dirname)(P),k=A.default.env.INIT_CWD||A.default.cwd();var I=g(require("boxen"),1),j=g(require("chalk"),1),C=require("child_process"),x=g(require("process"),1),N=g(require("util"),1);var G=g(require("node-persist"),1),F=g(require("os"),1),H=g(require("path"),1),L=g(require("process"),1),M=L.default.env.CYBERSKILL_STORAGE_DIR||H.default.join(F.default.homedir(),".cyberskill-storage");function R(){return K.apply(this,arguments)}function K(){K=t(function(){var e;return o(this,function(t){switch(t.label){case 0:e=G.default.defaultInstance;if(e)return[3,2];return[4,G.default.init({dir:M,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return K.apply(this,arguments)}var q={get:function e(e){return t(function(){var t,n;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,R()];case 1:r.sent();return[4,G.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,n){return t(function(){var t;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,R()];case 1:r.sent();return[4,G.default.setItem(e,n)];case 2:r.sent();return[3,4];case 3:t=r.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},remove:function e(e){return t(function(){var t;return o(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,R()];case 1:n.sent();return[4,G.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return t(function(){var e,t;return o(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,R()];case 1:n.sent();return[4,G.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return t(function(){return o(this,function(t){try{return[2,"".concat(M," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var D=x.default.env.DEBUG==="true",U=N.promisify(C.exec),J=j.default,B=J.gray,W=J.blue,Y=function(){return B("[".concat(new Date().toLocaleTimeString(),"]"))};function $(e){var t=j.default[e];return typeof t=="function"?t:j.default.green}function z(e,t,n,r){var s=$(t);console.log("".concat(Y()," ").concat(s("".concat(n," ").concat(e))," ").concat(r))}function Q(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.color,s=r===void 0?"green":r,i=n.padding,c=i===void 0?1:i,o=n.margin,a=o===void 0?1:o,u=n.borderStyle,l=u===void 0?"round":u,f=n.titleColor,p=f===void 0?"bold":f;var d=$(s),h=$(p);if(typeof t=="string"){console.log((0,I.default)(h(d("".concat(e,"\n").concat(t))),{padding:c,margin:a,borderStyle:l,borderColor:s}));return}Array.isArray(t)&&t.length&&(t.forEach(function(e){var t=e.file,n=e.position,r=e.rule,s=e.message;console.log("".concat(Y()," ").concat(d("File:")," ").concat(W("".concat(t).concat(n?":".concat(n):"")))),r&&console.log(" ".concat(d("Rule:")," ").concat(d(r))),console.log(" ".concat(d("Message:")," ").concat(d(s)))}),console.log((0,I.default)(h(d("".concat(e,": ").concat(t.length))),{padding:c,margin:a,borderStyle:l,borderColor:s})),console.log(B("─".repeat(40))))}var V={success:function(e){return z("SUCCESS","green","✔",e)},error:function(e){return z("ERROR","red","✖",e)},warning:function(e){return z("WARNING","yellow","⚠",e)},info:function(e){return z("INFO","blue","ℹ",e)},printBoxedLog:Q},X=function(e){return"error_list:".concat(e)};function Z(e){return ee.apply(this,arguments)}function ee(){ee=t(function(e){var n,r,s;return o(this,function(i){switch(i.label){case 0:if(e.length===0)return[2];n=Date.now(),r=X(n);i.label=1;case 1:i.trys.push([1,3,,4]);return[4,q.set(r,{errors:e,timestamp:n})];case 2:i.sent(),setTimeout(/*#__PURE__*/t(function(){var e;return o(this,function(t){switch(t.label){case 0:return[4,q.getLogLink(r)];case 1:e=t.sent();e&&V.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:s=i.sent();V.error("Failed to save errors: ".concat(s.message));return[3,4];case 4:return[2]}})});return ee.apply(this,arguments)}function et(){return en.apply(this,arguments)}function en(){en=t(function(){var e,n,r;return o(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,q.keys()];case 1:e=s.sent(),n=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(n.map(/*#__PURE__*/function(){var e=t(function(e){var t;return o(this,function(n){switch(n.label){case 0:return[4,q.get(e)];case 1:return[2,((t=n.sent())===null||t===void 0?void 0:t.errors)||[]]}})});return function(t){return e.apply(this,arguments)}}()))];case 2:return[2,s.sent().flat()];case 3:r=s.sent();return[2,(V.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return en.apply(this,arguments)}function er(){return es.apply(this,arguments)}function es(){es=t(function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,q.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return q.remove(e)}))];case 2:r.sent();return[3,4];case 3:n=r.sent();V.error("Failed to clear error lists: ".concat(n.message));return[3,4];case 4:return[2]}})});return es.apply(this,arguments)}function ei(e){var t=[],n=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,i=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var o=s.exec(e)||[],a=i.exec(e)||[],u=c.exec(e)||[];o.length&&r?t.push({file:r,position:"".concat(o[1],":").concat(o[2]),type:o[3]==="error"?"error":"warning",message:o[4].trim(),rule:o[5].trim()}):a.length?t.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4]==="error"?"error":"warning",message:a[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):n.push(e.trim())}}),t.length&&Z(t),n.length&&D&&(V.warning("Unmatched lines:"),n.forEach(function(e){return console.log(" ".concat(e))}))}function ec(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,i=e.column,c=e.ruleId,o=e.message;n.push({type:r===2?"error":"warning",file:t,position:"".concat(s,":").concat(i),rule:c,message:o})})}),n.length&&Z(n)}catch(t){ei(e)}}function eo(e){return ea.apply(this,arguments)}function ea(){ea=t(function(e){var t,n,r,s,i,c,a,u,l;var f=arguments;return o(this,function(o){switch(o.label){case 0:t=f.length>1&&f[1]!==void 0?f[1]:ec;n=new AbortController;x.default.on("SIGINT",function(){V.warning("Process interrupted. Terminating..."),n.abort(),x.default.exit()});o.label=1;case 1:o.trys.push([1,3,,4]);return[4,U(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=o.sent(),s=r.stdout,i=r.stderr;[s,i].forEach(function(e){return e&&t(e)});return[3,4];case 3:c=o.sent();a=c.stdout,u=c.stderr,l=c.message;[a,u].forEach(function(e){return e&&t(e)}),!u&&!a&&V.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return ea.apply(this,arguments)}var eu=g(require("fs"),1),el=function(e){return eu.existsSync(e)};var ef=g(require("node-fetch"),1),ep=g(require("fs"),1),ed=g(require("path"),1);var eh=24*60*60*1e3;function eg(e){return e?ed.default.join(k,"node_modules",e,"package.json"):ed.default.join(k,"package.json")}function ey(e){return em.apply(this,arguments)}function em(){em=t(function(e){var t,n,r,s,i,c,a,u,l,f;var p=arguments;return o(this,function(o){switch(o.label){case 0:t=p.length>1&&p[1]!==void 0?p[1]:!1;n="npm_version:".concat(e),r="npm_metadata:".concat(e);return[4,q.get(n)];case 1:s=o.sent();return[4,q.get(r)];case 2:i=o.sent(),c=s&&Date.now()-s.timestamp<eh;if(!t&&c)return[2,s.version];a={};(i===null||i===void 0?void 0:i.etag)&&(a["If-None-Match"]=i.etag),(i===null||i===void 0?void 0:i.lastModified)&&(a["If-Modified-Since"]=i.lastModified);o.label=3;case 3:o.trys.push([3,8,,9]);return[4,(0,ef.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:a})];case 4:u=o.sent();if(u.status===304&&s)return[2,s.version];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=o.sent().version;return[4,q.set(n,{version:l,timestamp:Date.now()})];case 6:o.sent();return[4,q.set(r,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(o.sent(),l)];case 8:f=o.sent();if(V.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),s)return[2,(V.warning("Falling back to cached version for ".concat(e,": ").concat(s.version)),s.version)];throw f;case 9:return[2]}})});return em.apply(this,arguments)}function ev(e){return eb.apply(this,arguments)}function eb(){eb=t(function(e){var t,n,r,s,i;var c=arguments;return o(this,function(o){switch(o.label){case 0:t=c.length>1&&c[1]!==void 0?c[1]:!0;o.label=1;case 1:o.trys.push([1,3,,4]);n=eg(e);if(!ep.default.existsSync(n))return[2,(V.info("".concat(e," is not installed.")),!0)];r=JSON.parse(ep.default.readFileSync(n,"utf-8")).version;return[4,ey(e,t)];case 2:s=o.sent();return[2,(V.info("Installed version of ".concat(e,": ").concat(r)),V.info("Latest version of ".concat(e,": ").concat(s)),r!==s)];case 3:i=o.sent();return[2,(V.warning("Failed to check version for ".concat(e,": ").concat(i.message)),!0)];case 4:return[2]}})});return eb.apply(this,arguments)}function ew(e){return eO.apply(this,arguments)}function eO(){eO=t(function(e){var t,s,c,a;return o(this,function(o){switch(o.label){case 0:o.trys.push([0,4,,5]);return[4,ey(e,!0)];case 1:t=o.sent(),s=eg();if(!ep.default.existsSync(s)){V.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(ep.default.readFileSync(s,"utf-8"));c.dependencies=i(r({},c.dependencies),n({},e,t)),ep.default.writeFileSync(s,JSON.stringify(c,null,2)),V.info("Updated ".concat(e," to version ").concat(t));return[4,eS()];case 2:o.sent();return[4,eo("pnpm run lint:fix")];case 3:o.sent(),V.success("".concat(e," updated successfully."));return[3,5];case 4:a=o.sent();throw V.error("Failed to update ".concat(e,": ").concat(a.message)),a;case 5:return[2]}})});return eO.apply(this,arguments)}function e_(e,t){try{var n=ed.default.join(e,"package.json");return ep.default.existsSync(n)?JSON.parse(ep.default.readFileSync(n,"utf-8")).name===t:!1}catch(e){return V.error("Error reading package.json: ".concat(e.message)),!1}}function eS(){return eA.apply(this,arguments)}function eA(){eA=t(function(){var e,t,n,r,s,i,c,a,u,l,f;return o(this,function(o){switch(o.label){case 0:e=[{command:"pnpm install",message:"Standard installation"},{command:"pnpm install --legacy-peer-deps",message:"Attempting installation with --legacy-peer-deps"},{command:"pnpm install --force",message:"Attempting forced installation"}];t=true,n=false,r=undefined;o.label=1;case 1:o.trys.push([1,8,9,10]);s=e[Symbol.iterator]();o.label=2;case 2:if(!!(t=(i=s.next()).done))return[3,7];c=i.value,a=c.command,u=c.message;o.label=3;case 3:o.trys.push([3,5,,6]);V.info("".concat(u,"..."));return[4,eo(a)];case 4:o.sent(),V.success("Dependencies installed using: ".concat(a));return[2];case 5:l=o.sent();V.warning("Failed with: ".concat(a)),V.error("Error: ".concat(l.message));return[3,6];case 6:t=true;return[3,2];case 7:return[3,10];case 8:f=o.sent();n=true;r=f;return[3,10];case 9:try{if(!t&&s.return!=null){s.return()}}finally{if(n){throw r}}return[7];case 10:throw new Error("Failed to install dependencies after multiple attempts.")}})});return eA.apply(this,arguments)}var eT={TS_CONFIG_PATH:b.resolve(k,"tsconfig.json"),HUSKY_PATH:b.resolve(k,".husky"),GIT_HOOK_PATH:b.resolve(k,".git/hooks"),GIT_COMMIT_MSG:b.resolve(k,".git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:b.resolve(k,".simple-git-hooks.json"),PACKAGE_JSON_PATH:b.resolve(k,"package.json"),PACKAGE_LOCK_PATH:b.resolve(k,"pnpm-lock.yaml"),PACKAGE_NAME:"@cyberskill/shared",LINT_STAGED_CONFIG_PATH:b.resolve(E,"./configs/lint-staged/base.js"),COMMITLINT_CONFIG_PATH:b.resolve(E,"./configs/commitlint/base.js"),UNIT_TEST_CONFIG_PATH:b.resolve(E,"./configs/vitest/react/unit.js"),E2E_TEST_CONFIG_PATH:b.resolve(E,"./configs/vitest/react/e2e.js"),HOOKS_CONFIG:{postinstall:"pnpm exec cyberskill setup","pre-commit":"pnpm exec cyberskill lint-staged","commit-msg":"pnpm exec cyberskill commitlint"},HOOKS_CONFIG_LOCAL:{postinstall:"pnpm exec tsx src/cli.ts setup","pre-commit":"pnpm exec tsx src/cli.ts lint-staged","commit-msg":"pnpm exec tsx src/cli.ts commitlint","pre-push":"git pull"}};function eP(e,t){return eE.apply(this,arguments)}function eE(){eE=t(function(e,t){return o(this,function(n){switch(n.label){case 0:V.info("".concat(e,"..."));return[4,eo(t)];case 1:n.sent(),V.success("".concat(e," completed."));return[2]}})});return eE.apply(this,arguments)}function ek(){return eI.apply(this,arguments)}function eI(){eI=t(function(){var e;return o(this,function(t){switch(t.label){case 0:if(!el(eT.TS_CONFIG_PATH))return[3,2];return[4,eP("Running TypeScript check","pnpm exec tsc -p ".concat(eT.TS_CONFIG_PATH," --noEmit"))];case 1:e=t.sent();return[3,3];case 2:e=V.warning("TypeScript config not found. Skipping TypeScript check.");t.label=3;case 3:e;return[2]}})});return eI.apply(this,arguments)}function ej(){return eC.apply(this,arguments)}function eC(){eC=t(function(){var e;var t=arguments;return o(this,function(n){switch(n.label){case 0:e=t.length>0&&t[0]!==void 0?t[0]:!1;return[4,eP("Running ESLint ".concat(e?"(with fix)":"(without fix)"),"pnpm exec eslint ".concat(k).concat(e?" --fix":""))];case 1:n.sent();return[2]}})});return eC.apply(this,arguments)}function ex(){return eN.apply(this,arguments)}function eN(){eN=t(function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:return[4,et()];case 1:e=r.sent(),t=e.filter(function(e){return e.type==="error"}),n=e.filter(function(e){return e.type==="warning"});!t.length&&!n.length?V.printBoxedLog("✔ NO ISSUES FOUND","",{color:"green"}):(V.printBoxedLog("⚠ Warnings",n,{color:"yellow"}),V.printBoxedLog("✖ Errors",t,{color:"red"}));return[2]}})});return eN.apply(this,arguments)}function eG(){return eF.apply(this,arguments)}function eF(){eF=t(function(){var e;return o(this,function(t){switch(t.label){case 0:if(!e_(k,eT.PACKAGE_NAME))return[3,5];t.label=1;case 1:t.trys.push([1,4,,5]);return[4,eP("Building @cyberskill/shared","pnpm run build")];case 2:t.sent();return[4,eo("git add dist")];case 3:t.sent(),V.success("Built and staged @cyberskill/shared");return[3,5];case 4:e=t.sent();throw V.error("Failed to build and stage @cyberskill/shared: ".concat(e.message)),e;case 5:return[4,eP("Running lint-staged","pnpm exec lint-staged --config ".concat(eT.LINT_STAGED_CONFIG_PATH))];case 6:t.sent(),ex();return[2]}})});return eF.apply(this,arguments)}function eH(){return eL.apply(this,arguments)}function eL(){eL=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Inspecting ESLint rules","pnpm exec @eslint/config-inspector")];case 1:e.sent();return[2]}})});return eL.apply(this,arguments)}function eM(){return eR.apply(this,arguments)}function eR(){eR=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,er()];case 1:e.sent();return[4,Promise.all([ek(),ej()])];case 2:e.sent(),ex();return[2]}})});return eR.apply(this,arguments)}function eK(){return eq.apply(this,arguments)}function eq(){eq=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,er()];case 1:e.sent();return[4,Promise.all([ek(),ej(!0)])];case 2:e.sent(),ex();return[2]}})});return eq.apply(this,arguments)}function eD(){return eU.apply(this,arguments)}function eU(){eU=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Running commit lint","pnpm exec commitlint --edit ".concat(eT.GIT_COMMIT_MSG," --config ").concat(eT.COMMITLINT_CONFIG_PATH))];case 1:e.sent(),ex();return[2]}})});return eU.apply(this,arguments)}function eJ(){return eB.apply(this,arguments)}function eB(){eB=t(function(){var e,t,n,r,s,i;return o(this,function(c){switch(c.label){case 0:if(V.info("Starting project setup..."),!el(eT.PACKAGE_JSON_PATH)){V.error("package.json not found. Aborting setup.");return[2]}c.label=1;case 1:c.trys.push([1,9,,10]);t=JSON.parse(v.readFileSync(eT.PACKAGE_JSON_PATH,"utf-8"));r=e_(k,eT.PACKAGE_NAME);if(r)return[3,4];s=(e=t.dependencies)===null||e===void 0?void 0:e[eT.PACKAGE_NAME];if(!s)return[3,3];return[4,ev(eT.PACKAGE_NAME)];case 2:s=!c.sent();c.label=3;case 3:r=s;c.label=4;case 4:if(!r)return[3,5];n=V.success("Cyberskill package is already up to date.");return[3,7];case 5:V.info("\uD83D\uDCE6 Updating Cyberskill package...");return[4,ew(eT.PACKAGE_NAME)];case 6:n=(c.sent(),V.success("Cyberskill package updated successfully."));c.label=7;case 7:n;return[4,eW()];case 8:c.sent(),V.success("Project setup completed.");return[3,10];case 9:i=c.sent();throw V.error("Failed to setup project: ".concat(i.message)),i;case 10:return[2]}})});return eB.apply(this,arguments)}function eW(){return eY.apply(this,arguments)}function eY(){eY=t(function(){var e,t,n;return o(this,function(r){switch(r.label){case 0:V.info("Setting up Git hooks...");e=el(eT.HUSKY_PATH);if(!e)return[3,3];return[4,eo("pnpm exec rimraf ".concat(eT.HUSKY_PATH," ").concat(eT.GIT_HOOK_PATH))];case 1:r.sent();return[4,eo("git config core.hooksPath ".concat(eT.GIT_HOOK_PATH))];case 2:e=r.sent();r.label=3;case 3:e;t=e_(k,eT.PACKAGE_NAME);v.writeFileSync(eT.SIMPLE_GIT_HOOKS_PATH,JSON.stringify(t?eT.HOOKS_CONFIG_LOCAL:eT.HOOKS_CONFIG,null,4));n=b.resolve(".gitignore");el(n)?v.readFileSync(n,"utf8").split("\n").includes(".simple-git-hooks.json")?V.info(".simple-git-hooks.json is already ignored in .gitignore"):(v.appendFileSync(n,"\n# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),V.info("Added .simple-git-hooks.json to .gitignore")):(v.writeFileSync(n,"# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),V.info("Created .gitignore and added .simple-git-hooks.json"));return[4,eo("pnpm exec simple-git-hooks")];case 4:r.sent(),V.success("Git hooks configured successfully.");return[2]}})});return eY.apply(this,arguments)}function e$(){return ez.apply(this,arguments)}function ez(){ez=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Resetting project","pnpm exec rimraf ".concat(k,"/node_modules ").concat(eT.PACKAGE_LOCK_PATH))];case 1:e.sent();return[4,eS()];case 2:e.sent();return[4,eW()];case 3:e.sent();return[2]}})});return ez.apply(this,arguments)}function eQ(){return eV.apply(this,arguments)}function eV(){eV=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Inspecting project dependencies","pnpm exec node-modules-inspector")];case 1:e.sent();return[2]}})});return eV.apply(this,arguments)}function eX(){return eZ.apply(this,arguments)}function eZ(){eZ=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Running unit tests","pnpm exec vitest --config ".concat(eT.UNIT_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eZ.apply(this,arguments)}function e0(){return e1.apply(this,arguments)}function e1(){e1=t(function(){return o(this,function(e){switch(e.label){case 0:return[4,eP("Running E2E tests","pnpm exec vitest --config ".concat(eT.E2E_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return e1.apply(this,arguments)}(0,_.default)((0,O.hideBin)(w.default.argv)).command("lint","Run linting checks",eM).command("lint:fix","Fix linting issues",eK).command("lint:inspect","Inspect linting rules",eH).command("lint-staged","Run lint-staged",eG).command("commitlint","Run commitlint",eD).command("setup","Run project setup",eJ).command("reset","Reset project dependencies",e$).command("inspect","Inspect project dependencies",eQ).command("test:unit","Run unit tests",eX).command("test:e2e","Run e2e tests",e0).help().parse();
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function e(e,n,t,r,s,o,i){try{var c=e[o](i);var a=c.value}catch(e){t(e);return}if(c.done){n(a)}else{Promise.resolve(a).then(r,s)}}function n(n){return function(){var t=this,r=arguments;return new Promise(function(s,o){var i=n.apply(t,r);function c(n){e(i,s,o,c,a,"next",n)}function a(n){e(i,s,o,c,a,"throw",n)}c(undefined)})}}function t(e,n,t){if(n in e){Object.defineProperty(e,n,{value:t,enumerable:true,configurable:true,writable:true})}else{e[n]=t}return e}function r(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};var s=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){s=s.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}s.forEach(function(n){t(e,n,r[n])})}return e}function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(n){r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})}t.push.apply(t,r)}return t}function o(e,n){n=n!=null?n:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(n))}else{s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i(e,n){var t,r,s,o,i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return o={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(e){return function(n){return a([e,n])}}function a(o){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,r&&(s=o[0]&2?r["return"]:o[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;if(r=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;r=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(o[0]===6&&i.label<s[1]){i.label=s[1];s=o;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(o);break}if(s[2])i.ops.pop();i.trys.pop();continue}o=n.call(e,i)}catch(e){o=[6,e];r=0}finally{t=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}import*as c from"node:fs";import*as a from"node:path";import u from"node:process";import{hideBin as l}from"yargs/helpers";import f from"yargs/yargs";import{dirname as p}from"node:path";import h from"node:process";import{fileURLToPath as g}from"node:url";var d=g(import.meta.url),m=p(d),y=h.env.INIT_CWD||h.cwd();import v from"boxen";import b from"chalk";import{exec as w}from"node:child_process";import S from"node:process";import*as _ from"node:util";import O from"node-persist";import T from"node:os";import A from"node:path";import k from"node:process";var E=k.env.CYBERSKILL_STORAGE_DIR||A.join(T.homedir(),".cyberskill-storage");function P(){return I.apply(this,arguments)}function I(){I=n(function(){var e;return i(this,function(n){switch(n.label){case 0:e=O.defaultInstance;if(e)return[3,2];return[4,O.init({dir:E,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=n.sent();n.label=2;case 2:e;return[2]}})});return I.apply(this,arguments)}var j={get:function e(e){return n(function(){var n,t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,P()];case 1:r.sent();return[4,O.getItem(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:null];case 3:t=r.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return n(function(){var n;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,P()];case 1:r.sent();return[4,O.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return n(function(){var n;return i(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,O.removeItem(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},keys:function e(){return n(function(){var e,n;return i(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,O.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:n=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",n),[])];case 4:return[2]}})})()},getLogLink:function e(e){return n(function(){return i(this,function(n){try{return[2,"".concat(E," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var C=S.env.DEBUG==="true",N=_.promisify(w),G=b.gray,x=b.blue,F=function(){return G("[".concat(new Date().toLocaleTimeString(),"]"))};function H(e){var n=b[e];return typeof n=="function"?n:b.green}function M(e,n,t,r){var s=H(n);console.log("".concat(F()," ").concat(s("".concat(t," ").concat(e))," ").concat(r))}function L(e,n){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=t.color,s=r===void 0?"green":r,o=t.padding,i=o===void 0?1:o,c=t.margin,a=c===void 0?1:c,u=t.borderStyle,l=u===void 0?"round":u,f=t.titleColor,p=f===void 0?"bold":f;var h=H(s),g=H(p);if(typeof n=="string"){console.log(v(g(h("".concat(e,"\n").concat(n))),{padding:i,margin:a,borderStyle:l,borderColor:s}));return}Array.isArray(n)&&n.length&&(n.forEach(function(e){var n=e.file,t=e.position,r=e.rule,s=e.message;console.log("".concat(F()," ").concat(h("File:")," ").concat(x("".concat(n).concat(t?":".concat(t):"")))),r&&console.log(" ".concat(h("Rule:")," ").concat(h(r))),console.log(" ".concat(h("Message:")," ").concat(h(s)))}),console.log(v(g(h("".concat(e,": ").concat(n.length))),{padding:i,margin:a,borderStyle:l,borderColor:s})),console.log(G("─".repeat(40))))}var R={success:function(e){return M("SUCCESS","green","✔",e)},error:function(e){return M("ERROR","red","✖",e)},warning:function(e){return M("WARNING","yellow","⚠",e)},info:function(e){return M("INFO","blue","ℹ",e)},printBoxedLog:L},K=function(e){return"error_list:".concat(e)};function D(e){return U.apply(this,arguments)}function U(){U=n(function(e){var t,r,s;return i(this,function(o){switch(o.label){case 0:if(e.length===0)return[2];t=Date.now(),r=K(t);o.label=1;case 1:o.trys.push([1,3,,4]);return[4,j.set(r,{errors:e,timestamp:t})];case 2:o.sent(),setTimeout(/*#__PURE__*/n(function(){var e;return i(this,function(n){switch(n.label){case 0:return[4,j.getLogLink(r)];case 1:e=n.sent();e&&R.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:s=o.sent();R.error("Failed to save errors: ".concat(s.message));return[3,4];case 4:return[2]}})});return U.apply(this,arguments)}function J(){return B.apply(this,arguments)}function B(){B=n(function(){var e,t,r;return i(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,j.keys()];case 1:e=s.sent(),t=Array.isArray(e)?e.filter(function(e){var n;return e===null||e===void 0?void 0:(n=e.startsWith)===null||n===void 0?void 0:n.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=n(function(e){var n;return i(this,function(t){switch(t.label){case 0:return[4,j.get(e)];case 1:return[2,((n=t.sent())===null||n===void 0?void 0:n.errors)||[]]}})});return function(n){return e.apply(this,arguments)}}()))];case 2:return[2,s.sent().flat()];case 3:r=s.sent();return[2,(R.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return B.apply(this,arguments)}function W(){return Y.apply(this,arguments)}function Y(){Y=n(function(){var e,n,t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,j.keys()];case 1:e=r.sent(),n=Array.isArray(e)?e.filter(function(e){var n;return e===null||e===void 0?void 0:(n=e.startsWith)===null||n===void 0?void 0:n.call(e,"error_list:")}):[];return[4,Promise.all(n.map(function(e){return j.remove(e)}))];case 2:r.sent();return[3,4];case 3:t=r.sent();R.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return Y.apply(this,arguments)}function $(e){var n=[],t=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var c=s.exec(e)||[],a=o.exec(e)||[],u=i.exec(e)||[];c.length&&r?n.push({file:r,position:"".concat(c[1],":").concat(c[2]),type:c[3]==="error"?"error":"warning",message:c[4].trim(),rule:c[5].trim()}):a.length?n.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4]==="error"?"error":"warning",message:a[5].trim()}):u.length?n.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),n.length&&D(n),t.length&&C&&(R.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function q(e){try{var n=JSON.parse(e),t=[];n.forEach(function(e){var n=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,o=e.column,i=e.ruleId,c=e.message;t.push({type:r===2?"error":"warning",file:n,position:"".concat(s,":").concat(o),rule:i,message:c})})}),t.length&&D(t)}catch(n){$(e)}}function z(e){return Q.apply(this,arguments)}function Q(){Q=n(function(e){var n,t,r,s,o,c,a,u,l;var f=arguments;return i(this,function(i){switch(i.label){case 0:n=f.length>1&&f[1]!==void 0?f[1]:q;t=new AbortController;S.on("SIGINT",function(){R.warning("Process interrupted. Terminating..."),t.abort(),S.exit()});i.label=1;case 1:i.trys.push([1,3,,4]);return[4,N(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:r=i.sent(),s=r.stdout,o=r.stderr;[s,o].forEach(function(e){return e&&n(e)});return[3,4];case 3:c=i.sent();a=c.stdout,u=c.stderr,l=c.message;[a,u].forEach(function(e){return e&&n(e)}),!u&&!a&&R.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return Q.apply(this,arguments)}import*as V from"node:fs";var X=function(e){return V.existsSync(e)};import Z from"node-fetch";import ee from"node:fs";import en from"node:path";var et=24*60*60*1e3;function er(e){return e?en.join(y,"node_modules",e,"package.json"):en.join(y,"package.json")}function es(e){return eo.apply(this,arguments)}function eo(){eo=n(function(e){var n,t,r,s,o,c,a,u,l,f;var p=arguments;return i(this,function(i){switch(i.label){case 0:n=p.length>1&&p[1]!==void 0?p[1]:!1;t="npm_version:".concat(e),r="npm_metadata:".concat(e);return[4,j.get(t)];case 1:s=i.sent();return[4,j.get(r)];case 2:o=i.sent(),c=s&&Date.now()-s.timestamp<et;if(!n&&c)return[2,s.version];a={};(o===null||o===void 0?void 0:o.etag)&&(a["If-None-Match"]=o.etag),(o===null||o===void 0?void 0:o.lastModified)&&(a["If-Modified-Since"]=o.lastModified);i.label=3;case 3:i.trys.push([3,8,,9]);return[4,Z("https://registry.npmjs.org/".concat(e,"/latest"),{headers:a})];case 4:u=i.sent();if(u.status===304&&s)return[2,s.version];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=i.sent().version;return[4,j.set(t,{version:l,timestamp:Date.now()})];case 6:i.sent();return[4,j.set(r,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(i.sent(),l)];case 8:f=i.sent();if(R.error("Error fetching latest version for ".concat(e,": ").concat(f.message)),s)return[2,(R.warning("Falling back to cached version for ".concat(e,": ").concat(s.version)),s.version)];throw f;case 9:return[2]}})});return eo.apply(this,arguments)}function ei(e){return ec.apply(this,arguments)}function ec(){ec=n(function(e){var n,t,r,s,o;var c=arguments;return i(this,function(i){switch(i.label){case 0:n=c.length>1&&c[1]!==void 0?c[1]:!0;i.label=1;case 1:i.trys.push([1,3,,4]);t=er(e);if(!ee.existsSync(t))return[2,(R.info("".concat(e," is not installed.")),!0)];r=JSON.parse(ee.readFileSync(t,"utf-8")).version;return[4,es(e,n)];case 2:s=i.sent();return[2,(R.info("Installed version of ".concat(e,": ").concat(r)),R.info("Latest version of ".concat(e,": ").concat(s)),r!==s)];case 3:o=i.sent();return[2,(R.warning("Failed to check version for ".concat(e,": ").concat(o.message)),!0)];case 4:return[2]}})});return ec.apply(this,arguments)}function ea(e){return eu.apply(this,arguments)}function eu(){eu=n(function(e){var n,s,c,a;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,4,,5]);return[4,es(e,!0)];case 1:n=i.sent(),s=er();if(!ee.existsSync(s)){R.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(ee.readFileSync(s,"utf-8"));c.dependencies=o(r({},c.dependencies),t({},e,n)),ee.writeFileSync(s,JSON.stringify(c,null,2)),R.info("Updated ".concat(e," to version ").concat(n));return[4,z("npm i -f")];case 2:i.sent();return[4,z("npm run lint:fix")];case 3:i.sent(),R.success("".concat(e," updated successfully."));return[3,5];case 4:a=i.sent();throw R.error("Failed to update ".concat(e,": ").concat(a.message)),a;case 5:return[2]}})});return eu.apply(this,arguments)}function el(e,n){try{var t=en.join(e,"package.json");return ee.existsSync(t)?JSON.parse(ee.readFileSync(t,"utf-8")).name===n:!1}catch(e){return R.error("Error reading package.json: ".concat(e.message)),!1}}var ef={TS_CONFIG_PATH:a.resolve(y,"tsconfig.json"),HUSKY_PATH:a.resolve(y,".husky"),GIT_HOOK_PATH:a.resolve(y,".git/hooks"),GIT_COMMIT_MSG:a.resolve(y,".git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:a.resolve(y,".simple-git-hooks.json"),PACKAGE_JSON_PATH:a.resolve(y,"package.json"),PACKAGE_LOCK_PATH:a.resolve(y,"package-lock.json"),PACKAGE_NAME:"@cyberskill/shared",LINT_STAGED_CONFIG_PATH:a.resolve(m,"./configs/lint-staged/base.js"),COMMITLINT_CONFIG_PATH:a.resolve(m,"./configs/commitlint/base.js"),UNIT_TEST_CONFIG_PATH:a.resolve(m,"./configs/vitest/react/unit.js"),E2E_TEST_CONFIG_PATH:a.resolve(m,"./configs/vitest/react/e2e.js"),HOOKS_CONFIG:{"pre-commit":"npx --yes cyberskill lint-staged","commit-msg":"npx --yes cyberskill commitlint"}};function ep(e,n){return eh.apply(this,arguments)}function eh(){eh=n(function(e,n){return i(this,function(t){switch(t.label){case 0:R.info("".concat(e,"..."));return[4,z(n)];case 1:t.sent(),R.success("".concat(e," completed."));return[2]}})});return eh.apply(this,arguments)}function eg(){return ed.apply(this,arguments)}function ed(){ed=n(function(){var e;return i(this,function(n){switch(n.label){case 0:if(!X(ef.TS_CONFIG_PATH))return[3,2];return[4,ep("Running TypeScript check","npx tsc -p ".concat(ef.TS_CONFIG_PATH," --noEmit"))];case 1:e=n.sent();return[3,3];case 2:e=R.warning("TypeScript config not found. Skipping TypeScript check.");n.label=3;case 3:e;return[2]}})});return ed.apply(this,arguments)}function em(){return ey.apply(this,arguments)}function ey(){ey=n(function(){var e;var n=arguments;return i(this,function(t){switch(t.label){case 0:e=n.length>0&&n[0]!==void 0?n[0]:!1;return[4,ep("Running ESLint ".concat(e?"(with fix)":"(without fix)"),"npx eslint ".concat(y).concat(e?" --fix":""))];case 1:t.sent();return[2]}})});return ey.apply(this,arguments)}function ev(){return eb.apply(this,arguments)}function eb(){eb=n(function(){var e,n,t;return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:e=r.sent(),n=e.filter(function(e){return e.type==="error"}),t=e.filter(function(e){return e.type==="warning"});!n.length&&!t.length?R.printBoxedLog("✔ NO ISSUES FOUND","",{color:"green"}):(R.printBoxedLog("⚠ Warnings",t,{color:"yellow"}),R.printBoxedLog("✖ Errors",n,{color:"red"}));return[2]}})});return eb.apply(this,arguments)}function ew(){return eS.apply(this,arguments)}function eS(){eS=n(function(){var e;return i(this,function(n){switch(n.label){case 0:if(!el(y,ef.PACKAGE_NAME))return[3,5];n.label=1;case 1:n.trys.push([1,4,,5]);return[4,ep("Building @cyberskill/shared","npm run build")];case 2:n.sent();return[4,z("git add dist")];case 3:n.sent(),R.success("Built and staged @cyberskill/shared");return[3,5];case 4:e=n.sent();throw R.error("Failed to build and stage @cyberskill/shared: ".concat(e.message)),e;case 5:return[4,ep("Running lint-staged","npx lint-staged --config ".concat(ef.LINT_STAGED_CONFIG_PATH))];case 6:n.sent(),ev();return[2]}})});return eS.apply(this,arguments)}function e_(){return eO.apply(this,arguments)}function eO(){eO=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Inspecting ESLint rules","npx @eslint/config-inspector")];case 1:e.sent();return[2]}})});return eO.apply(this,arguments)}function eT(){return eA.apply(this,arguments)}function eA(){eA=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,W()];case 1:e.sent();return[4,Promise.all([eg(),em()])];case 2:e.sent(),ev();return[2]}})});return eA.apply(this,arguments)}function ek(){return eE.apply(this,arguments)}function eE(){eE=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,W()];case 1:e.sent();return[4,Promise.all([eg(),em(!0)])];case 2:e.sent(),ev();return[2]}})});return eE.apply(this,arguments)}function eP(){return eI.apply(this,arguments)}function eI(){eI=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Running commit lint","npx commitlint --edit ".concat(ef.GIT_COMMIT_MSG," --config ").concat(ef.COMMITLINT_CONFIG_PATH))];case 1:e.sent(),ev();return[2]}})});return eI.apply(this,arguments)}function ej(){return eC.apply(this,arguments)}function eC(){eC=n(function(){var e,n,t,r,s,o;return i(this,function(i){switch(i.label){case 0:if(R.info("Starting project setup..."),!X(ef.PACKAGE_JSON_PATH)){R.error("package.json not found. Aborting setup.");return[2]}i.label=1;case 1:i.trys.push([1,9,,10]);n=JSON.parse(c.readFileSync(ef.PACKAGE_JSON_PATH,"utf-8"));r=el(y,ef.PACKAGE_NAME);if(r)return[3,4];s=(e=n.dependencies)===null||e===void 0?void 0:e[ef.PACKAGE_NAME];if(!s)return[3,3];return[4,ei(ef.PACKAGE_NAME)];case 2:s=!i.sent();i.label=3;case 3:r=s;i.label=4;case 4:if(!r)return[3,5];t=R.success("Cyberskill package is already up to date.");return[3,7];case 5:R.info("\uD83D\uDCE6 Updating Cyberskill package...");return[4,ea(ef.PACKAGE_NAME)];case 6:t=(i.sent(),R.success("Cyberskill package updated successfully."));i.label=7;case 7:t;return[4,eN()];case 8:i.sent(),R.success("Project setup completed.");return[3,10];case 9:o=i.sent();throw R.error("Failed to setup project: ".concat(o.message)),o;case 10:return[2]}})});return eC.apply(this,arguments)}function eN(){return eG.apply(this,arguments)}function eG(){eG=n(function(){var e,n;return i(this,function(t){switch(t.label){case 0:R.info("Setting up Git hooks...");e=X(ef.HUSKY_PATH);if(!e)return[3,3];return[4,z("npx rimraf ".concat(ef.HUSKY_PATH," ").concat(ef.GIT_HOOK_PATH))];case 1:t.sent();return[4,z("git config core.hooksPath ".concat(ef.GIT_HOOK_PATH))];case 2:e=t.sent();t.label=3;case 3:e,c.writeFileSync(ef.SIMPLE_GIT_HOOKS_PATH,JSON.stringify(ef.HOOKS_CONFIG,null,4));n=a.resolve(".gitignore");X(n)?c.readFileSync(n,"utf8").split("\n").includes(".simple-git-hooks.json")?R.info(".simple-git-hooks.json is already ignored in .gitignore"):(c.appendFileSync(n,"\n# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),R.info("Added .simple-git-hooks.json to .gitignore")):(c.writeFileSync(n,"# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),R.info("Created .gitignore and added .simple-git-hooks.json"));return[4,z("npx simple-git-hooks")];case 4:t.sent(),R.success("Git hooks configured successfully.");return[2]}})});return eG.apply(this,arguments)}function ex(){return eF.apply(this,arguments)}function eF(){eF=n(function(){var e,n,t,r,s,o,c,a,u,l,f;return i(this,function(i){switch(i.label){case 0:e=[{command:"npm install",message:"Standard installation"},{command:"npm install --legacy-peer-deps",message:"Attempting installation with --legacy-peer-deps"},{command:"npm install --force",message:"Attempting forced installation"}];n=true,t=false,r=undefined;i.label=1;case 1:i.trys.push([1,8,9,10]);s=e[Symbol.iterator]();i.label=2;case 2:if(!!(n=(o=s.next()).done))return[3,7];c=o.value,a=c.command,u=c.message;i.label=3;case 3:i.trys.push([3,5,,6]);R.info("".concat(u,"..."));return[4,z(a)];case 4:i.sent(),R.success("Dependencies installed using: ".concat(a));return[2];case 5:l=i.sent();R.warning("Failed with: ".concat(a)),R.error("Error: ".concat(l.message));return[3,6];case 6:n=true;return[3,2];case 7:return[3,10];case 8:f=i.sent();t=true;r=f;return[3,10];case 9:try{if(!n&&s.return!=null){s.return()}}finally{if(t){throw r}}return[7];case 10:throw new Error("Failed to install dependencies after multiple attempts.")}})});return eF.apply(this,arguments)}function eH(){return eM.apply(this,arguments)}function eM(){eM=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Resetting project","npx rimraf ".concat(y,"/node_modules ").concat(ef.PACKAGE_LOCK_PATH))];case 1:e.sent();return[4,ex()];case 2:e.sent();return[4,eN()];case 3:e.sent();return[2]}})});return eM.apply(this,arguments)}function eL(){return eR.apply(this,arguments)}function eR(){eR=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Inspecting project dependencies","npx node-modules-inspector")];case 1:e.sent();return[2]}})});return eR.apply(this,arguments)}function eK(){return eD.apply(this,arguments)}function eD(){eD=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Running unit tests","npx vitest --config ".concat(ef.UNIT_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eD.apply(this,arguments)}function eU(){return eJ.apply(this,arguments)}function eJ(){eJ=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,ep("Running E2E tests","npx vitest --config ".concat(ef.E2E_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eJ.apply(this,arguments)}f(l(u.argv)).command("lint","Run linting checks",eT).command("lint:fix","Fix linting issues",ek).command("lint:inspect","Inspect linting rules",e_).command("lint-staged","Run lint-staged",ew).command("commitlint","Run commitlint",eP).command("setup","Run project setup",ej).command("reset","Reset project dependencies",eH).command("inspect","Inspect project dependencies",eL).command("test:unit","Run unit tests",eK).command("test:e2e","Run e2e tests",eU).help().parse();
|
|
2
|
+
function e(e,n,t,r,s,o,i){try{var c=e[o](i);var a=c.value}catch(e){t(e);return}if(c.done){n(a)}else{Promise.resolve(a).then(r,s)}}function n(n){return function(){var t=this,r=arguments;return new Promise(function(s,o){var i=n.apply(t,r);function c(n){e(i,s,o,c,a,"next",n)}function a(n){e(i,s,o,c,a,"throw",n)}c(undefined)})}}function t(e,n,t){if(n in e){Object.defineProperty(e,n,{value:t,enumerable:true,configurable:true,writable:true})}else{e[n]=t}return e}function r(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};var s=Object.keys(r);if(typeof Object.getOwnPropertySymbols==="function"){s=s.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))}s.forEach(function(n){t(e,n,r[n])})}return e}function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(n){r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})}t.push.apply(t,r)}return t}function o(e,n){n=n!=null?n:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(n))}else{s(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i(e,n){var t,r,s,o,i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]};return o={next:c(0),"throw":c(1),"return":c(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(e){return function(n){return a([e,n])}}function a(o){if(t)throw new TypeError("Generator is already executing.");while(i)try{if(t=1,r&&(s=o[0]&2?r["return"]:o[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;if(r=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;r=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){i.label=o[1];break}if(o[0]===6&&i.label<s[1]){i.label=s[1];s=o;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(o);break}if(s[2])i.ops.pop();i.trys.pop();continue}o=n.call(e,i)}catch(e){o=[6,e];r=0}finally{t=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}}import*as c from"node:fs";import*as a from"node:path";import u from"node:process";import{hideBin as l}from"yargs/helpers";import p from"yargs/yargs";import{dirname as f}from"node:path";import h from"node:process";import{fileURLToPath as g}from"node:url";var d=g(import.meta.url),m=f(d),y=h.env.INIT_CWD||h.cwd();import v from"boxen";import b from"chalk";import{exec as _}from"node:child_process";import w from"node:process";import*as S from"node:util";import O from"node-persist";import A from"node:os";import T from"node:path";import E from"node:process";var k=E.env.CYBERSKILL_STORAGE_DIR||T.join(A.homedir(),".cyberskill-storage");function P(){return I.apply(this,arguments)}function I(){I=n(function(){var e;return i(this,function(n){switch(n.label){case 0:e=O.defaultInstance;if(e)return[3,2];return[4,O.init({dir:k,stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=n.sent();n.label=2;case 2:e;return[2]}})});return I.apply(this,arguments)}var C={get:function e(e){return n(function(){var n,t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,P()];case 1:r.sent();return[4,O.getItem(e)];case 2:return[2,(n=r.sent())!==null&&n!==void 0?n:null];case 3:t=r.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),t),null)];case 4:return[2]}})})()},set:function e(e,t){return n(function(){var n;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,P()];case 1:r.sent();return[4,O.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return n(function(){var n;return i(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,O.removeItem(e)];case 2:t.sent();return[3,4];case 3:n=t.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},keys:function e(){return n(function(){var e,n;return i(this,function(t){switch(t.label){case 0:t.trys.push([0,3,,4]);return[4,P()];case 1:t.sent();return[4,O.keys()];case 2:e=t.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:n=t.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",n),[])];case 4:return[2]}})})()},getLogLink:function e(e){return n(function(){return i(this,function(n){try{return[2,"".concat(k," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var j=w.env.DEBUG==="true",x=S.promisify(_),N=b.gray,G=b.blue,F=function(){return N("[".concat(new Date().toLocaleTimeString(),"]"))};function H(e){var n=b[e];return typeof n=="function"?n:b.green}function L(e,n,t,r){var s=H(n);console.log("".concat(F()," ").concat(s("".concat(t," ").concat(e))," ").concat(r))}function M(e,n){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=t.color,s=r===void 0?"green":r,o=t.padding,i=o===void 0?1:o,c=t.margin,a=c===void 0?1:c,u=t.borderStyle,l=u===void 0?"round":u,p=t.titleColor,f=p===void 0?"bold":p;var h=H(s),g=H(f);if(typeof n=="string"){console.log(v(g(h("".concat(e,"\n").concat(n))),{padding:i,margin:a,borderStyle:l,borderColor:s}));return}Array.isArray(n)&&n.length&&(n.forEach(function(e){var n=e.file,t=e.position,r=e.rule,s=e.message;console.log("".concat(F()," ").concat(h("File:")," ").concat(G("".concat(n).concat(t?":".concat(t):"")))),r&&console.log(" ".concat(h("Rule:")," ").concat(h(r))),console.log(" ".concat(h("Message:")," ").concat(h(s)))}),console.log(v(g(h("".concat(e,": ").concat(n.length))),{padding:i,margin:a,borderStyle:l,borderColor:s})),console.log(N("─".repeat(40))))}var K={success:function(e){return L("SUCCESS","green","✔",e)},error:function(e){return L("ERROR","red","✖",e)},warning:function(e){return L("WARNING","yellow","⚠",e)},info:function(e){return L("INFO","blue","ℹ",e)},printBoxedLog:M},R=function(e){return"error_list:".concat(e)};function D(e){return U.apply(this,arguments)}function U(){U=n(function(e){var t,r,s;return i(this,function(o){switch(o.label){case 0:if(e.length===0)return[2];t=Date.now(),r=R(t);o.label=1;case 1:o.trys.push([1,3,,4]);return[4,C.set(r,{errors:e,timestamp:t})];case 2:o.sent(),setTimeout(/*#__PURE__*/n(function(){var e;return i(this,function(n){switch(n.label){case 0:return[4,C.getLogLink(r)];case 1:e=n.sent();e&&K.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:s=o.sent();K.error("Failed to save errors: ".concat(s.message));return[3,4];case 4:return[2]}})});return U.apply(this,arguments)}function J(){return B.apply(this,arguments)}function B(){B=n(function(){var e,t,r;return i(this,function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);return[4,C.keys()];case 1:e=s.sent(),t=Array.isArray(e)?e.filter(function(e){var n;return e===null||e===void 0?void 0:(n=e.startsWith)===null||n===void 0?void 0:n.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=n(function(e){var n;return i(this,function(t){switch(t.label){case 0:return[4,C.get(e)];case 1:return[2,((n=t.sent())===null||n===void 0?void 0:n.errors)||[]]}})});return function(n){return e.apply(this,arguments)}}()))];case 2:return[2,s.sent().flat()];case 3:r=s.sent();return[2,(K.error("Failed to retrieve stored errors: ".concat(r.message)),[])];case 4:return[2]}})});return B.apply(this,arguments)}function W(){return Y.apply(this,arguments)}function Y(){Y=n(function(){var e,n,t;return i(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,C.keys()];case 1:e=r.sent(),n=Array.isArray(e)?e.filter(function(e){var n;return e===null||e===void 0?void 0:(n=e.startsWith)===null||n===void 0?void 0:n.call(e,"error_list:")}):[];return[4,Promise.all(n.map(function(e){return C.remove(e)}))];case 2:r.sent();return[3,4];case 3:t=r.sent();K.error("Failed to clear error lists: ".concat(t.message));return[3,4];case 4:return[2]}})});return Y.apply(this,arguments)}function $(e){var n=[],t=[],r="",s=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,o=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,i=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var c=s.exec(e)||[],a=o.exec(e)||[],u=i.exec(e)||[];c.length&&r?n.push({file:r,position:"".concat(c[1],":").concat(c[2]),type:c[3]==="error"?"error":"warning",message:c[4].trim(),rule:c[5].trim()}):a.length?n.push({file:a[1],position:"".concat(a[2],":").concat(a[3]),type:a[4]==="error"?"error":"warning",message:a[5].trim()}):u.length?n.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):t.push(e.trim())}}),n.length&&D(n),t.length&&j&&(K.warning("Unmatched lines:"),t.forEach(function(e){return console.log(" ".concat(e))}))}function q(e){try{var n=JSON.parse(e),t=[];n.forEach(function(e){var n=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,s=e.line,o=e.column,i=e.ruleId,c=e.message;t.push({type:r===2?"error":"warning",file:n,position:"".concat(s,":").concat(o),rule:i,message:c})})}),t.length&&D(t)}catch(n){$(e)}}function z(e){return Q.apply(this,arguments)}function Q(){Q=n(function(e){var n,t,r,s,o,c,a,u,l;var p=arguments;return i(this,function(i){switch(i.label){case 0:n=p.length>1&&p[1]!==void 0?p[1]:q;t=new AbortController;w.on("SIGINT",function(){K.warning("Process interrupted. Terminating..."),t.abort(),w.exit()});i.label=1;case 1:i.trys.push([1,3,,4]);return[4,x(e,{maxBuffer:0x6400000,signal:t.signal})];case 2:r=i.sent(),s=r.stdout,o=r.stderr;[s,o].forEach(function(e){return e&&n(e)});return[3,4];case 3:c=i.sent();a=c.stdout,u=c.stderr,l=c.message;[a,u].forEach(function(e){return e&&n(e)}),!u&&!a&&K.error("Command failed: ".concat(l));return[3,4];case 4:return[2]}})});return Q.apply(this,arguments)}import*as V from"node:fs";var X=function(e){return V.existsSync(e)};import Z from"node-fetch";import ee from"node:fs";import en from"node:path";var et=24*60*60*1e3;function er(e){return e?en.join(y,"node_modules",e,"package.json"):en.join(y,"package.json")}function es(e){return eo.apply(this,arguments)}function eo(){eo=n(function(e){var n,t,r,s,o,c,a,u,l,p;var f=arguments;return i(this,function(i){switch(i.label){case 0:n=f.length>1&&f[1]!==void 0?f[1]:!1;t="npm_version:".concat(e),r="npm_metadata:".concat(e);return[4,C.get(t)];case 1:s=i.sent();return[4,C.get(r)];case 2:o=i.sent(),c=s&&Date.now()-s.timestamp<et;if(!n&&c)return[2,s.version];a={};(o===null||o===void 0?void 0:o.etag)&&(a["If-None-Match"]=o.etag),(o===null||o===void 0?void 0:o.lastModified)&&(a["If-Modified-Since"]=o.lastModified);i.label=3;case 3:i.trys.push([3,8,,9]);return[4,Z("https://registry.npmjs.org/".concat(e,"/latest"),{headers:a})];case 4:u=i.sent();if(u.status===304&&s)return[2,s.version];if(!u.ok)throw new Error("Failed to fetch latest version: ".concat(u.statusText));return[4,u.json()];case 5:l=i.sent().version;return[4,C.set(t,{version:l,timestamp:Date.now()})];case 6:i.sent();return[4,C.set(r,{etag:u.headers.get("ETag")||void 0,lastModified:u.headers.get("Last-Modified")||void 0})];case 7:return[2,(i.sent(),l)];case 8:p=i.sent();if(K.error("Error fetching latest version for ".concat(e,": ").concat(p.message)),s)return[2,(K.warning("Falling back to cached version for ".concat(e,": ").concat(s.version)),s.version)];throw p;case 9:return[2]}})});return eo.apply(this,arguments)}function ei(e){return ec.apply(this,arguments)}function ec(){ec=n(function(e){var n,t,r,s,o;var c=arguments;return i(this,function(i){switch(i.label){case 0:n=c.length>1&&c[1]!==void 0?c[1]:!0;i.label=1;case 1:i.trys.push([1,3,,4]);t=er(e);if(!ee.existsSync(t))return[2,(K.info("".concat(e," is not installed.")),!0)];r=JSON.parse(ee.readFileSync(t,"utf-8")).version;return[4,es(e,n)];case 2:s=i.sent();return[2,(K.info("Installed version of ".concat(e,": ").concat(r)),K.info("Latest version of ".concat(e,": ").concat(s)),r!==s)];case 3:o=i.sent();return[2,(K.warning("Failed to check version for ".concat(e,": ").concat(o.message)),!0)];case 4:return[2]}})});return ec.apply(this,arguments)}function ea(e){return eu.apply(this,arguments)}function eu(){eu=n(function(e){var n,s,c,a;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,4,,5]);return[4,es(e,!0)];case 1:n=i.sent(),s=er();if(!ee.existsSync(s)){K.error("package.json not found. Cannot update ".concat(e));return[2]}c=JSON.parse(ee.readFileSync(s,"utf-8"));c.dependencies=o(r({},c.dependencies),t({},e,n)),ee.writeFileSync(s,JSON.stringify(c,null,2)),K.info("Updated ".concat(e," to version ").concat(n));return[4,ep()];case 2:i.sent();return[4,z("pnpm run lint:fix")];case 3:i.sent(),K.success("".concat(e," updated successfully."));return[3,5];case 4:a=i.sent();throw K.error("Failed to update ".concat(e,": ").concat(a.message)),a;case 5:return[2]}})});return eu.apply(this,arguments)}function el(e,n){try{var t=en.join(e,"package.json");return ee.existsSync(t)?JSON.parse(ee.readFileSync(t,"utf-8")).name===n:!1}catch(e){return K.error("Error reading package.json: ".concat(e.message)),!1}}function ep(){return ef.apply(this,arguments)}function ef(){ef=n(function(){var e,n,t,r,s,o,c,a,u,l,p;return i(this,function(i){switch(i.label){case 0:e=[{command:"pnpm install",message:"Standard installation"},{command:"pnpm install --legacy-peer-deps",message:"Attempting installation with --legacy-peer-deps"},{command:"pnpm install --force",message:"Attempting forced installation"}];n=true,t=false,r=undefined;i.label=1;case 1:i.trys.push([1,8,9,10]);s=e[Symbol.iterator]();i.label=2;case 2:if(!!(n=(o=s.next()).done))return[3,7];c=o.value,a=c.command,u=c.message;i.label=3;case 3:i.trys.push([3,5,,6]);K.info("".concat(u,"..."));return[4,z(a)];case 4:i.sent(),K.success("Dependencies installed using: ".concat(a));return[2];case 5:l=i.sent();K.warning("Failed with: ".concat(a)),K.error("Error: ".concat(l.message));return[3,6];case 6:n=true;return[3,2];case 7:return[3,10];case 8:p=i.sent();t=true;r=p;return[3,10];case 9:try{if(!n&&s.return!=null){s.return()}}finally{if(t){throw r}}return[7];case 10:throw new Error("Failed to install dependencies after multiple attempts.")}})});return ef.apply(this,arguments)}var eh={TS_CONFIG_PATH:a.resolve(y,"tsconfig.json"),HUSKY_PATH:a.resolve(y,".husky"),GIT_HOOK_PATH:a.resolve(y,".git/hooks"),GIT_COMMIT_MSG:a.resolve(y,".git/COMMIT_EDITMSG"),SIMPLE_GIT_HOOKS_PATH:a.resolve(y,".simple-git-hooks.json"),PACKAGE_JSON_PATH:a.resolve(y,"package.json"),PACKAGE_LOCK_PATH:a.resolve(y,"pnpm-lock.yaml"),PACKAGE_NAME:"@cyberskill/shared",LINT_STAGED_CONFIG_PATH:a.resolve(m,"./configs/lint-staged/base.js"),COMMITLINT_CONFIG_PATH:a.resolve(m,"./configs/commitlint/base.js"),UNIT_TEST_CONFIG_PATH:a.resolve(m,"./configs/vitest/react/unit.js"),E2E_TEST_CONFIG_PATH:a.resolve(m,"./configs/vitest/react/e2e.js"),HOOKS_CONFIG:{postinstall:"pnpm exec cyberskill setup","pre-commit":"pnpm exec cyberskill lint-staged","commit-msg":"pnpm exec cyberskill commitlint"},HOOKS_CONFIG_LOCAL:{postinstall:"pnpm exec tsx src/cli.ts setup","pre-commit":"pnpm exec tsx src/cli.ts lint-staged","commit-msg":"pnpm exec tsx src/cli.ts commitlint","pre-push":"git pull"}};function eg(e,n){return ed.apply(this,arguments)}function ed(){ed=n(function(e,n){return i(this,function(t){switch(t.label){case 0:K.info("".concat(e,"..."));return[4,z(n)];case 1:t.sent(),K.success("".concat(e," completed."));return[2]}})});return ed.apply(this,arguments)}function em(){return ey.apply(this,arguments)}function ey(){ey=n(function(){var e;return i(this,function(n){switch(n.label){case 0:if(!X(eh.TS_CONFIG_PATH))return[3,2];return[4,eg("Running TypeScript check","pnpm exec tsc -p ".concat(eh.TS_CONFIG_PATH," --noEmit"))];case 1:e=n.sent();return[3,3];case 2:e=K.warning("TypeScript config not found. Skipping TypeScript check.");n.label=3;case 3:e;return[2]}})});return ey.apply(this,arguments)}function ev(){return eb.apply(this,arguments)}function eb(){eb=n(function(){var e;var n=arguments;return i(this,function(t){switch(t.label){case 0:e=n.length>0&&n[0]!==void 0?n[0]:!1;return[4,eg("Running ESLint ".concat(e?"(with fix)":"(without fix)"),"pnpm exec eslint ".concat(y).concat(e?" --fix":""))];case 1:t.sent();return[2]}})});return eb.apply(this,arguments)}function e_(){return ew.apply(this,arguments)}function ew(){ew=n(function(){var e,n,t;return i(this,function(r){switch(r.label){case 0:return[4,J()];case 1:e=r.sent(),n=e.filter(function(e){return e.type==="error"}),t=e.filter(function(e){return e.type==="warning"});!n.length&&!t.length?K.printBoxedLog("✔ NO ISSUES FOUND","",{color:"green"}):(K.printBoxedLog("⚠ Warnings",t,{color:"yellow"}),K.printBoxedLog("✖ Errors",n,{color:"red"}));return[2]}})});return ew.apply(this,arguments)}function eS(){return eO.apply(this,arguments)}function eO(){eO=n(function(){var e;return i(this,function(n){switch(n.label){case 0:if(!el(y,eh.PACKAGE_NAME))return[3,5];n.label=1;case 1:n.trys.push([1,4,,5]);return[4,eg("Building @cyberskill/shared","pnpm run build")];case 2:n.sent();return[4,z("git add dist")];case 3:n.sent(),K.success("Built and staged @cyberskill/shared");return[3,5];case 4:e=n.sent();throw K.error("Failed to build and stage @cyberskill/shared: ".concat(e.message)),e;case 5:return[4,eg("Running lint-staged","pnpm exec lint-staged --config ".concat(eh.LINT_STAGED_CONFIG_PATH))];case 6:n.sent(),e_();return[2]}})});return eO.apply(this,arguments)}function eA(){return eT.apply(this,arguments)}function eT(){eT=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Inspecting ESLint rules","pnpm exec @eslint/config-inspector")];case 1:e.sent();return[2]}})});return eT.apply(this,arguments)}function eE(){return ek.apply(this,arguments)}function ek(){ek=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,W()];case 1:e.sent();return[4,Promise.all([em(),ev()])];case 2:e.sent(),e_();return[2]}})});return ek.apply(this,arguments)}function eP(){return eI.apply(this,arguments)}function eI(){eI=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,W()];case 1:e.sent();return[4,Promise.all([em(),ev(!0)])];case 2:e.sent(),e_();return[2]}})});return eI.apply(this,arguments)}function eC(){return ej.apply(this,arguments)}function ej(){ej=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Running commit lint","pnpm exec commitlint --edit ".concat(eh.GIT_COMMIT_MSG," --config ").concat(eh.COMMITLINT_CONFIG_PATH))];case 1:e.sent(),e_();return[2]}})});return ej.apply(this,arguments)}function ex(){return eN.apply(this,arguments)}function eN(){eN=n(function(){var e,n,t,r,s,o;return i(this,function(i){switch(i.label){case 0:if(K.info("Starting project setup..."),!X(eh.PACKAGE_JSON_PATH)){K.error("package.json not found. Aborting setup.");return[2]}i.label=1;case 1:i.trys.push([1,9,,10]);n=JSON.parse(c.readFileSync(eh.PACKAGE_JSON_PATH,"utf-8"));r=el(y,eh.PACKAGE_NAME);if(r)return[3,4];s=(e=n.dependencies)===null||e===void 0?void 0:e[eh.PACKAGE_NAME];if(!s)return[3,3];return[4,ei(eh.PACKAGE_NAME)];case 2:s=!i.sent();i.label=3;case 3:r=s;i.label=4;case 4:if(!r)return[3,5];t=K.success("Cyberskill package is already up to date.");return[3,7];case 5:K.info("\uD83D\uDCE6 Updating Cyberskill package...");return[4,ea(eh.PACKAGE_NAME)];case 6:t=(i.sent(),K.success("Cyberskill package updated successfully."));i.label=7;case 7:t;return[4,eG()];case 8:i.sent(),K.success("Project setup completed.");return[3,10];case 9:o=i.sent();throw K.error("Failed to setup project: ".concat(o.message)),o;case 10:return[2]}})});return eN.apply(this,arguments)}function eG(){return eF.apply(this,arguments)}function eF(){eF=n(function(){var e,n,t;return i(this,function(r){switch(r.label){case 0:K.info("Setting up Git hooks...");e=X(eh.HUSKY_PATH);if(!e)return[3,3];return[4,z("pnpm exec rimraf ".concat(eh.HUSKY_PATH," ").concat(eh.GIT_HOOK_PATH))];case 1:r.sent();return[4,z("git config core.hooksPath ".concat(eh.GIT_HOOK_PATH))];case 2:e=r.sent();r.label=3;case 3:e;n=el(y,eh.PACKAGE_NAME);c.writeFileSync(eh.SIMPLE_GIT_HOOKS_PATH,JSON.stringify(n?eh.HOOKS_CONFIG_LOCAL:eh.HOOKS_CONFIG,null,4));t=a.resolve(".gitignore");X(t)?c.readFileSync(t,"utf8").split("\n").includes(".simple-git-hooks.json")?K.info(".simple-git-hooks.json is already ignored in .gitignore"):(c.appendFileSync(t,"\n# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),K.info("Added .simple-git-hooks.json to .gitignore")):(c.writeFileSync(t,"# Ignore simple-git-hooks config\n.simple-git-hooks.json\n"),K.info("Created .gitignore and added .simple-git-hooks.json"));return[4,z("pnpm exec simple-git-hooks")];case 4:r.sent(),K.success("Git hooks configured successfully.");return[2]}})});return eF.apply(this,arguments)}function eH(){return eL.apply(this,arguments)}function eL(){eL=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Resetting project","pnpm exec rimraf ".concat(y,"/node_modules ").concat(eh.PACKAGE_LOCK_PATH))];case 1:e.sent();return[4,ep()];case 2:e.sent();return[4,eG()];case 3:e.sent();return[2]}})});return eL.apply(this,arguments)}function eM(){return eK.apply(this,arguments)}function eK(){eK=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Inspecting project dependencies","pnpm exec node-modules-inspector")];case 1:e.sent();return[2]}})});return eK.apply(this,arguments)}function eR(){return eD.apply(this,arguments)}function eD(){eD=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Running unit tests","pnpm exec vitest --config ".concat(eh.UNIT_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eD.apply(this,arguments)}function eU(){return eJ.apply(this,arguments)}function eJ(){eJ=n(function(){return i(this,function(e){switch(e.label){case 0:return[4,eg("Running E2E tests","pnpm exec vitest --config ".concat(eh.E2E_TEST_CONFIG_PATH))];case 1:e.sent();return[2]}})});return eJ.apply(this,arguments)}p(l(u.argv)).command("lint","Run linting checks",eE).command("lint:fix","Fix linting issues",eP).command("lint:inspect","Inspect linting rules",eA).command("lint-staged","Run lint-staged",eS).command("commitlint","Run commitlint",eC).command("setup","Run project setup",ex).command("reset","Reset project dependencies",eH).command("inspect","Inspect project dependencies",eM).command("test:unit","Run unit tests",eR).command("test:e2e","Run e2e tests",eU).help().parse();
|