crankscript 0.11.14 → 0.13.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 +3 -3
- package/src/commands/GenerateTypes/components/GenerateTypes.js +6 -2
- package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +5 -2
- package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.d.ts +11 -0
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +70 -0
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +11 -4
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +5 -35
- package/src/commands/GenerateTypes/types.d.ts +12 -0
- package/src/commands/GenerateTypes/types.js +3 -0
- package/src/commands/GenerateTypes/types.js.map +1 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +7 -37
- package/src/commands/GenerateTypes/utils/createTypeProvider.js +51 -27
- package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
- package/src/commands/NewCommand/components/New.js +25 -2
- package/src/commands/NewCommand/components/New.js.map +1 -1
- package/src/commands/NewLibCommand/NewLibCommand.d.ts +10 -0
- package/src/commands/NewLibCommand/NewLibCommand.js +35 -0
- package/src/commands/NewLibCommand/NewLibCommand.js.map +1 -0
- package/src/commands/NewLibCommand/components/NewLib.d.ts +8 -0
- package/src/commands/NewLibCommand/components/NewLib.js +49 -0
- package/src/commands/NewLibCommand/components/NewLib.js.map +1 -0
- package/src/commands/NewLibCommand/index.d.ts +1 -0
- package/src/commands/NewLibCommand/index.js +3 -0
- package/src/commands/NewLibCommand/index.js.map +1 -0
- package/src/commands/SimulatorCommand/components/Simulator.js +12 -1
- package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +2 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +20 -1
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
- package/src/commands/TranspileCommand/components/Transpile.d.ts +5 -2
- package/src/commands/TranspileCommand/components/Transpile.js +5 -2
- package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/transpile.d.ts +7 -1
- package/src/commands/TranspileCommand/fn/transpile.js +15 -6
- package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +5 -0
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js +22 -0
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -0
- package/src/commands/TranspileCommand/fn/validateExitPoint.d.ts +5 -0
- package/src/commands/TranspileCommand/fn/validateExitPoint.js +26 -0
- package/src/commands/TranspileCommand/fn/validateExitPoint.js.map +1 -0
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +6 -1
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +5 -2
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.d.ts +11 -0
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js +3 -0
- package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js.map +1 -0
- package/src/commands/TranspileCommand/model/ValidatedExitPoint.d.ts +11 -0
- package/src/commands/TranspileCommand/model/ValidatedExitPoint.js +3 -0
- package/src/commands/TranspileCommand/model/ValidatedExitPoint.js.map +1 -0
- package/src/components/CheckList/CheckList.d.ts +3 -3
- package/src/components/CheckList/CheckList.js.map +1 -1
- package/src/components/CheckList/Item.d.ts +1 -1
- package/src/components/CheckList/Item.js +20 -5
- package/src/components/CheckList/Item.js.map +1 -1
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/types.d.ts +20 -16
- package/src/types.js +4 -0
- package/src/types.js.map +1 -1
@@ -1 +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 VariableDeclarationStructure,\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 constants: {},\n statements: [],\n classes: {},\n properties: {},\n dynamicProperties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n constants: fallbackProvider.constants,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n dynamicProperties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\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 getDynamicProperties = (namespace: string) => {\n return (\n provider.dynamicProperties?.[namespace] ??\n fallbackProvider.dynamicProperties?.[namespace] ??\n []\n );\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 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 {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n const options = getFunctionDetails(func).overrideOptions ?? {};\n\n if ('overloads' in options && Array.isArray(options.overloads)) {\n return {\n overloads: options.overloads.map(overload => ({\n ...overload,\n docs: [func.docs],\n })),\n };\n }\n\n return options;\n };\n\n const getConstants = (fullNamespace: string) => {\n return (provider.constants[fullNamespace] ?? []).map(constant => {\n return {\n kind: StructureKind.VariableDeclaration,\n name: typeof constant === 'string' ? constant : constant.name,\n type: typeof constant === 'string' ? 'number' : constant.type,\n } satisfies VariableDeclarationStructure;\n });\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getDynamicProperties,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n getConstants,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","constants","statements","classes","properties","dynamicProperties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getDynamicProperties","namespace","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","options","Array","isArray","overloads","overload","docs","getConstants","fullNamespace","constant","VariableDeclaration","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AwBtB;QAEnC;IACJ;IAEA,MAAM4B,6BAA6B,CAACtB;YAChBD;QAAhB,MAAMwB,UAAUxB,CAAAA,sCAAAA,mBAAmBC,MAAMmB,eAAe,YAAxCpB,sCAA4C,CAAC;QAE7D,IAAI,eAAewB,WAAWC,MAAMC,OAAO,CAACF,QAAQG,SAAS,GAAG;YAC5D,OAAO;gBACHA,WAAWH,QAAQG,SAAS,CAACvB,GAAG,CAACwB,CAAAA,WAAa,aACvCA;wBACHC,MAAM;4BAAC5B,KAAK4B,IAAI;yBAAC;;YAEzB;QACJ;QAEA,OAAOL;IACX;IAEA,MAAMM,eAAe,CAACC;YACVjD;QAAR,OAAO,AAACA,CAAAA,CAAAA,oCAAAA,SAASN,SAAS,CAACuD,cAAc,YAAjCjD,oCAAqC,EAAE,AAAD,EAAGsB,GAAG,CAAC4B,CAAAA;YACjD,OAAO;gBACHd,MAAMzD,cAAcwE,mBAAmB;gBACvC3B,MAAM,OAAO0B,aAAa,WAAWA,WAAWA,SAAS1B,IAAI;gBAC7DV,MAAM,OAAOoC,aAAa,WAAW,WAAWA,SAASpC,IAAI;YACjE;QACJ;IACJ;IAEA,MAAMsC,OAAO;QACT,MAAMC,WAAW9D,KAAK+D,SAAS,CAACtD,UAAU,MAAM,KAAK;QAErDvB,cAAcY,MAAMgE,UAAU;IAClC;IAEA,OAAO;QACH3B;QACAC;QACAvB;QACAE;QACAU;QACAY;QACAC;QACAI;QACAQ;QACAO;QACAI;IACJ;AACJ,EAAE"}
|
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 ParameterDeclarationStructure,\n StructureKind,\n VariableDeclarationStructure,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n FunctionDeclarationOverloadStructure,\n MethodDeclarationOverloadStructure,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\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 constants: {},\n statements: [],\n classes: {},\n properties: {},\n dynamicProperties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n constants: fallbackProvider.constants,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n dynamicProperties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\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 getDynamicProperties = (namespace: string) => {\n return (\n provider.dynamicProperties?.[namespace] ??\n fallbackProvider.dynamicProperties?.[namespace] ??\n []\n );\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 kind: StructureKind.Parameter,\n name: kebabToCamelCase(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 getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string,\n ): ParameterDeclarationStructure => {\n const details = getFunctionDetails(func);\n const param = details.parameters?.find(p => p.name === parameter);\n\n if (!param) {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter),\n type: 'any',\n };\n }\n\n return {\n ...param,\n name: kebabToCamelCase(param.name),\n };\n };\n\n const getParameters = (\n func: FunctionDescription,\n ): ParameterDeclarationStructure[] => {\n const details = getFunctionDetails(func);\n\n if (details.overrideParameters && details.parameters) {\n return details.parameters.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n }));\n }\n\n return func.parameters.map(parameter => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n ...details,\n name: kebabToCamelCase(details.name),\n hasQuestionToken: !parameter.required,\n };\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n const details = getFunctionDetails(func);\n const options: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n > = {};\n\n if (details.kind) {\n options.kind = details.kind;\n }\n\n if (details.typeParameters) {\n options.typeParameters = details.typeParameters;\n }\n\n if ('overloads' in details && Array.isArray(details.overloads)) {\n if (details.kind === StructureKind.Method) {\n options.overloads = details.overloads.map(overload => ({\n ...(overload as MethodDeclarationOverloadStructure),\n typeParameters: overload.typeParameters,\n parameters: overload.parameters?.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n })),\n docs: [func.docs],\n }));\n } else {\n options.overloads = details.overloads.map(overload => ({\n ...(overload as FunctionDeclarationOverloadStructure),\n typeParameters: overload.typeParameters,\n parameters: overload.parameters?.map(param => ({\n ...param,\n name: kebabToCamelCase(param.name),\n })),\n docs: [func.docs],\n }));\n }\n }\n\n return options;\n };\n\n const getConstants = (fullNamespace: string) => {\n return (provider.constants[fullNamespace] ?? []).map(constant => {\n return {\n kind: StructureKind.VariableDeclaration,\n name: typeof constant === 'string' ? constant : constant.name,\n type: typeof constant === 'string' ? 'number' : constant.type,\n } satisfies VariableDeclarationStructure;\n });\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getDynamicProperties,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n getConstants,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","constants","statements","classes","properties","dynamicProperties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getDynamicProperties","namespace","getFunctionDetails","func","fn","parameters","map","p","kind","Parameter","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","hasQuestionToken","required","getFunctionOverrideOptions","options","typeParameters","Array","isArray","overloads","Method","overload","docs","getConstants","fullNamespace","constant","VariableDeclaration","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,AAAD,EAAGsB,GAAG,CAAC4B,CAAAA;YACjD,OAAO;gBACH1B,MAAM7C,cAAcwE,mBAAmB;gBACvCzB,MAAM,OAAOwB,aAAa,WAAWA,WAAWA,SAASxB,IAAI;gBAC7DZ,MAAM,OAAOoC,aAAa,WAAW,WAAWA,SAASpC,IAAI;YACjE;QACJ;IACJ;IAEA,MAAMsC,OAAO;QACT,MAAMC,WAAW9D,KAAK+D,SAAS,CAACtD,UAAU,MAAM,KAAK;QAErDvB,cAAcY,MAAMgE,UAAU;IAClC;IAEA,OAAO;QACHzB;QACAC;QACAzB;QACAE;QACAU;QACAc;QACAC;QACAI;QACAI;QACAS;QACAI;IACJ;AACJ,EAAE"}
|
@@ -1,6 +1,10 @@
|
|
1
|
+
import { exec } from 'node:child_process';
|
2
|
+
import { join } from 'node:path';
|
3
|
+
import { promisify } from 'node:util';
|
1
4
|
import React, { useMemo } from 'react';
|
2
5
|
import tiged from 'tiged';
|
3
6
|
import { CheckList } from '../../../components/CheckList/index.js';
|
7
|
+
const execPromise = promisify(exec);
|
4
8
|
export const New = ({ name, template })=>{
|
5
9
|
const items = useMemo(()=>{
|
6
10
|
return [
|
@@ -14,12 +18,31 @@ export const New = ({ name, template })=>{
|
|
14
18
|
runningDescription: `Creating a new project named "${name}" using the "${template}" template`,
|
15
19
|
finishedDescription: ()=>`Created a new project named "${name}" using the "${template}" template`,
|
16
20
|
errorDescription: `Failed to create project named "${name}" using the "${template}" template`
|
21
|
+
},
|
22
|
+
{
|
23
|
+
ready: true,
|
24
|
+
runner: async ()=>{
|
25
|
+
const projectPath = join(process.cwd(), name);
|
26
|
+
await execPromise(`npm install`, {
|
27
|
+
cwd: projectPath
|
28
|
+
});
|
29
|
+
await execPromise(`npm install --save-exact @crankscript/core@latest @crankscript/types@latest crankscript@latest`, {
|
30
|
+
cwd: projectPath
|
31
|
+
});
|
32
|
+
},
|
33
|
+
waitingDescription: `About to install dependencies for "${name}"`,
|
34
|
+
runningDescription: `Installing dependencies for "${name}"`,
|
35
|
+
finishedDescription: ()=>`Installed dependencies for "${name}"`,
|
36
|
+
errorDescription: `Failed to install dependencies for "${name}"`
|
17
37
|
}
|
18
38
|
];
|
19
|
-
}, [
|
39
|
+
}, [
|
40
|
+
name,
|
41
|
+
template
|
42
|
+
]);
|
20
43
|
return /*#__PURE__*/ React.createElement(CheckList, {
|
21
44
|
items: items,
|
22
|
-
onFinish: ()=>process.exit
|
45
|
+
onFinish: ()=>process.exit()
|
23
46
|
});
|
24
47
|
};
|
25
48
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewCommand/components/New.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, TemplateName } from '@/cli/types.js';\n\ninterface Props {\n name: string;\n template: TemplateName;\n}\n\nexport const New = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new project named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new project named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new project named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create project named \"${name}\" using the \"${template}\" template`,\n },\n ];\n }, []) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["React","useMemo","tiged","CheckList","New","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewCommand/components/New.tsx"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\nimport React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, TemplateName } from '@/cli/types.js';\n\nconst execPromise = promisify(exec);\n\ninterface Props {\n name: string;\n template: TemplateName;\n}\n\nexport const New = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new project named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new project named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new project named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create project named \"${name}\" using the \"${template}\" template`,\n },\n {\n ready: true,\n runner: async () => {\n const projectPath = join(process.cwd(), name);\n\n await execPromise(`npm install`, {\n cwd: projectPath,\n });\n\n await execPromise(\n `npm install --save-exact @crankscript/core@latest @crankscript/types@latest crankscript@latest`,\n {\n cwd: projectPath,\n },\n );\n },\n waitingDescription: `About to install dependencies for \"${name}\"`,\n runningDescription: `Installing dependencies for \"${name}\"`,\n finishedDescription: () =>\n `Installed dependencies for \"${name}\"`,\n errorDescription: `Failed to install dependencies for \"${name}\"`,\n },\n ];\n }, [name, template]) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={() => process.exit()} />;\n};\n"],"names":["exec","join","promisify","React","useMemo","tiged","CheckList","execPromise","New","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","projectPath","process","cwd","onFinish","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AACtC,OAAOC,SAASC,OAAO,QAAQ,QAAQ;AACvC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAGhE,MAAMC,cAAcL,UAAUF;AAO9B,OAAO,MAAMQ,MAAM,CAAC,EAAEC,IAAI,EAAEC,QAAQ,EAAS;IACzC,MAAMC,QAAQP,QAAQ;QAClB,OAAO;YACH;gBACIQ,OAAO;gBACPC,QAAQ;oBACJ,MAAMC,OAAOT,MAAM,CAAC,qBAAqB,EAAEK,SAAS,CAAC;oBAErD,MAAMI,KAAKC,KAAK,CAACN;gBACrB;gBACAO,oBAAoB,CAAC,qCAAqC,EAAEP,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBACpGO,oBAAoB,CAAC,8BAA8B,EAAER,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC7FQ,qBAAqB,IACjB,CAAC,6BAA6B,EAAET,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;gBAC5ES,kBAAkB,CAAC,gCAAgC,EAAEV,KAAK,aAAa,EAAEC,SAAS,UAAU,CAAC;YACjG;YACA;gBACIE,OAAO;gBACPC,QAAQ;oBACJ,MAAMO,cAAcnB,KAAKoB,QAAQC,GAAG,IAAIb;oBAExC,MAAMF,YAAY,CAAC,WAAW,CAAC,EAAE;wBAC7Be,KAAKF;oBACT;oBAEA,MAAMb,YACF,CAAC,8FAA8F,CAAC,EAChG;wBACIe,KAAKF;oBACT;gBAER;gBACAJ,oBAAoB,CAAC,mCAAmC,EAAEP,KAAK,CAAC,CAAC;gBACjEQ,oBAAoB,CAAC,6BAA6B,EAAER,KAAK,CAAC,CAAC;gBAC3DS,qBAAqB,IACjB,CAAC,4BAA4B,EAAET,KAAK,CAAC,CAAC;gBAC1CU,kBAAkB,CAAC,oCAAoC,EAAEV,KAAK,CAAC,CAAC;YACpE;SACH;IACL,GAAG;QAACA;QAAMC;KAAS;IAEnB,qBAAO,oBAACJ;QAAUK,OAAOA;QAAOY,UAAU,IAAMF,QAAQG,IAAI;;AAChE,EAAE"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
3
|
+
import { LibraryTemplateName } from '../../types.js';
|
4
|
+
export declare class NewLibCommand extends RenderableCommand {
|
5
|
+
static paths: string[][];
|
6
|
+
static usage: import("clipanion").Usage;
|
7
|
+
name: string;
|
8
|
+
template: LibraryTemplateName;
|
9
|
+
render(): React.JSX.Element;
|
10
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { Command, Option } from 'clipanion';
|
2
|
+
import React from 'react';
|
3
|
+
import * as t from 'typanion';
|
4
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
5
|
+
import { LibraryTemplateName } from '../../types.js';
|
6
|
+
import { NewLib } from './components/NewLib.js';
|
7
|
+
const defaultTemplate = LibraryTemplateName.Blank;
|
8
|
+
export class NewLibCommand extends RenderableCommand {
|
9
|
+
render() {
|
10
|
+
return /*#__PURE__*/ React.createElement(NewLib, {
|
11
|
+
name: this.name,
|
12
|
+
template: this.template
|
13
|
+
});
|
14
|
+
}
|
15
|
+
constructor(...args){
|
16
|
+
super(...args);
|
17
|
+
this.name = Option.String({
|
18
|
+
name: 'name'
|
19
|
+
});
|
20
|
+
this.template = Option.String('-t,--template', defaultTemplate, {
|
21
|
+
description: `The template to use, defaults to "${defaultTemplate}"`,
|
22
|
+
validator: t.isEnum(LibraryTemplateName)
|
23
|
+
});
|
24
|
+
}
|
25
|
+
}
|
26
|
+
NewLibCommand.paths = [
|
27
|
+
[
|
28
|
+
'new-lib'
|
29
|
+
]
|
30
|
+
];
|
31
|
+
NewLibCommand.usage = Command.Usage({
|
32
|
+
description: 'Create a new crankscript library'
|
33
|
+
});
|
34
|
+
|
35
|
+
//# sourceMappingURL=NewLibCommand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/NewLibCommand/NewLibCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { LibraryTemplateName } from '@/cli/types.js';\nimport { NewLib } from './components/NewLib.js';\n\nconst defaultTemplate = LibraryTemplateName.Blank;\n\nexport class NewLibCommand extends RenderableCommand {\n static override paths = [['new-lib']];\n\n static override usage = Command.Usage({\n description: 'Create a new crankscript library',\n });\n\n name = Option.String({\n name: 'name',\n });\n\n template = Option.String('-t,--template', defaultTemplate, {\n description: `The template to use, defaults to \"${defaultTemplate}\"`,\n validator: t.isEnum(LibraryTemplateName),\n });\n\n override render() {\n return <NewLib name={this.name} template={this.template} />;\n }\n}\n"],"names":["Command","Option","React","t","RenderableCommand","LibraryTemplateName","NewLib","defaultTemplate","Blank","NewLibCommand","render","name","template","String","description","validator","isEnum","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,MAAM,QAAQ,yBAAyB;AAEhD,MAAMC,kBAAkBF,oBAAoBG,KAAK;AAEjD,OAAO,MAAMC,sBAAsBL;IAgBtBM,SAAS;QACd,qBAAO,oBAACJ;YAAOK,MAAM,IAAI,CAACA,IAAI;YAAEC,UAAU,IAAI,CAACA,QAAQ;;IAC3D;;;aAXAD,OAAOV,OAAOY,MAAM,CAAC;YACjBF,MAAM;QACV;aAEAC,WAAWX,OAAOY,MAAM,CAAC,iBAAiBN,iBAAiB;YACvDO,aAAa,CAAC,kCAAkC,EAAEP,gBAAgB,CAAC,CAAC;YACpEQ,WAAWZ,EAAEa,MAAM,CAACX;QACxB;;AAKJ;AAnBaI,cACOQ,QAAQ;IAAC;QAAC;KAAU;CAAC;AAD5BR,cAGOS,QAAQlB,QAAQmB,KAAK,CAAC;IAClCL,aAAa;AACjB"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { exec } from 'node:child_process';
|
2
|
+
import { join } from 'node:path';
|
3
|
+
import { promisify } from 'node:util';
|
4
|
+
import React, { useMemo } from 'react';
|
5
|
+
import tiged from 'tiged';
|
6
|
+
import { CheckList } from '../../../components/CheckList/index.js';
|
7
|
+
const execPromise = promisify(exec);
|
8
|
+
export const NewLib = ({ name, template })=>{
|
9
|
+
const items = useMemo(()=>{
|
10
|
+
return [
|
11
|
+
{
|
12
|
+
ready: true,
|
13
|
+
runner: async ()=>{
|
14
|
+
const task = tiged(`crankscript/lib-template-${template}`);
|
15
|
+
await task.clone(name);
|
16
|
+
},
|
17
|
+
waitingDescription: `About to create a new library named "${name}" using the "${template}" template`,
|
18
|
+
runningDescription: `Creating a new library named "${name}" using the "${template}" template`,
|
19
|
+
finishedDescription: ()=>`Created a new library named "${name}" using the "${template}" template`,
|
20
|
+
errorDescription: `Failed to create library named "${name}" using the "${template}" template`
|
21
|
+
},
|
22
|
+
{
|
23
|
+
ready: true,
|
24
|
+
runner: async ()=>{
|
25
|
+
const projectPath = join(process.cwd(), name);
|
26
|
+
await execPromise(`npm install`, {
|
27
|
+
cwd: projectPath
|
28
|
+
});
|
29
|
+
await execPromise(`npm install --save-exact @crankscript/core@latest @crankscript/types@latest crankscript@latest`, {
|
30
|
+
cwd: projectPath
|
31
|
+
});
|
32
|
+
},
|
33
|
+
waitingDescription: `About to install dependencies for "${name}"`,
|
34
|
+
runningDescription: `Installing dependencies for "${name}"`,
|
35
|
+
finishedDescription: ()=>`Installed dependencies for "${name}"`,
|
36
|
+
errorDescription: `Failed to install dependencies for "${name}"`
|
37
|
+
}
|
38
|
+
];
|
39
|
+
}, [
|
40
|
+
name,
|
41
|
+
template
|
42
|
+
]);
|
43
|
+
return /*#__PURE__*/ React.createElement(CheckList, {
|
44
|
+
items: items,
|
45
|
+
onFinish: ()=>process.exit()
|
46
|
+
});
|
47
|
+
};
|
48
|
+
|
49
|
+
//# sourceMappingURL=NewLib.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/NewLibCommand/components/NewLib.tsx"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\nimport React, { useMemo } from 'react';\nimport tiged from 'tiged';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { CheckListItem, LibraryTemplateName } from '@/cli/types.js';\n\nconst execPromise = promisify(exec);\n\ninterface Props {\n name: string;\n template: LibraryTemplateName;\n}\n\nexport const NewLib = ({ name, template }: Props) => {\n const items = useMemo(() => {\n return [\n {\n ready: true,\n runner: async () => {\n const task = tiged(`crankscript/lib-template-${template}`);\n\n await task.clone(name);\n },\n waitingDescription: `About to create a new library named \"${name}\" using the \"${template}\" template`,\n runningDescription: `Creating a new library named \"${name}\" using the \"${template}\" template`,\n finishedDescription: () =>\n `Created a new library named \"${name}\" using the \"${template}\" template`,\n errorDescription: `Failed to create library named \"${name}\" using the \"${template}\" template`,\n },\n {\n ready: true,\n runner: async () => {\n const projectPath = join(process.cwd(), name);\n\n await execPromise(`npm install`, {\n cwd: projectPath,\n });\n\n await execPromise(\n `npm install --save-exact @crankscript/core@latest @crankscript/types@latest crankscript@latest`,\n {\n cwd: projectPath,\n },\n );\n },\n waitingDescription: `About to install dependencies for \"${name}\"`,\n runningDescription: `Installing dependencies for \"${name}\"`,\n finishedDescription: () =>\n `Installed dependencies for \"${name}\"`,\n errorDescription: `Failed to install dependencies for \"${name}\"`,\n },\n ];\n }, [name, template]) satisfies CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={() => process.exit()} />;\n};\n"],"names":["exec","join","promisify","React","useMemo","tiged","CheckList","execPromise","NewLib","name","template","items","ready","runner","task","clone","waitingDescription","runningDescription","finishedDescription","errorDescription","projectPath","process","cwd","onFinish","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AACtC,OA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AAMF,QAAQG,IAAI;;AAChE,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './NewLibCommand.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/NewLibCommand/index.ts"],"sourcesContent":["export * from './NewLibCommand.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,qBAAqB"}
|
@@ -6,15 +6,26 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
6
6
|
import { getPdcPathFromEnvironment } from '../../../commands/CompileCommand/fn/getPdcPathFromEnvironment.js';
|
7
7
|
import { useCompileTasks } from '../../../commands/CompileCommand/hooks/useCompileTasks.js';
|
8
8
|
import { getSimulatorPathFromEnvironment } from '../../../commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';
|
9
|
+
import { validateEntryPoint } from '../../../commands/TranspileCommand/fn/validateEntryPoint.js';
|
9
10
|
import { useTranspileTasks } from '../../../commands/TranspileCommand/hooks/useTranspileTasks.js';
|
10
11
|
import { CheckList } from '../../../components/CheckList/index.js';
|
11
12
|
import { isMac, isWindows } from '../../../utils/platform.js';
|
13
|
+
import { validateExitPoint } from '../../TranspileCommand/fn/validateExitPoint.js';
|
12
14
|
export const Simulator = ({ environment, path, watch = false, recompileOnly = false, background = false })=>{
|
13
15
|
const watcher = useRef(null);
|
14
16
|
const [isWatching, setIsWatching] = useState(false);
|
15
17
|
const [hasChanged, setHasChanged] = useState(false);
|
16
18
|
const [hasChangedMessage, setHasChangedMessage] = useState(false);
|
17
|
-
const transpileTasks = useTranspileTasks(
|
19
|
+
const transpileTasks = useTranspileTasks({
|
20
|
+
entryPoint: validateEntryPoint({
|
21
|
+
projectPath: path,
|
22
|
+
entryFile: join(path, 'src', 'index.ts')
|
23
|
+
}),
|
24
|
+
exitPoint: validateExitPoint({
|
25
|
+
projectPath: path,
|
26
|
+
exitFile: join(path, 'src', 'index.lua')
|
27
|
+
})
|
28
|
+
});
|
18
29
|
const compileTasks = useCompileTasks(getPdcPathFromEnvironment(environment));
|
19
30
|
const didRun = useRef(false);
|
20
31
|
const [hasFailure, setHasFailure] = useState(false);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { FSWatcher, watch as watchDir } from 'node:fs';\nimport { join } from 'node:path';\nimport { StatusMessage } from '@inkjs/ui';\nimport open from 'open';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { getSimulatorPathFromEnvironment } from '@/cli/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList, CheckListProps } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { isMac, isWindows } from '@/cli/utils/platform.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n recompileOnly?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = false,\n recompileOnly = false,\n background = false,\n}: Props) => {\n const watcher = useRef<FSWatcher | null>(null);\n const [isWatching, setIsWatching] = useState(false);\n const [hasChanged, setHasChanged] = useState(false);\n const [hasChangedMessage, setHasChangedMessage] = useState(false);\n const transpileTasks = useTranspileTasks(path);\n const compileTasks = useCompileTasks(\n getPdcPathFromEnvironment(environment),\n );\n const didRun = useRef(false);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback(\n (hasFailure => {\n setHasFailure(hasFailure);\n if (didRun.current && recompileOnly) {\n return;\n }\n\n didRun.current = true;\n\n open('Game.pdx', {\n background,\n app: isMac\n ? undefined\n : {\n name: getSimulatorPathFromEnvironment(environment),\n },\n }).then(() => {\n if (!watch) {\n if (!isWindows) {\n process.exit();\n }\n\n // Wait for the simulator to start\n // See https://github.com/sindresorhus/open/issues/298\n setTimeout(process.exit, 1000);\n } else {\n setHasChangedMessage(false);\n\n if (watcher.current) {\n watcher.current.close();\n }\n\n setIsWatching(true);\n\n watcher.current = watchDir(\n join(path, 'src'),\n { recursive: true },\n () => {\n setHasChanged(true);\n setHasChangedMessage(true);\n setIsWatching(false);\n },\n );\n }\n });\n }) satisfies CheckListProps['onFinish'],\n [watch, setHasChanged, setIsWatching],\n );\n\n const tasks = useMemo(() => {\n return [...transpileTasks, ...compileTasks];\n }, [transpileTasks, compileTasks]);\n\n return (\n <>\n {!hasChanged && <CheckList items={tasks} onFinish={handleFinish} />}\n {isWatching && !hasChangedMessage && (\n <>\n {hasFailure && (\n <StatusMessage variant=\"warning\">\n Some steps failed.\n </StatusMessage>\n )}\n <StatusMessage variant=\"info\">\n Watching for changes...\n </StatusMessage>\n </>\n )}\n {hasChangedMessage && (\n <StatusMessage variant=\"info\">Change detected</StatusMessage>\n )}\n </>\n );\n};\n"],"names":["watch","watchDir","join","StatusMessage","open","React","useCallback","useEffect","useMemo","useRef","useState","getPdcPathFromEnvironment","useCompileTasks","getSimulatorPathFromEnvironment","useTranspileTasks","CheckList","isMac","isWindows","Simulator","environment","path","recompileOnly","background","watcher","isWatching","setIsWatching","hasChanged","setHasChanged","hasChangedMessage","setHasChangedMessage","transpileTasks","compileTasks","didRun","hasFailure","setHasFailure","handleFinish","current","app","undefined","name","then","process","exit","setTimeout","close","recursive","tasks","items","onFinish","variant"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { FSWatcher, watch as watchDir } from 'node:fs';\nimport { join } from 'node:path';\nimport { StatusMessage } from '@inkjs/ui';\nimport open from 'open';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { getSimulatorPathFromEnvironment } from '@/cli/commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';\nimport { validateEntryPoint } from '@/cli/commands/TranspileCommand/fn/validateEntryPoint.js';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList, CheckListProps } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { isMac, isWindows } from '@/cli/utils/platform.js';\nimport { validateExitPoint } from '../../TranspileCommand/fn/validateExitPoint.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n recompileOnly?: boolean;\n background?: boolean;\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = false,\n recompileOnly = false,\n background = false,\n}: Props) => {\n const watcher = useRef<FSWatcher | null>(null);\n const [isWatching, setIsWatching] = useState(false);\n const [hasChanged, setHasChanged] = useState(false);\n const [hasChangedMessage, setHasChangedMessage] = useState(false);\n const transpileTasks = useTranspileTasks({\n entryPoint: validateEntryPoint({\n projectPath: path,\n entryFile: join(path, 'src', 'index.ts'),\n }),\n exitPoint: validateExitPoint({\n projectPath: path,\n exitFile: join(path, 'src', 'index.lua'),\n }),\n });\n const compileTasks = useCompileTasks(\n getPdcPathFromEnvironment(environment),\n );\n const didRun = useRef(false);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (hasChanged) {\n setHasChanged(false);\n }\n }, [hasChanged, setHasChanged]);\n\n const handleFinish = useCallback(\n (hasFailure => {\n setHasFailure(hasFailure);\n if (didRun.current && recompileOnly) {\n return;\n }\n\n didRun.current = true;\n\n open('Game.pdx', {\n background,\n app: isMac\n ? undefined\n : {\n name: getSimulatorPathFromEnvironment(environment),\n },\n }).then(() => {\n if (!watch) {\n if (!isWindows) {\n process.exit();\n }\n\n // Wait for the simulator to start\n // See https://github.com/sindresorhus/open/issues/298\n setTimeout(process.exit, 1000);\n } else {\n setHasChangedMessage(false);\n\n if (watcher.current) {\n watcher.current.close();\n }\n\n setIsWatching(true);\n\n watcher.current = watchDir(\n join(path, 'src'),\n { recursive: true },\n () => {\n setHasChanged(true);\n setHasChangedMessage(true);\n setIsWatching(false);\n },\n );\n }\n });\n }) satisfies CheckListProps['onFinish'],\n [watch, setHasChanged, setIsWatching],\n );\n\n const tasks = useMemo(() => {\n return [...transpileTasks, ...compileTasks];\n }, [transpileTasks, compileTasks]);\n\n return (\n <>\n {!hasChanged && <CheckList items={tasks} onFinish={handleFinish} />}\n {isWatching && !hasChangedMessage && (\n <>\n {hasFailure && (\n <StatusMessage variant=\"warning\">\n Some steps failed.\n </StatusMessage>\n )}\n <StatusMessage variant=\"info\">\n Watching for changes...\n </StatusMessage>\n </>\n )}\n {hasChangedMessage && (\n <StatusMessage variant=\"info\">Change detected</StatusMessage>\n )}\n </>\n );\n};\n"],"names":["watch","watchDir","join","StatusMessage","open","React","useCallback","useEffect","useMemo","useRef","useState","getPdcPathFromEnvironment","useCompileTasks","getSimulatorPathFromEnvironment","validateEntryPoint","useTranspileTasks","CheckList","isMac","isWindows","validateExitPoint","Simulator","environment","path","recompileOnly","background","watcher","isWatching","setIsWatching","hasChanged","setHasChanged","hasChangedMessage","setHasChangedMessage","transpileTasks","entryPoint","projectPath","entryFile","exitPoint","exitFile","compileTasks","didRun","hasFailure","setHasFailure","handleFinish","current","app","undefined","name","then","process","exit","setTimeout","close","recursive","tasks","items","onFinish","variant"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAoBA,SAASC,QAAQ,Q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GC,cAAcD;QACd,IAAID,OAAOI,OAAO,IAAIpB,eAAe;YACjC;QACJ;QAEAgB,OAAOI,OAAO,GAAG;QAEjBvC,KAAK,YAAY;YACboB;YACAoB,KAAK3B,QACC4B,YACA;gBACIC,MAAMjC,gCAAgCQ;YAC1C;QACV,GAAG0B,IAAI,CAAC;YACJ,IAAI,CAAC/C,OAAO;gBACR,IAAI,CAACkB,WAAW;oBACZ8B,QAAQC,IAAI;gBAChB;gBAEA,kCAAkC;gBAClC,sDAAsD;gBACtDC,WAAWF,QAAQC,IAAI,EAAE;YAC7B,OAAO;gBACHlB,qBAAqB;gBAErB,IAAIN,QAAQkB,OAAO,EAAE;oBACjBlB,QAAQkB,OAAO,CAACQ,KAAK;gBACzB;gBAEAxB,cAAc;gBAEdF,QAAQkB,OAAO,GAAG1C,SACdC,KAAKoB,MAAM,QACX;oBAAE8B,WAAW;gBAAK,GAClB;oBACIvB,cAAc;oBACdE,qBAAqB;oBACrBJ,cAAc;gBAClB;YAER;QACJ;IACJ,GACA;QAAC3B;QAAO6B;QAAeF;KAAc;IAGzC,MAAM0B,QAAQ7C,QAAQ;QAClB,OAAO;eAAIwB;eAAmBM;SAAa;IAC/C,GAAG;QAACN;QAAgBM;KAAa;IAEjC,qBACI,0CACK,CAACV,4BAAc,oBAACZ;QAAUsC,OAAOD;QAAOE,UAAUb;QAClDhB,cAAc,CAACI,mCACZ,0CACKU,4BACG,oBAACrC;QAAcqD,SAAQ;OAAU,qCAIrC,oBAACrD;QAAcqD,SAAQ;OAAO,6BAKrC1B,mCACG,oBAAC3B;QAAcqD,SAAQ;OAAO;AAI9C,EAAE"}
|
@@ -4,6 +4,8 @@ export declare const projectPathOption: string;
|
|
4
4
|
export declare class TranspileCommand extends RenderableCommand {
|
5
5
|
static paths: string[][];
|
6
6
|
static usage: import("clipanion").Usage;
|
7
|
+
entryFile: string;
|
8
|
+
exitFile: string;
|
7
9
|
projectPath: string;
|
8
10
|
render(): React.JSX.Element;
|
9
11
|
}
|
@@ -4,18 +4,37 @@ import React from 'react';
|
|
4
4
|
import * as t from 'typanion';
|
5
5
|
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
6
6
|
import { Transpile } from '../../commands/TranspileCommand/components/Transpile.js';
|
7
|
+
import { validateEntryPoint } from '../../commands/TranspileCommand/fn/validateEntryPoint.js';
|
8
|
+
import { validateExitPoint } from './fn/validateExitPoint.js';
|
7
9
|
export const projectPathOption = Option.String('-p,--path', process.cwd(), {
|
8
10
|
description: `Where to find the project. Defaults to the current working directory ("${process.cwd()}")`,
|
9
11
|
validator: t.isString()
|
10
12
|
});
|
11
13
|
export class TranspileCommand extends RenderableCommand {
|
12
14
|
render() {
|
15
|
+
const validatedEntryPoint = validateEntryPoint({
|
16
|
+
projectPath: this.projectPath,
|
17
|
+
entryFile: this.entryFile
|
18
|
+
});
|
19
|
+
const validatedExitPoint = validateExitPoint({
|
20
|
+
projectPath: this.projectPath,
|
21
|
+
exitFile: this.exitFile
|
22
|
+
});
|
13
23
|
return /*#__PURE__*/ React.createElement(Transpile, {
|
14
|
-
|
24
|
+
entryPoint: validatedEntryPoint,
|
25
|
+
exitPoint: validatedExitPoint
|
15
26
|
});
|
16
27
|
}
|
17
28
|
constructor(...args){
|
18
29
|
super(...args);
|
30
|
+
this.entryFile = Option.String('-i,--input', 'src/index.ts', {
|
31
|
+
description: 'The entry point to transpile',
|
32
|
+
validator: t.isString()
|
33
|
+
});
|
34
|
+
this.exitFile = Option.String('-o,--output', 'Source/main.lua', {
|
35
|
+
description: 'The output bundle',
|
36
|
+
validator: t.isString()
|
37
|
+
});
|
19
38
|
this.projectPath = projectPathOption;
|
20
39
|
}
|
21
40
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n static override usage = Command.Usage({\n description: 'Transpile TypeScript files to Lua',\n });\n\n projectPath = projectPathOption;\n\n override render() {\n
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\nimport { validateEntryPoint } from '@/cli/commands/TranspileCommand/fn/validateEntryPoint.js';\nimport { validateExitPoint } from './fn/validateExitPoint.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n static override usage = Command.Usage({\n description: 'Transpile TypeScript files to Lua',\n });\n\n entryFile = Option.String('-i,--input', 'src/index.ts', {\n description: 'The entry point to transpile',\n validator: t.isString(),\n });\n\n exitFile = Option.String('-o,--output', 'Source/main.lua', {\n description: 'The output bundle',\n validator: t.isString(),\n });\n\n projectPath = projectPathOption;\n\n override render() {\n const validatedEntryPoint = validateEntryPoint({\n projectPath: this.projectPath,\n entryFile: this.entryFile,\n });\n\n const validatedExitPoint = validateExitPoint({\n projectPath: this.projectPath,\n exitFile: this.exitFile,\n });\n\n return (\n <Transpile\n entryPoint={validatedEntryPoint}\n exitPoint={validatedExitPoint}\n />\n );\n }\n}\n"],"names":["process","Command","Option","React","t","RenderableCommand","Transpile","validateEntryPoint","validateExitPoint","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","validatedEntryPoint","projectPath","entryFile","validatedExitPoint","exitFile","entryPoint","exitPoint","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,SAAS,QAAQ,0DAA0D;AACpF,SAASC,kBAAkB,QAAQ,2DAA2D;AAC9F,SAASC,iBAAiB,QAAQ,4BAA4B;AAE9D,OAAO,MAAMC,oBAAoBP,OAAOQ,MAAM,CAAC,aAAaV,QAAQW,GAAG,IAAI;IACvEC,aAAa,CAAC,uEAAuE,EAAEZ,QAAQW,GAAG,GAAG,EAAE,CAAC;IACxGE,WAAWT,EAAEU,QAAQ;AACzB,GAAG;AAEH,OAAO,MAAMC,yBAAyBV;IAmBzBW,SAAS;QACd,MAAMC,sBAAsBV,mBAAmB;YAC3CW,aAAa,IAAI,CAACA,WAAW;YAC7BC,WAAW,IAAI,CAACA,SAAS;QAC7B;QAEA,MAAMC,qBAAqBZ,kBAAkB;YACzCU,aAAa,IAAI,CAACA,WAAW;YAC7BG,UAAU,IAAI,CAACA,QAAQ;QAC3B;QAEA,qBACI,oBAACf;YACGgB,YAAYL;YACZM,WAAWH;;IAGvB;;;aA7BAD,YAAYjB,OAAOQ,MAAM,CAAC,cAAc,gBAAgB;YACpDE,aAAa;YACbC,WAAWT,EAAEU,QAAQ;QACzB;aAEAO,WAAWnB,OAAOQ,MAAM,CAAC,eAAe,mBAAmB;YACvDE,aAAa;YACbC,WAAWT,EAAEU,QAAQ;QACzB;aAEAI,cAAcT;;AAoBlB;AArCaM,iBACOS,QAAQ;IAAC;QAAC;KAAY;CAAC;AAD9BT,iBAGOU,QAAQxB,QAAQyB,KAAK,CAAC;IAClCd,aAAa;AACjB"}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { ValidatedEntryPoint } from '../../../commands/TranspileCommand/model/ValidatedEntryPoint.js';
|
3
|
+
import { ValidatedExitPoint } from '../model/ValidatedExitPoint.js';
|
2
4
|
interface Props {
|
3
|
-
|
5
|
+
entryPoint: ValidatedEntryPoint;
|
6
|
+
exitPoint: ValidatedExitPoint;
|
4
7
|
}
|
5
|
-
export declare const Transpile: ({
|
8
|
+
export declare const Transpile: ({ entryPoint, exitPoint }: Props) => React.JSX.Element;
|
6
9
|
export {};
|
@@ -1,8 +1,11 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useTranspileTasks } from '../../../commands/TranspileCommand/hooks/useTranspileTasks.js';
|
3
3
|
import { CheckList } from '../../../components/CheckList/index.js';
|
4
|
-
export const Transpile = ({
|
5
|
-
const items = useTranspileTasks(
|
4
|
+
export const Transpile = ({ entryPoint, exitPoint })=>{
|
5
|
+
const items = useTranspileTasks({
|
6
|
+
entryPoint,
|
7
|
+
exitPoint
|
8
|
+
});
|
6
9
|
return /*#__PURE__*/ React.createElement(CheckList, {
|
7
10
|
items: items,
|
8
11
|
onFinish: ()=>process.exit
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/components/Transpile.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\n\ninterface Props {\n
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/components/Transpile.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranspileTasks } from '@/cli/commands/TranspileCommand/hooks/useTranspileTasks.js';\nimport { ValidatedEntryPoint } from '@/cli/commands/TranspileCommand/model/ValidatedEntryPoint.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { ValidatedExitPoint } from '../model/ValidatedExitPoint.js';\n\ninterface Props {\n entryPoint: ValidatedEntryPoint;\n exitPoint: ValidatedExitPoint;\n}\n\nexport const Transpile = ({ entryPoint, exitPoint }: Props) => {\n const items = useTranspileTasks({\n entryPoint,\n exitPoint,\n });\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["React","useTranspileTasks","CheckList","Transpile","entryPoint","exitPoint","items","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ,6DAA6D;AAE/F,SAASC,SAAS,QAAQ,sCAAsC;AAQhE,OAAO,MAAMC,YAAY,CAAC,EAAEC,UAAU,EAAEC,SAAS,EAAS;IACtD,MAAMC,QAAQL,kBAAkB;QAC5BG;QACAC;IACJ;IAEA,qBAAO,oBAACH;QAAUI,OAAOA;QAAOC,UAAU,IAAMC,QAAQC,IAAI;;AAChE,EAAE"}
|
@@ -1,2 +1,8 @@
|
|
1
1
|
import * as tstl from 'typescript-to-lua';
|
2
|
-
|
2
|
+
import { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';
|
3
|
+
import { ValidatedExitPoint } from '../model/ValidatedExitPoint.js';
|
4
|
+
export declare const transpile: ({ entryPoint, exitPoint, buildMode, }: {
|
5
|
+
entryPoint: ValidatedEntryPoint;
|
6
|
+
exitPoint: ValidatedExitPoint;
|
7
|
+
buildMode?: tstl.BuildMode;
|
8
|
+
}) => tstl.EmitResult;
|
@@ -1,13 +1,22 @@
|
|
1
|
-
import {
|
1
|
+
import { existsSync } from 'node:fs';
|
2
|
+
import { mkdirSync } from 'node:fs';
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
2
4
|
import * as tstl from 'typescript-to-lua';
|
3
5
|
import { LuaTarget } from 'typescript-to-lua';
|
4
6
|
import { RootFolder } from '../../../constants.js';
|
5
|
-
export const transpile = (
|
6
|
-
|
7
|
+
export const transpile = ({ entryPoint, exitPoint, buildMode = tstl.BuildMode.Default })=>{
|
8
|
+
const exitDir = dirname(exitPoint.exitPath);
|
9
|
+
if (!existsSync(exitDir)) {
|
10
|
+
mkdirSync(exitDir, {
|
11
|
+
recursive: true
|
12
|
+
});
|
13
|
+
}
|
14
|
+
return tstl.transpileProject(join(entryPoint.projectPath, 'tsconfig.json'), {
|
15
|
+
buildMode,
|
7
16
|
luaTarget: LuaTarget.Lua54,
|
8
|
-
outDir:
|
9
|
-
luaBundle:
|
10
|
-
luaBundleEntry: join(
|
17
|
+
outDir: dirname(exitPoint.exitPath),
|
18
|
+
luaBundle: basename(exitPoint.exitPath),
|
19
|
+
luaBundleEntry: join(entryPoint.entryFile),
|
11
20
|
luaPlugins: [
|
12
21
|
{
|
13
22
|
name: join(RootFolder, 'assets', 'index.js')
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/transpile.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as tstl from 'typescript-to-lua';\nimport { LuaTarget } from 'typescript-to-lua';\nimport { RootFolder } from '@/cli/constants.js';\n\nexport const transpile = (
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/transpile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdirSync } from 'node:fs';\nimport { basename, dirname, join } from 'node:path';\nimport * as tstl from 'typescript-to-lua';\nimport { LuaTarget } from 'typescript-to-lua';\nimport { RootFolder } from '@/cli/constants.js';\nimport { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';\nimport { ValidatedExitPoint } from '../model/ValidatedExitPoint.js';\n\nexport const transpile = ({\n entryPoint,\n exitPoint,\n buildMode = tstl.BuildMode.Default,\n}: {\n entryPoint: ValidatedEntryPoint;\n exitPoint: ValidatedExitPoint;\n buildMode?: tstl.BuildMode;\n}) => {\n const exitDir = dirname(exitPoint.exitPath);\n\n if (!existsSync(exitDir)) {\n mkdirSync(exitDir, { recursive: true });\n }\n\n return tstl.transpileProject(\n join(entryPoint.projectPath, 'tsconfig.json'),\n {\n buildMode,\n luaTarget: LuaTarget.Lua54,\n outDir: dirname(exitPoint.exitPath),\n luaBundle: basename(exitPoint.exitPath),\n luaBundleEntry: join(entryPoint.entryFile),\n luaPlugins: [\n {\n name: join(RootFolder, 'assets', 'index.js'),\n },\n ],\n },\n );\n};\n"],"names":["existsSync","mkdirSync","basename","dirname","join","tstl","LuaTarget","RootFolder","transpile","entryPoint","exitPoint","buildMode","BuildMode","Default","exitDir","exitPath","recursive","transpileProject","projectPath","luaTarget","Lua54","outDir","luaBundle","luaBundleEntry","entryFile","luaPlugins","name"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,SAAS,QAAQ,UAAU;AACpC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AACpD,YAAYC,UAAU,oBAAoB;AAC1C,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,UAAU,QAAQ,qBAAqB;AAIhD,OAAO,MAAMC,YAAY,CAAC,EACtBC,UAAU,EACVC,SAAS,EACTC,YAAYN,KAAKO,SAAS,CAACC,OAAO,EAKrC;IACG,MAAMC,UAAUX,QAAQO,UAAUK,QAAQ;IAE1C,IAAI,CAACf,WAAWc,UAAU;QACtBb,UAAUa,SAAS;YAAEE,WAAW;QAAK;IACzC;IAEA,OAAOX,KAAKY,gBAAgB,CACxBb,KAAKK,WAAWS,WAAW,EAAE,kBAC7B;QACIP;QACAQ,WAAWb,UAAUc,KAAK;QAC1BC,QAAQlB,QAAQO,UAAUK,QAAQ;QAClCO,WAAWpB,SAASQ,UAAUK,QAAQ;QACtCQ,gBAAgBnB,KAAKK,WAAWe,SAAS;QACzCC,YAAY;YACR;gBACIC,MAAMtB,KAAKG,YAAY,UAAU;YACrC;SACH;IACL;AAER,EAAE"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
2
|
+
import { resolve } from 'node:path';
|
3
|
+
export const validateEntryPoint = (input)=>{
|
4
|
+
const resolvedPath = resolve(input.projectPath);
|
5
|
+
const resolvedEntry = resolve(input.entryFile);
|
6
|
+
if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {
|
7
|
+
throw new Error(`"${resolvedPath}" is not a valid project path`);
|
8
|
+
}
|
9
|
+
if (!existsSync(resolvedEntry) || !statSync(resolvedEntry).isFile()) {
|
10
|
+
throw new Error(`"${resolvedEntry}" is not a valid entry file`);
|
11
|
+
}
|
12
|
+
if (!resolvedEntry.startsWith(resolvedPath)) {
|
13
|
+
throw new Error(`Entry must be inside project path`);
|
14
|
+
}
|
15
|
+
return {
|
16
|
+
__validated: true,
|
17
|
+
projectPath: resolvedPath,
|
18
|
+
entryFile: resolvedEntry
|
19
|
+
};
|
20
|
+
};
|
21
|
+
|
22
|
+
//# sourceMappingURL=validateEntryPoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/validateEntryPoint.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { ValidatedEntryPoint } from '../model/ValidatedEntryPoint.js';\n\nexport const validateEntryPoint = (input: {\n projectPath: string;\n entryFile: string;\n}): ValidatedEntryPoint => {\n const resolvedPath = resolve(input.projectPath);\n const resolvedEntry = resolve(input.entryFile);\n\n if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {\n throw new Error(`\"${resolvedPath}\" is not a valid project path`);\n }\n\n if (!existsSync(resolvedEntry) || !statSync(resolvedEntry).isFile()) {\n throw new Error(`\"${resolvedEntry}\" is not a valid entry file`);\n }\n\n if (!resolvedEntry.startsWith(resolvedPath)) {\n throw new Error(`Entry must be inside project path`);\n }\n\n return {\n __validated: true,\n projectPath: resolvedPath,\n entryFile: resolvedEntry,\n } satisfies ValidatedEntryPoint;\n};\n"],"names":["existsSync","statSync","resolve","validateEntryPoint","input","resolvedPath","projectPath","resolvedEntry","entryFile","isDirectory","Error","isFile","startsWith","__validated"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,UAAU;AAC/C,SAASC,OAAO,QAAQ,YAAY;AAGpC,OAAO,MAAMC,qBAAqB,CAACC;IAI/B,MAAMC,eAAeH,QAAQE,MAAME,WAAW;IAC9C,MAAMC,gBAAgBL,QAAQE,MAAMI,SAAS;IAE7C,IAAI,CAACR,WAAWK,iBAAiB,CAACJ,SAASI,cAAcI,WAAW,IAAI;QACpE,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEL,aAAa,6BAA6B,CAAC;IACnE;IAEA,IAAI,CAACL,WAAWO,kBAAkB,CAACN,SAASM,eAAeI,MAAM,IAAI;QACjE,MAAM,IAAID,MAAM,CAAC,CAAC,EAAEH,cAAc,2BAA2B,CAAC;IAClE;IAEA,IAAI,CAACA,cAAcK,UAAU,CAACP,eAAe;QACzC,MAAM,IAAIK,MAAM,CAAC,iCAAiC,CAAC;IACvD;IAEA,OAAO;QACHG,aAAa;QACbP,aAAaD;QACbG,WAAWD;IACf;AACJ,EAAE"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
2
|
+
import { resolve, dirname } from 'node:path';
|
3
|
+
export const validateExitPoint = (input)=>{
|
4
|
+
const resolvedPath = resolve(input.projectPath);
|
5
|
+
const resolvedExit = resolve(input.exitFile);
|
6
|
+
const exitDir = dirname(resolvedExit);
|
7
|
+
if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {
|
8
|
+
throw new Error(`"${resolvedPath}" is not a valid project path`);
|
9
|
+
}
|
10
|
+
if (!existsSync(exitDir)) {
|
11
|
+
// Will be created
|
12
|
+
} else if (!statSync(exitDir).isDirectory()) {
|
13
|
+
throw new Error(`"${exitDir}" exists but is not a directory`);
|
14
|
+
}
|
15
|
+
// Check if the parent directory is inside the project path
|
16
|
+
if (!exitDir.startsWith(resolvedPath)) {
|
17
|
+
throw new Error(`Exit path must be inside project path`);
|
18
|
+
}
|
19
|
+
return {
|
20
|
+
__validated: true,
|
21
|
+
projectPath: resolvedPath,
|
22
|
+
exitPath: resolvedExit
|
23
|
+
};
|
24
|
+
};
|
25
|
+
|
26
|
+
//# sourceMappingURL=validateExitPoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/fn/validateExitPoint.ts"],"sourcesContent":["import { existsSync, statSync } from 'node:fs';\nimport { resolve, dirname } from 'node:path';\nimport { ValidatedExitPoint } from '../model/ValidatedExitPoint.js';\n\nexport const validateExitPoint = (input: {\n projectPath: string;\n exitFile: string;\n}): ValidatedExitPoint => {\n const resolvedPath = resolve(input.projectPath);\n const resolvedExit = resolve(input.exitFile);\n const exitDir = dirname(resolvedExit);\n\n if (!existsSync(resolvedPath) || !statSync(resolvedPath).isDirectory()) {\n throw new Error(`\"${resolvedPath}\" is not a valid project path`);\n }\n\n if (!existsSync(exitDir)) {\n // Will be created\n } else if (!statSync(exitDir).isDirectory()) {\n throw new Error(`\"${exitDir}\" exists but is not a directory`);\n }\n\n // Check if the parent directory is inside the project path\n if (!exitDir.startsWith(resolvedPath)) {\n throw new Error(`Exit path must be inside project path`);\n }\n\n return {\n __validated: true,\n projectPath: resolvedPath,\n exitPath: resolvedExit,\n } satisfies ValidatedExitPoint;\n};\n"],"names":["existsSync","statSync","resolve","dirname","validateExitPoint","input","resolvedPath","projectPath","resolvedExit","exitFile","exitDir","isDirectory","Error","startsWith","__validated","exitPath"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,UAAU;AAC/C,SAASC,OAAO,EAAEC,OAAO,QAAQ,YAAY;AAG7C,OAAO,MAAMC,oBAAoB,CAACC;IAI9B,MAAMC,eAAeJ,QAAQG,MAAME,WAAW;IAC9C,MAAMC,eAAeN,QAAQG,MAAMI,QAAQ;IAC3C,MAAMC,UAAUP,QAAQK;IAExB,IAAI,CAACR,WAAWM,iBAAiB,CAACL,SAASK,cAAcK,WAAW,IAAI;QACpE,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEN,aAAa,6BAA6B,CAAC;IACnE;IAEA,IAAI,CAACN,WAAWU,UAAU;IACtB,kBAAkB;IACtB,OAAO,IAAI,CAACT,SAASS,SAASC,WAAW,IAAI;QACzC,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEF,QAAQ,+BAA+B,CAAC;IAChE;IAEA,2DAA2D;IAC3D,IAAI,CAACA,QAAQG,UAAU,CAACP,eAAe;QACnC,MAAM,IAAIM,MAAM,CAAC,qCAAqC,CAAC;IAC3D;IAEA,OAAO;QACHE,aAAa;QACbP,aAAaD;QACbS,UAAUP;IACd;AACJ,EAAE"}
|
@@ -1,2 +1,7 @@
|
|
1
|
+
import { ValidatedEntryPoint } from '../../../commands/TranspileCommand/model/ValidatedEntryPoint.js';
|
2
|
+
import { ValidatedExitPoint } from '../../../commands/TranspileCommand/model/ValidatedExitPoint.js';
|
1
3
|
import { CheckListItem } from '../../../types.js';
|
2
|
-
export declare const useTranspileTasks: (
|
4
|
+
export declare const useTranspileTasks: ({ entryPoint, exitPoint, }: {
|
5
|
+
entryPoint: ValidatedEntryPoint;
|
6
|
+
exitPoint: ValidatedExitPoint;
|
7
|
+
}) => CheckListItem<unknown>[];
|