crankscript 0.5.1 → 0.6.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/package.json +1 -1
- package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +1 -0
- package/src/commands/GenerateTypes/GenerateTypesCommand.js +5 -1
- package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -1
- package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +2 -1
- package/src/commands/GenerateTypes/components/GenerateTypes.js +11 -5
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
- package/src/commands/GenerateTypes/fn/generateFunction.d.ts +4 -0
- package/src/commands/GenerateTypes/fn/generateFunction.js +28 -0
- package/src/commands/GenerateTypes/fn/generateFunction.js.map +1 -0
- package/src/commands/GenerateTypes/fn/generateNamespace.d.ts +4 -3
- package/src/commands/GenerateTypes/fn/generateNamespace.js +68 -21
- package/src/commands/GenerateTypes/fn/generateNamespace.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +2 -11
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js +26 -9
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.d.ts +5 -0
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +75 -0
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -0
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.d.ts +1 -1
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +4 -6
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.d.ts +2 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +14 -23
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +10 -0
- package/src/commands/GenerateTypes/hooks/useGetVersion.js +5 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +0 -9
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +3 -3
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -1
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +12 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.js +141 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -0
- package/src/components/CheckList/CheckList.js +1 -2
- package/src/components/CheckList/CheckList.js.map +1 -1
- package/src/components/CheckList/Item.js +1 -0
- package/src/components/CheckList/Item.js.map +1 -1
- package/src/constants.d.ts +2 -0
- package/src/constants.js +4 -0
- package/src/constants.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/types.d.ts +34 -3
- package/src/types.js.map +1 -1
- package/src/utils/dirname.d.ts +1 -1
- package/src/utils/dirname.js +2 -3
- package/src/utils/dirname.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.d.ts +0 -2
- package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js +0 -37
- package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js.map +0 -1
- package/src/commands/GenerateTypes/utils/playdateConstants.d.ts +0 -9
- package/src/commands/GenerateTypes/utils/playdateConstants.js +0 -134
- package/src/commands/GenerateTypes/utils/playdateConstants.js.map +0 -1
@@ -1,7 +1,8 @@
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
1
2
|
import { useMemo } from 'react';
|
2
3
|
import { Project } from 'ts-morph';
|
3
4
|
import { generateNamespace } from '../../../commands/GenerateTypes/fn/generateNamespace.js';
|
4
|
-
export const useGenerateTypeFile = (path, definitions)=>{
|
5
|
+
export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
|
5
6
|
const generateTypeFile = useMemo(()=>{
|
6
7
|
return {
|
7
8
|
waitingDescription: 'Waiting to generate the type file...',
|
@@ -12,39 +13,29 @@ export const useGenerateTypeFile = (path, definitions)=>{
|
|
12
13
|
if (!definitions) {
|
13
14
|
throw new Error('Definitions are not set');
|
14
15
|
}
|
16
|
+
if (!typeProvider) {
|
17
|
+
throw new Error('Type provider is not set');
|
18
|
+
}
|
15
19
|
const project = new Project();
|
16
20
|
const typeFile = project.createSourceFile(path, '', {
|
17
21
|
overwrite: true
|
18
22
|
});
|
19
|
-
typeFile.addStatements(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
docs: [
|
24
|
-
constantDefinition.docs
|
25
|
-
],
|
26
|
-
isConst: true,
|
27
|
-
isExported: true,
|
28
|
-
members: constantDefinition.values.map((value)=>({
|
29
|
-
name: value.name,
|
30
|
-
docs: [
|
31
|
-
value.docs
|
32
|
-
],
|
33
|
-
value: value.value
|
34
|
-
}))
|
35
|
-
});
|
36
|
-
}
|
23
|
+
typeFile.addStatements(typeProvider.getGlobalStatements());
|
24
|
+
const subjects = new Map();
|
25
|
+
const typeSubjects = new Map();
|
26
|
+
subjects.set('root', typeFile);
|
37
27
|
Object.keys(definitions.namespaces).forEach((namespace)=>{
|
38
28
|
const namespaceDescription = definitions.namespaces[namespace];
|
39
29
|
const namespaces = namespace.split('.');
|
40
|
-
generateNamespace(
|
30
|
+
generateNamespace(namespaceDescription, namespaces, subjects, typeSubjects, typeProvider, definitions.types);
|
41
31
|
});
|
42
|
-
typeFile.
|
32
|
+
writeFileSync(path, typeFile.getFullText().replace('/** Playdate SDK */', '\n/** Playdate SDK */'));
|
43
33
|
},
|
44
|
-
ready: definitions !== null
|
34
|
+
ready: definitions !== null && typeProvider !== null
|
45
35
|
};
|
46
36
|
}, [
|
47
|
-
definitions
|
37
|
+
definitions,
|
38
|
+
typeProvider
|
48
39
|
]);
|
49
40
|
return {
|
50
41
|
generateTypeFile
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n InterfaceDeclaration,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { ApiDefinitions, CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n const subjects = new Map<\n string,\n SourceFile | ModuleDeclaration\n >();\n const typeSubjects = new Map<string, InterfaceDeclaration>();\n subjects.set('root', typeFile);\n\n Object.keys(definitions.namespaces).forEach((namespace) => {\n const namespaceDescription =\n definitions.namespaces[namespace];\n const namespaces = namespace.split('.');\n generateNamespace(\n namespaceDescription,\n namespaces,\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\n );\n });\n\n writeFileSync(\n path,\n typeFile\n .getFullText()\n .replace('/** Playdate SDK */', '\\n/** Playdate SDK */')\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["writeFileSync","useMemo","Project","generateNamespace","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","getGlobalStatements","subjects","Map","typeSubjects","set","Object","keys","namespaces","forEach","namespace","namespaceDescription","split","types","getFullText","replace","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAGIC,OAAO,QAEJ,WAAW;AAClB,SAASC,iBAAiB,QAAQ,uDAAuD;AAIzF,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACP,aAAa;oBACd,MAAM,IAAIQ,MAAM;gBACpB;gBAEA,IAAI,CAACP,cAAc;oBACf,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIb;gBACpB,MAAMc,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBACAF,SAASG,aAAa,CAACZ,aAAaa,mBAAmB;gBAEvD,MAAMC,WAAW,IAAIC;gBAIrB,MAAMC,eAAe,IAAID;gBACzBD,SAASG,GAAG,CAAC,QAAQR;gBAErBS,OAAOC,IAAI,CAACpB,YAAYqB,UAAU,EAAEC,OAAO,CAAC,CAACC;oBACzC,MAAMC,uBACFxB,YAAYqB,UAAU,CAACE,UAAU;oBACrC,MAAMF,aAAaE,UAAUE,KAAK,CAAC;oBACnC5B,kBACI2B,sBACAH,YACAN,UACAE,cACAhB,cACAD,YAAY0B,KAAK;gBAEzB;gBAEAhC,cACIK,MACAW,SACKiB,WAAW,GACXC,OAAO,CAAC,uBAAuB;YAE5C;YACAC,OAAO7B,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE"}
|
@@ -9,4 +9,14 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
|
|
9
9
|
runner: () => Promise<string>;
|
10
10
|
onFinish: (result: string) => void;
|
11
11
|
};
|
12
|
+
typeProvider: {
|
13
|
+
getGlobalStatements: () => string[];
|
14
|
+
getStatements: () => string[];
|
15
|
+
getPropertyDetails: (property: import("../../../types.js").PropertyDescription) => import("../../../types.js").PropertyDetails;
|
16
|
+
getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
|
17
|
+
getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
|
18
|
+
getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
|
19
|
+
getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodSignatureStructure>;
|
20
|
+
save: () => void;
|
21
|
+
} | null;
|
12
22
|
};
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import { useCallback, useMemo, useState } from 'react';
|
2
2
|
import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
|
3
|
+
import { createTypeProvider } from '../../../commands/GenerateTypes/utils/createTypeProvider.js';
|
3
4
|
import { PlaydateSdkVersionIdentifier } from '../../../types.js';
|
4
5
|
export const useGetVersion = (version)=>{
|
6
|
+
const [typeProvider, setTypeProvider] = useState(null);
|
5
7
|
const [result, setResult] = useState(null);
|
6
8
|
const fetchLastVersion = useCallback(async ()=>{
|
7
9
|
const response = await fetch(PlaydateSdkUrl);
|
@@ -32,6 +34,7 @@ export const useGetVersion = (version)=>{
|
|
32
34
|
versionLiteral = await fetchLastVersion();
|
33
35
|
}
|
34
36
|
await validateVersion(versionLiteral);
|
37
|
+
setTypeProvider(createTypeProvider(versionLiteral));
|
35
38
|
return versionLiteral;
|
36
39
|
},
|
37
40
|
onFinish: (result)=>{
|
@@ -41,7 +44,8 @@ export const useGetVersion = (version)=>{
|
|
41
44
|
}, []);
|
42
45
|
return {
|
43
46
|
fetchedVersion: result,
|
44
|
-
getVersion
|
47
|
+
getVersion,
|
48
|
+
typeProvider
|
45
49
|
};
|
46
50
|
};
|
47
51
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport {\n CheckListItem,\n PlaydateSdkVersion,\n PlaydateSdkVersionIdentifier,\n} from '@/cli/types.js';\n\nexport const useGetVersion = (version: PlaydateSdkVersion) => {\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: (result) => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n return versionLiteral;\n },\n onFinish: (result) => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","PlaydateSdkVersionIdentifier","useGetVersion","version","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n CheckListItem,\n PlaydateSdkVersion,\n PlaydateSdkVersionIdentifier,\n} from '@/cli/types.js';\n\nexport const useGetVersion = (version: PlaydateSdkVersion) => {\n const [typeProvider, setTypeProvider] = useState<ReturnType<\n typeof createTypeProvider\n > | null>(null);\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: (result) => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n setTypeProvider(createTypeProvider(versionLiteral));\n\n return versionLiteral;\n },\n onFinish: (result) => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n typeProvider,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","createTypeProvider","PlaydateSdkVersionIdentifier","useGetVersion","version","typeProvider","setTypeProvider","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,kBAAkB,QAAQ,2DAA2D;AAC9F,SAGIC,4BAA4B,QACzB,iBAAiB;AAExB,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,CAACC,cAAcC,gBAAgB,GAAGP,SAE9B;IACV,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAwB;IACpD,MAAMU,mBAAmBZ,YAAY;QACjC,MAAMa,WAAW,MAAMC,MAAMX;QAC7B,MAAMY,MAAMF,SAASE,GAAG;QAExB,MAAMC,QAAQ;QACd,MAAMC,QAAQF,IAAIE,KAAK,CAACD;QAExB,IAAI,CAACC,SAASA,MAAMC,MAAM,GAAG,GAAG;YAC5B,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOF,KAAK,CAAC,EAAE;IACnB,GAAG,EAAE;IACL,MAAMG,kBAAkBpB,YAAY,OAAOO;QACvC,MAAMM,WAAW,MAAMC,MAAM,CAAC,sBAAsB,EAAEP,QAAQ,CAAC,CAAC;QAEhE,IAAI,CAACM,SAASQ,EAAE,EAAE;YACd,MAAM,IAAIF,MAAM,CAAC,wBAAwB,EAAEZ,QAAQ,CAAC;QACxD;QAEA,OAAO;IACX,GAAG,EAAE;IAEL,MAAMe,aAAarB,QAAQ;QACvB,OAAO;YACHsB,oBAAoB,CAAC,wBAAwB,CAAC;YAC9CC,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,CAAChB,SAAW,CAAC,gBAAgB,EAAEA,OAAO,CAAC;YAC5DiB,QAAQ;gBACJ,IAAIC,iBAAiBrB;gBAErB,IAAIA,YAAYF,6BAA6BwB,MAAM,EAAE;oBACjDD,iBAAiB,MAAMhB;gBAC3B;gBAEA,MAAMQ,gBAAgBQ;gBAEtBnB,gBAAgBL,mBAAmBwB;gBAEnC,OAAOA;YACX;YACAE,UAAU,CAACpB;gBACPC,UAAUD;YACd;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;QACAd;IACJ;AACJ,EAAE"}
|
@@ -9,15 +9,6 @@ export declare const useParseDocumentation: (html: string | null, version: strin
|
|
9
9
|
runner: () => Promise<{
|
10
10
|
namespaces: Record<string, import("../../../types.js").PlaydateNamespace>;
|
11
11
|
types: Record<string, import("../../../types.js").PlaydateType>;
|
12
|
-
constants: {
|
13
|
-
name: string;
|
14
|
-
values: {
|
15
|
-
name: string;
|
16
|
-
value: number;
|
17
|
-
docs: string;
|
18
|
-
}[];
|
19
|
-
docs: string;
|
20
|
-
}[];
|
21
12
|
}>;
|
22
13
|
onFinish: (result: ApiDefinitions) => void;
|
23
14
|
ready: boolean;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useMemo, useState } from 'react';
|
2
2
|
import { getApiDefinitions } from '../../../commands/GenerateTypes/fn/getApiDefinitions.js';
|
3
|
-
import {
|
3
|
+
import { getDescriptionsFromHtml } from '../../../commands/GenerateTypes/fn/getDescriptionsFromHtml.js';
|
4
4
|
export const useParseDocumentation = (html, version)=>{
|
5
5
|
const [result, setResult] = useState(null);
|
6
6
|
const parseDocumentation = useMemo(()=>{
|
@@ -13,8 +13,8 @@ export const useParseDocumentation = (html, version)=>{
|
|
13
13
|
if (!html) {
|
14
14
|
throw new Error('HTML is not set');
|
15
15
|
}
|
16
|
-
const functions =
|
17
|
-
return getApiDefinitions(functions);
|
16
|
+
const { functions, properties } = getDescriptionsFromHtml(html, version);
|
17
|
+
return getApiDefinitions(functions, properties);
|
18
18
|
},
|
19
19
|
onFinish: (result)=>{
|
20
20
|
setResult(result);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getDescriptionsFromHtml.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const { functions, properties } = getDescriptionsFromHtml(\n html,\n version\n );\n\n return getApiDefinitions(functions, properties);\n },\n onFinish: (result) => {\n setResult(result);\n },\n ready: html !== null,\n } satisfies CheckListItem<ApiDefinitions>;\n }, [html]);\n\n return {\n definitions: result,\n parseDocumentation,\n };\n};\n"],"names":["useMemo","useState","getApiDefinitions","getDescriptionsFromHtml","useParseDocumentation","html","version","result","setResult","parseDocumentation","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","functions","properties","onFinish","ready","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,uBAAuB,QAAQ,6DAA6D;AAGrG,OAAO,MAAMC,wBAAwB,CAACC,MAAqBC;IACvD,MAAM,CAACC,QAAQC,UAAU,GAAGP,SAAgC;IAE5D,MAAMQ,qBAAqBT,QAAQ;QAC/B,OAAO;YACHU,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACT,MAAM;oBACP,MAAM,IAAIU,MAAM;gBACpB;gBAEA,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE,GAAGd,wBAC9BE,MACAC;gBAGJ,OAAOJ,kBAAkBc,WAAWC;YACxC;YACAC,UAAU,CAACX;gBACPC,UAAUD;YACd;YACAY,OAAOd,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHe,aAAab;QACbE;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { FunctionDeclarationStructure } from 'ts-morph';
|
2
|
+
import { FunctionDescription, ParameterDetails, PropertyDescription, PropertyDetails } from '../../../types.js';
|
3
|
+
export declare const createTypeProvider: (version: string) => {
|
4
|
+
getGlobalStatements: () => string[];
|
5
|
+
getStatements: () => string[];
|
6
|
+
getPropertyDetails: (property: PropertyDescription) => PropertyDetails;
|
7
|
+
getFunctionReturnType: (func: FunctionDescription) => string;
|
8
|
+
getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
|
9
|
+
getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
|
10
|
+
getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodSignatureStructure>;
|
11
|
+
save: () => void;
|
12
|
+
};
|
@@ -0,0 +1,141 @@
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
2
|
+
import { readFileSync } from 'fs';
|
3
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
4
|
+
import { join } from 'node:path';
|
5
|
+
import { StructureKind } from 'ts-morph';
|
6
|
+
import { DataFolder } from '../../../constants.js';
|
7
|
+
function kebabToCamelCase(str) {
|
8
|
+
return str.replace(/-([a-z])/g, (_, letter)=>letter.toUpperCase());
|
9
|
+
}
|
10
|
+
export const createTypeProvider = (version)=>{
|
11
|
+
const path = join(DataFolder, `${version}.json`);
|
12
|
+
const fallbackProvider = existsSync(path) ? JSON.parse(readFileSync(path, 'utf-8')) : {
|
13
|
+
globalStatements: [],
|
14
|
+
statements: [],
|
15
|
+
properties: {},
|
16
|
+
functions: {}
|
17
|
+
};
|
18
|
+
const provider = {
|
19
|
+
globalStatements: fallbackProvider.globalStatements,
|
20
|
+
statements: fallbackProvider.statements,
|
21
|
+
properties: {},
|
22
|
+
functions: {}
|
23
|
+
};
|
24
|
+
const visitedProperties = new Map();
|
25
|
+
const visitedFunctions = new Map();
|
26
|
+
const getPropertyDetails = (property)=>{
|
27
|
+
if (visitedProperties.has(property.signature)) {
|
28
|
+
return visitedProperties.get(property.signature);
|
29
|
+
}
|
30
|
+
let result;
|
31
|
+
let prop = provider.properties[property.signature];
|
32
|
+
if (!prop) {
|
33
|
+
prop = fallbackProvider.properties[property.signature];
|
34
|
+
}
|
35
|
+
if (!prop) {
|
36
|
+
const details = {
|
37
|
+
signature: property.signature,
|
38
|
+
type: 'any'
|
39
|
+
};
|
40
|
+
provider.properties[property.signature] = details;
|
41
|
+
result = details;
|
42
|
+
} else {
|
43
|
+
provider.properties[property.signature] = prop;
|
44
|
+
result = prop;
|
45
|
+
}
|
46
|
+
visitedProperties.set(property.signature, result);
|
47
|
+
return result;
|
48
|
+
};
|
49
|
+
const getFunctionDetails = (func)=>{
|
50
|
+
if (visitedFunctions.has(func.signature)) {
|
51
|
+
return visitedFunctions.get(func.signature);
|
52
|
+
}
|
53
|
+
let result;
|
54
|
+
let fn = provider.functions[func.signature];
|
55
|
+
if (!fn) {
|
56
|
+
fn = fallbackProvider.functions[func.signature];
|
57
|
+
}
|
58
|
+
if (!fn) {
|
59
|
+
const details = {
|
60
|
+
signature: func.signature,
|
61
|
+
parameters: func.parameters.map((p)=>({
|
62
|
+
name: p.name,
|
63
|
+
type: 'any'
|
64
|
+
})),
|
65
|
+
returnType: 'any'
|
66
|
+
};
|
67
|
+
provider.functions[func.signature] = details;
|
68
|
+
result = details;
|
69
|
+
} else {
|
70
|
+
provider.functions[func.signature] = fn;
|
71
|
+
result = fn;
|
72
|
+
}
|
73
|
+
visitedFunctions.set(func.signature, result);
|
74
|
+
return result;
|
75
|
+
};
|
76
|
+
const getGlobalStatements = ()=>{
|
77
|
+
return provider.globalStatements;
|
78
|
+
};
|
79
|
+
const getStatements = ()=>{
|
80
|
+
return provider.statements;
|
81
|
+
};
|
82
|
+
const isPropertyStatic = (property)=>{
|
83
|
+
const { isStatic } = getPropertyDetails(property);
|
84
|
+
return isStatic;
|
85
|
+
};
|
86
|
+
const getFunctionReturnType = (func)=>{
|
87
|
+
const { returnType } = getFunctionDetails(func);
|
88
|
+
return returnType;
|
89
|
+
};
|
90
|
+
const getParameterDetails = (func, parameter)=>{
|
91
|
+
const { parameters } = getFunctionDetails(func);
|
92
|
+
const param = parameters.find((p)=>p.name === parameter);
|
93
|
+
if (!param) {
|
94
|
+
return {
|
95
|
+
name: parameter,
|
96
|
+
type: 'any'
|
97
|
+
};
|
98
|
+
}
|
99
|
+
return param;
|
100
|
+
};
|
101
|
+
const getParameters = (func)=>{
|
102
|
+
const { overrideParameters = false, parameters } = getFunctionDetails(func);
|
103
|
+
const getParameterFromDetails = (parameter)=>{
|
104
|
+
var _parameter_overrideOptions;
|
105
|
+
return _extends({
|
106
|
+
kind: StructureKind.Parameter,
|
107
|
+
name: kebabToCamelCase(parameter.name),
|
108
|
+
type: parameter.type
|
109
|
+
}, (_parameter_overrideOptions = parameter.overrideOptions) != null ? _parameter_overrideOptions : {});
|
110
|
+
};
|
111
|
+
if (overrideParameters) {
|
112
|
+
return parameters.map((details)=>{
|
113
|
+
return getParameterFromDetails(details);
|
114
|
+
});
|
115
|
+
}
|
116
|
+
return func.parameters.map((parameter)=>{
|
117
|
+
const details = getParameterDetails(func, parameter.name);
|
118
|
+
return getParameterFromDetails(details);
|
119
|
+
});
|
120
|
+
};
|
121
|
+
const getFunctionOverrideOptions = (func)=>{
|
122
|
+
var _getFunctionDetails_overrideOptions;
|
123
|
+
return (_getFunctionDetails_overrideOptions = getFunctionDetails(func).overrideOptions) != null ? _getFunctionDetails_overrideOptions : {};
|
124
|
+
};
|
125
|
+
const save = ()=>{
|
126
|
+
const contents = JSON.stringify(provider, null, 4);
|
127
|
+
writeFileSync(path, contents, 'utf-8');
|
128
|
+
};
|
129
|
+
return {
|
130
|
+
getGlobalStatements,
|
131
|
+
getStatements,
|
132
|
+
getPropertyDetails,
|
133
|
+
getFunctionReturnType,
|
134
|
+
getParameterDetails,
|
135
|
+
getParameters,
|
136
|
+
getFunctionOverrideOptions,
|
137
|
+
save
|
138
|
+
};
|
139
|
+
};
|
140
|
+
|
141
|
+
//# sourceMappingURL=createTypeProvider.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n statements: [],\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n properties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map((p) => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const isPropertyStatic = (property: PropertyDescription) => {\n const { isStatic } = getPropertyDetails(property);\n\n return isStatic;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find((p) => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map((details) => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map((parameter) => {\n const details = getParameterDetails(func, parameter.name);\n\n return getParameterFromDetails(details);\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n return getFunctionDetails(func).overrideOptions ?? {};\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4);\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getPropertyDetails,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","properties","functions","provider","visitedProperties","Map","visitedFunctions","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","isPropertyStatic","isStatic","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","getFunctionOverrideOptions","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CurrentIndex(index + 1);
|
17
17
|
} else {
|
18
|
-
setCurrentIndex(null);
|
19
18
|
onFinish == null ? void 0 : onFinish();
|
20
19
|
}
|
21
20
|
};
|
22
21
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, items.map((item, index)=>/*#__PURE__*/ React.createElement(Item, {
|
23
|
-
key:
|
22
|
+
key: item.waitingDescription,
|
24
23
|
item: _extends({}, item, {
|
25
24
|
onFinish: (result)=>{
|
26
25
|
var _item_onFinish;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\ninterface Props {\n items: CheckListItem<unknown>[];\n onFinish?: () => void;\n}\n\nexport const CheckList = ({ items, onFinish }: Props) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\ninterface Props {\n items: CheckListItem<unknown>[];\n onFinish?: () => void;\n}\n\nexport const CheckList = ({ items, onFinish }: Props) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n onFinish?.();\n }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={item.waitingDescription}\n item={{\n ...item,\n onFinish: (result: unknown) => {\n item?.onFinish?.(result);\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","onFinish","currentIndex","setCurrentIndex","length","handleFinish","index","map","item","key","waitingDescription","result","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,OAAO,MAAMC,YAAY,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAS;IAChD,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,SAAwB;IAEhED,UAAU;QACN,IAAIM,iBAAiB,QAAQF,MAAMI,MAAM,GAAG,GAAG;YAC3CD,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcF;KAAM;IAExB,MAAMK,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIN,MAAMI,MAAM,EAAE;YAC1BD,gBAAgBG,QAAQ;QAC5B,OAAO;YACHL,4BAAAA;QACJ;IACJ;IAEA,qBACI,0CACKD,MAAMO,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACR;YACGW,KAAKD,KAAKE,kBAAkB;YAC5BF,MAAM,aACCA;gBACHP,UAAU,CAACU;wBACPH;oBAAAA,yBAAAA,iBAAAA,KAAMP,QAAQ,qBAAdO,oBAAAA,MAAiBG;oBACjBN,aAAaC;gBACjB;;YAEJM,OAAON,UAAUJ;;AAKrC,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import {\n StatusMessage,\n StatusMessageProps,\n Spinner,\n extendTheme,\n defaultTheme,\n ThemeProvider,\n} from '@inkjs/ui';\nimport { Text, TextProps } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\n// todo: possibly extract this\nconst SpinnerTheme = extendTheme(defaultTheme, {\n components: {\n Spinner: {\n styles: {\n frame: (): TextProps => ({\n color: 'yellowBright',\n }),\n label: (): TextProps => ({\n color: 'yellowBright',\n }),\n },\n },\n },\n});\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n ready,\n },\n start,\n}: ItemProps<TResult>) => {\n const executed = useRef(false);\n const interval = useRef<NodeJS.Timeout | null>(null);\n const [dotCount, setDotCount] = useState(0);\n const [result, setResult] = useState<TResult | null>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (couldStartButNotReady) {\n interval.current = setInterval(() => {\n setDotCount((count) => (count + 1) % 4);\n }, 250);\n } else {\n if (interval.current) {\n clearInterval(interval.current);\n }\n }\n\n return () => {\n if (interval.current) {\n clearInterval(interval.current);\n }\n };\n }, [couldStartButNotReady]);\n\n useEffect(() => {\n if (!start || executed.current || ready === false) {\n return;\n }\n\n runner()\n .then((result) => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch((reason) => {\n setfailedReason(reason.message);\n });\n }, [errorDescription, onFinish, runner, start]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isRunning) {\n message = runningDescription;\n variant = 'warning';\n } else if (hasResult) {\n message = finishedDescription(result);\n variant = 'success';\n }\n\n if (isRunning) {\n return (\n <ThemeProvider theme={SpinnerTheme}>\n <Spinner label={` ${message}`} />\n </ThemeProvider>\n );\n }\n\n return (\n <StatusMessage variant={variant}>\n <Text\n bold={!isWaiting}\n color={\n isRunning\n ? 'yellow'\n : isWaiting\n ? 'gray'\n : failedReason\n ? 'red'\n : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Spinner","extendTheme","defaultTheme","ThemeProvider","Text","React","useEffect","useRef","useState","SpinnerTheme","components","styles","frame","color","label","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","ready","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","message","variant","theme","bold","repeat"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import {\n StatusMessage,\n StatusMessageProps,\n Spinner,\n extendTheme,\n defaultTheme,\n ThemeProvider,\n} from '@inkjs/ui';\nimport { Text, TextProps } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\n// todo: possibly extract this\nconst SpinnerTheme = extendTheme(defaultTheme, {\n components: {\n Spinner: {\n styles: {\n frame: (): TextProps => ({\n color: 'yellowBright',\n }),\n label: (): TextProps => ({\n color: 'yellowBright',\n }),\n },\n },\n },\n});\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n runner,\n onFinish,\n ready,\n },\n start,\n}: ItemProps<TResult>) => {\n const executed = useRef(false);\n const interval = useRef<NodeJS.Timeout | null>(null);\n const [dotCount, setDotCount] = useState(0);\n const [result, setResult] = useState<TResult | null>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason) {\n process.exit();\n }\n }, [failedReason]);\n\n useEffect(() => {\n if (couldStartButNotReady) {\n interval.current = setInterval(() => {\n setDotCount((count) => (count + 1) % 4);\n }, 250);\n } else {\n if (interval.current) {\n clearInterval(interval.current);\n }\n }\n\n return () => {\n if (interval.current) {\n clearInterval(interval.current);\n }\n };\n }, [couldStartButNotReady]);\n\n useEffect(() => {\n if (!start || executed.current || ready === false) {\n return;\n }\n\n runner()\n .then((result) => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch((reason) => {\n console.log(reason);\n setfailedReason(reason.message);\n });\n }, [errorDescription, onFinish, runner, start]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isRunning) {\n message = runningDescription;\n variant = 'warning';\n } else if (hasResult) {\n message = finishedDescription(result);\n variant = 'success';\n }\n\n if (isRunning) {\n return (\n <ThemeProvider theme={SpinnerTheme}>\n <Spinner label={` ${message}`} />\n </ThemeProvider>\n );\n }\n\n return (\n <StatusMessage variant={variant}>\n <Text\n bold={!isWaiting}\n color={\n isRunning\n ? 'yellow'\n : isWaiting\n ? 'gray'\n : failedReason\n ? 'red'\n : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Spinner","extendTheme","defaultTheme","ThemeProvider","Text","React","useEffect","useRef","useState","SpinnerTheme","components","styles","frame","color","label","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","ready","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","console","log","message","variant","theme","bold","repeat"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SACIA,aAAa,EAEbC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,aAAa,QACV,YAAY;AACnB,SAASC,IAAI,QAAmB,MAAM;AACtC,OAAOC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAQ3D,8BAA8B;AAC9B,MAAMC,eAAeR,YAAYC,cAAc;IAC3CQ,YAAY;QACRV,SAAS;YACLW,QAAQ;gBACJC,OAAO,IAAkB,CAAA;wBACrBC,OAAO;oBACX,CAAA;gBACAC,OAAO,IAAkB,CAAA;wBACrBD,OAAO;oBACX,CAAA;YACJ;QACJ;IACJ;AACJ;AAEA,OAAO,MAAME,OAAO,CAAW,EAC3BC,MAAM,EACFC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACR,EACDC,KAAK,EACY;IACjB,MAAMC,WAAWlB,OAAO;IACxB,MAAMmB,WAAWnB,OAA8B;IAC/C,MAAM,CAACoB,UAAUC,YAAY,GAAGpB,SAAS;IACzC,MAAM,CAACqB,QAAQC,UAAU,GAAGtB,SAAyB;IACrD,MAAM,CAACuB,cAAcC,gBAAgB,GAAGxB,SAAwB;IAChE,MAAMyB,YAAY,CAACF,gBAAgBF,WAAW;IAC9C,MAAMK,YAAY,CAACH,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IACpE,MAAMY,YAAY,CAACJ,gBAAgB,CAACE,aAAc,CAAA,CAACT,SAAS,CAACD,KAAI;IACjE,MAAMa,wBACF,CAACL,gBAAgB,CAACE,aAAaT,SAASD,UAAU;IAEt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B;QACPtB,OACIqB,YACM,WACAC,YACA,SACAJ,eACA,QACA;OAGTiB,SAAS,KACTZ,yBACG,CAAC,eAAe,EAAE,IAAIgB,MAAM,CAACzB,UAAU,CAAC;AAI5D,EAAE"}
|
package/src/constants.d.ts
CHANGED
package/src/constants.js
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
import { join } from 'node:path';
|
2
|
+
import { __dirname } from './utils/dirname.js';
|
1
3
|
export const CrankscriptConfigurationFileName = 'crankscript.json';
|
2
4
|
export const TypescriptReservedNamed = [
|
3
5
|
'delete',
|
4
6
|
'new',
|
5
7
|
'function'
|
6
8
|
];
|
9
|
+
export const RootFolder = join(__dirname, '..', '..');
|
10
|
+
export const DataFolder = join(RootFolder, 'src', 'data');
|
7
11
|
|
8
12
|
//# sourceMappingURL=constants.js.map
|
package/src/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { __dirname } from './utils/dirname.js';\n\nexport const CrankscriptConfigurationFileName = 'crankscript.json';\nexport const TypescriptReservedNamed = ['delete', 'new', 'function'];\nexport const RootFolder = join(__dirname, '..', '..');\nexport const DataFolder = join(RootFolder, 'src', 'data');\n"],"names":["join","__dirname","CrankscriptConfigurationFileName","TypescriptReservedNamed","RootFolder","DataFolder"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,SAASC,SAAS,QAAQ,qBAAqB;AAE/C,OAAO,MAAMC,mCAAmC,mBAAmB;AACnE,OAAO,MAAMC,0BAA0B;IAAC;IAAU;IAAO;CAAW,CAAC;AACrE,OAAO,MAAMC,aAAaJ,KAAKC,WAAW,MAAM,MAAM;AACtD,OAAO,MAAMI,aAAaL,KAAKI,YAAY,OAAO,QAAQ"}
|
package/src/index.js
CHANGED
@@ -4,7 +4,7 @@ import { join } from 'node:path';
|
|
4
4
|
import { Cli } from 'clipanion';
|
5
5
|
import { DoctorCommand } from './commands/DoctorCommand.js';
|
6
6
|
import { GenerateTypesCommand } from './commands/GenerateTypes/GenerateTypesCommand.js';
|
7
|
-
import { RootFolder } from './
|
7
|
+
import { RootFolder } from './constants.js';
|
8
8
|
const packageJsonContents = readFileSync(join(RootFolder, 'package.json'), 'utf-8');
|
9
9
|
const packageJson = JSON.parse(packageJsonContents);
|
10
10
|
const args = process.argv.slice(2);
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Cli } from 'clipanion';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';\nimport { RootFolder } from '@/cli/
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Cli } from 'clipanion';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';\nimport { RootFolder } from '@/cli/constants.js';\n\nconst packageJsonContents = readFileSync(\n join(RootFolder, 'package.json'),\n 'utf-8'\n);\nconst packageJson = JSON.parse(packageJsonContents);\n\nconst args = process.argv.slice(2);\n\nconst cli = new Cli({\n binaryLabel: 'crankscript',\n binaryName: 'crankscript',\n binaryVersion: packageJson.version,\n});\n\ncli.register(DoctorCommand);\ncli.register(GenerateTypesCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","DoctorCommand","GenerateTypesCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBN,aACxBC,KAAKI,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIZ,IAAI;IAChBa,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAJ,IAAIK,QAAQ,CAAChB;AACbW,IAAIK,QAAQ,CAACf;AACbU,IAAIM,OAAO,CAACV"}
|
package/src/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { FunctionDeclarationStructure, MethodSignatureStructure, ParameterDeclarationStructure } from 'ts-morph';
|
1
2
|
import { Environment } from './environment/dto/Environment.js';
|
2
3
|
import { PlaydateSdkPath } from './environment/path/dto/PlaydateSdkPath.js';
|
3
4
|
export declare enum PlaydateSdkVersionIdentifier {
|
@@ -38,9 +39,15 @@ export type CheckListItem<TResult> = {
|
|
38
39
|
export interface ParameterDescription {
|
39
40
|
name: string;
|
40
41
|
required: boolean;
|
41
|
-
|
42
|
+
}
|
43
|
+
export interface PropertyDescription {
|
44
|
+
signature: string;
|
45
|
+
name: string;
|
46
|
+
namespaces: string[];
|
47
|
+
docs: string;
|
42
48
|
}
|
43
49
|
export interface FunctionDescription {
|
50
|
+
signature: string;
|
44
51
|
name: string;
|
45
52
|
namespaces: string[];
|
46
53
|
parameters: ParameterDescription[];
|
@@ -58,7 +65,8 @@ export interface ConstantDescription {
|
|
58
65
|
}
|
59
66
|
export interface PlaydateNamespace {
|
60
67
|
functions: FunctionDescription[];
|
61
|
-
|
68
|
+
methods: FunctionDescription[];
|
69
|
+
properties: PropertyDescription[];
|
62
70
|
}
|
63
71
|
export interface PlaydateType {
|
64
72
|
methods: FunctionDescription[];
|
@@ -66,5 +74,28 @@ export interface PlaydateType {
|
|
66
74
|
export interface ApiDefinitions {
|
67
75
|
namespaces: Record<string, PlaydateNamespace>;
|
68
76
|
types: Record<string, PlaydateType>;
|
69
|
-
constants: ConstantDescription[];
|
70
77
|
}
|
78
|
+
export interface ParameterDetails {
|
79
|
+
name: string;
|
80
|
+
type: string;
|
81
|
+
overrideOptions?: Partial<Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>>;
|
82
|
+
}
|
83
|
+
export interface PropertyDetails {
|
84
|
+
signature: string;
|
85
|
+
type: string;
|
86
|
+
isStatic?: boolean;
|
87
|
+
isReadOnly?: boolean;
|
88
|
+
}
|
89
|
+
export interface FunctionDetails {
|
90
|
+
signature: string;
|
91
|
+
parameters: ParameterDetails[];
|
92
|
+
returnType: string;
|
93
|
+
overrideParameters?: boolean;
|
94
|
+
overrideOptions?: Partial<FunctionDeclarationStructure | MethodSignatureStructure>;
|
95
|
+
}
|
96
|
+
export type TypeProviderData = {
|
97
|
+
globalStatements: string[];
|
98
|
+
statements: string[];
|
99
|
+
properties: Record<string, PropertyDetails>;
|
100
|
+
functions: Record<string, FunctionDetails>;
|
101
|
+
};
|
package/src/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n MethodSignatureStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ConstantDescription {\n name: string;\n docs: string;\n values: {\n name: string;\n value: number;\n docs: string;\n }[];\n}\n\nexport interface PlaydateNamespace {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n}\n\nexport interface PlaydateType {\n methods: FunctionDescription[];\n}\n\nexport interface ApiDefinitions {\n namespaces: Record<string, PlaydateNamespace>;\n types: Record<string, PlaydateType>;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodSignatureStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UAQYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}
|
package/src/utils/dirname.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const
|
1
|
+
export declare const __dirname: string;
|
package/src/utils/dirname.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import { dirname
|
1
|
+
import { dirname } from 'node:path';
|
2
2
|
import { fileURLToPath } from 'node:url';
|
3
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
4
|
-
export const RootFolder = join(__dirname, '..', '..');
|
3
|
+
export const __dirname = dirname(fileURLToPath(import.meta.url));
|
5
4
|
|
6
5
|
//# sourceMappingURL=dirname.js.map
|