crankscript 0.13.1 → 0.15.1
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/package.json +32 -31
- package/src/commands/CompileCommand/components/Compile.js +3 -1
- package/src/commands/CompileCommand/components/Compile.js.map +1 -1
- package/src/commands/CompileCommand/hooks/useCompileTasks.d.ts +6 -1
- package/src/commands/CompileCommand/hooks/useCompileTasks.js +2 -2
- package/src/commands/CompileCommand/hooks/useCompileTasks.js.map +1 -1
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +1 -0
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +25 -1
- package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js.map +1 -1
- package/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.d.ts +11 -0
- package/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js +20 -0
- package/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js.map +1 -0
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +4 -4
- package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -1
- package/src/commands/SimulatorCommand/SimulatorCommand.d.ts +2 -0
- package/src/commands/SimulatorCommand/SimulatorCommand.js +27 -3
- package/src/commands/SimulatorCommand/SimulatorCommand.js.map +1 -1
- package/src/commands/SimulatorCommand/components/Simulator.d.ts +3 -1
- package/src/commands/SimulatorCommand/components/Simulator.js +20 -84
- package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
- package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.d.ts +7 -0
- package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.js +43 -0
- package/src/commands/SimulatorCommand/components/TemporaryFolderCreator.js.map +1 -0
- package/src/commands/SimulatorCommand/fn/createTemporaryFolderPathFromEntryFile.d.ts +1 -0
- package/src/commands/SimulatorCommand/fn/createTemporaryFolderPathFromEntryFile.js +9 -0
- package/src/commands/SimulatorCommand/fn/createTemporaryFolderPathFromEntryFile.js.map +1 -0
- package/src/commands/SimulatorCommand/hooks/useFileWatcher.d.ts +6 -0
- package/src/commands/SimulatorCommand/hooks/useFileWatcher.js +37 -0
- package/src/commands/SimulatorCommand/hooks/useFileWatcher.js.map +1 -0
- package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.d.ts +22 -0
- package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.js +109 -0
- package/src/commands/SimulatorCommand/hooks/useSimulatorTasks.js.map +1 -0
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +2 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +10 -4
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
- package/src/commands/TranspileCommand/components/Transpile.d.ts +2 -1
- package/src/commands/TranspileCommand/components/Transpile.js +3 -2
- package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/transpile.d.ts +3 -2
- package/src/commands/TranspileCommand/fn/transpile.js +18 -2
- package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
- package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +2 -1
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js +19 -9
- package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -1
- package/src/commands/TranspileCommand/fn/validateExitPoint.d.ts +2 -1
- package/src/commands/TranspileCommand/fn/validateExitPoint.js +16 -10
- package/src/commands/TranspileCommand/fn/validateExitPoint.js.map +1 -1
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +4 -1
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +28 -4
- package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
- package/src/commands/TranspileCommand/types.d.ts +4 -0
- package/src/commands/TranspileCommand/types.js +7 -0
- package/src/commands/TranspileCommand/types.js.map +1 -0
- package/src/components/CheckList/Item.js +8 -2
- package/src/components/CheckList/Item.js.map +1 -1
- package/src/components/ErrorBoundary.js +28 -0
- package/src/components/ErrorBoundary.js.map +1 -0
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
@@ -1,7 +1,16 @@
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
2
|
+
import { basename, dirname, join } from 'node:path';
|
1
3
|
import { useMemo } from 'react';
|
2
4
|
import { getErrorMessage } from '../../../commands/TranspileCommand/fn/getErrorMessage.js';
|
3
5
|
import { transpile } from '../../../commands/TranspileCommand/fn/transpile.js';
|
4
|
-
|
6
|
+
import { TranspileMode } from '../types.js';
|
7
|
+
const getToyboxTemplate = (namespace, entryPoint)=>`${namespace} = ${namespace} or {}
|
8
|
+
local ____exports = import("${entryPoint}")
|
9
|
+
for k, v in pairs(____exports) do
|
10
|
+
${namespace}[k] = v
|
11
|
+
end
|
12
|
+
`;
|
13
|
+
export const useTranspileTasks = ({ entryPoint, exitPoint, toybox, transpileMode = TranspileMode.Project })=>{
|
5
14
|
return useMemo(()=>[
|
6
15
|
{
|
7
16
|
waitingDescription: 'Waiting to transpile code...',
|
@@ -11,7 +20,8 @@ export const useTranspileTasks = ({ entryPoint, exitPoint })=>{
|
|
11
20
|
runner: async ()=>{
|
12
21
|
const result = transpile({
|
13
22
|
entryPoint,
|
14
|
-
exitPoint
|
23
|
+
exitPoint,
|
24
|
+
transpileMode
|
15
25
|
});
|
16
26
|
if (result.diagnostics.length > 0) {
|
17
27
|
const errors = getErrorMessage(result.diagnostics);
|
@@ -20,8 +30,22 @@ export const useTranspileTasks = ({ entryPoint, exitPoint })=>{
|
|
20
30
|
},
|
21
31
|
ready: true,
|
22
32
|
quitOnError: false
|
23
|
-
}
|
24
|
-
|
33
|
+
},
|
34
|
+
...toybox ? [
|
35
|
+
{
|
36
|
+
waitingDescription: 'Waiting to create toybox import file...',
|
37
|
+
errorDescription: 'Could not create toybox import file',
|
38
|
+
runningDescription: 'Creating toybox import file...',
|
39
|
+
finishedDescription: ()=>'Toybox import file created',
|
40
|
+
runner: async ()=>{
|
41
|
+
const template = getToyboxTemplate(toybox, basename(exitPoint.exitPath));
|
42
|
+
writeFileSync(join(dirname(exitPoint.exitPath), 'import.lua'), template);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
] : []
|
46
|
+
], [
|
47
|
+
toybox
|
48
|
+
]);
|
25
49
|
};
|
26
50
|
|
27
51
|
//# sourceMappingURL=useTranspileTasks.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/hooks/useTranspileTasks.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { getErrorMessage } from '@/cli/commands/TranspileCommand/fn/getErrorMessage.js';\nimport { transpile } from '@/cli/commands/TranspileCommand/fn/transpile.js';\nimport { ValidatedEntryPoint } from '@/cli/commands/TranspileCommand/model/ValidatedEntryPoint.js';\nimport { ValidatedExitPoint } from '@/cli/commands/TranspileCommand/model/ValidatedExitPoint.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useTranspileTasks = ({\n entryPoint,\n exitPoint,\n}: {\n entryPoint: ValidatedEntryPoint;\n exitPoint: ValidatedExitPoint;\n}) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to transpile code...',\n errorDescription: 'Could not transpile code',\n runningDescription: 'Transpiling code...',\n finishedDescription: () => 'Code transpiled',\n runner: async () => {\n const result = transpile({\n entryPoint,\n exitPoint,\n });\n\n if (result.diagnostics.length > 0) {\n const errors = getErrorMessage(result.diagnostics);\n\n throw new Error(\n `${\n result.diagnostics.length === 1\n ? 'An error'\n : 'Errors'\n } occurred while transpiling the code:\\n${errors}`,\n );\n }\n },\n ready: true,\n quitOnError: false,\n },\n ],\n [],\n ) as CheckListItem<unknown>[];\n};\n"],"names":["useMemo","getErrorMessage","transpile","
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/hooks/useTranspileTasks.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { basename, dirname, join } from 'node:path';\nimport { useMemo } from 'react';\nimport { getErrorMessage } from '@/cli/commands/TranspileCommand/fn/getErrorMessage.js';\nimport { transpile } from '@/cli/commands/TranspileCommand/fn/transpile.js';\nimport { ValidatedEntryPoint } from '@/cli/commands/TranspileCommand/model/ValidatedEntryPoint.js';\nimport { ValidatedExitPoint } from '@/cli/commands/TranspileCommand/model/ValidatedExitPoint.js';\nimport { CheckListItem } from '@/cli/types.js';\nimport { TranspileMode } from '../types.js';\n\nconst getToyboxTemplate = (\n namespace: string,\n entryPoint: string,\n) => `${namespace} = ${namespace} or {}\nlocal ____exports = import(\"${entryPoint}\")\nfor k, v in pairs(____exports) do\n ${namespace}[k] = v\nend\n`;\n\nexport const useTranspileTasks = ({\n entryPoint,\n exitPoint,\n toybox,\n transpileMode = TranspileMode.Project,\n}: {\n entryPoint: ValidatedEntryPoint;\n exitPoint: ValidatedExitPoint;\n toybox?: string;\n transpileMode?: TranspileMode;\n}) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to transpile code...',\n errorDescription: 'Could not transpile code',\n runningDescription: 'Transpiling code...',\n finishedDescription: () => 'Code transpiled',\n runner: async () => {\n const result = transpile({\n entryPoint,\n exitPoint,\n transpileMode,\n });\n\n if (result.diagnostics.length > 0) {\n const errors = getErrorMessage(result.diagnostics);\n\n throw new Error(\n `${\n result.diagnostics.length === 1\n ? 'An error'\n : 'Errors'\n } occurred while transpiling the code:\\n${errors}`,\n );\n }\n },\n ready: true,\n quitOnError: false,\n },\n ...(toybox\n ? [\n {\n waitingDescription:\n 'Waiting to create toybox import file...',\n errorDescription:\n 'Could not create toybox import file',\n runningDescription: 'Creating toybox import file...',\n finishedDescription: () =>\n 'Toybox import file created',\n runner: async () => {\n const template = getToyboxTemplate(\n toybox,\n basename(exitPoint.exitPath),\n );\n\n writeFileSync(\n join(\n dirname(exitPoint.exitPath),\n 'import.lua',\n ),\n template,\n );\n },\n },\n ]\n : []),\n ],\n [toybox],\n ) as CheckListItem<unknown>[];\n};\n"],"names":["writeFileSync","basename","dirname","join","useMemo","getErrorMessage","transpile","TranspileMode","getToyboxTemplate","namespace","entryPoint","useTranspileTasks","exitPoint","toybox","transpileMode","Project","waitingDescription","errorDescription","runningDescription","finishedDescription","runner","result","diagnostics","length","errors","Error","ready","quitOnError","template","exitPath"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AACpD,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,eAAe,QAAQ,wDAAwD;AACxF,SAASC,SAAS,QAAQ,kDAAkD;AAI5E,SAASC,aAAa,QAAQ,cAAc;AAE5C,MAAMC,oBAAoB,CACtBC,WACAC,aACC,CAAC,EAAED,UAAU,GAAG,EAAEA,UAAU;4BACL,EAAEC,WAAW;;EAEvC,EAAED,UAAU;;AAEd,CAAC;AAED,OAAO,MAAME,oBAAoB,CAAC,EAC9BD,UAAU,EACVE,SAAS,EACTC,MAAM,EACNC,gBAAgBP,cAAcQ,OAAO,EAMxC;IACG,OAAOX,QACH,IAAM;YACF;gBACIY,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJ,MAAMC,SAASf,UAAU;wBACrBI;wBACAE;wBACAE;oBACJ;oBAEA,IAAIO,OAAOC,WAAW,CAACC,MAAM,GAAG,GAAG;wBAC/B,MAAMC,SAASnB,gBAAgBgB,OAAOC,WAAW;wBAEjD,MAAM,IAAIG,MACN,CAAC,EACGJ,OAAOC,WAAW,CAACC,MAAM,KAAK,IACxB,aACA,SACT,uCAAuC,EAAEC,OAAO,CAAC;oBAE1D;gBACJ;gBACAE,OAAO;gBACPC,aAAa;YACjB;eACId,SACE;gBACI;oBACIG,oBACI;oBACJC,kBACI;oBACJC,oBAAoB;oBACpBC,qBAAqB,IACjB;oBACJC,QAAQ;wBACJ,MAAMQ,WAAWpB,kBACbK,QACAZ,SAASW,UAAUiB,QAAQ;wBAG/B7B,cACIG,KACID,QAAQU,UAAUiB,QAAQ,GAC1B,eAEJD;oBAER;gBACJ;aACH,GACD,EAAE;SACX,EACD;QAACf;KAAO;AAEhB,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/types.ts"],"sourcesContent":["export enum TranspileMode {\n Project = 'Project',\n File = 'File',\n}\n"],"names":["TranspileMode"],"rangeMappings":";;;;","mappings":";UAAYA;;;GAAAA,kBAAAA"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { StatusMessage } from '@inkjs/ui';
|
2
2
|
import { Text } from 'ink';
|
3
3
|
import React, { useEffect, useRef, useState } from 'react';
|
4
|
+
import { useCrankScriptContext } from '../../commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js';
|
4
5
|
import { Spinner } from '../../components/Spinner.js';
|
5
6
|
export const Item = ({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, skipDescription, runner, onFinish, ready, quitOnError = true, skip }, start })=>{
|
6
7
|
const executed = useRef(false);
|
@@ -8,7 +9,9 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
|
|
8
9
|
const [dotCount, setDotCount] = useState(0);
|
9
10
|
const [result, setResult] = useState(null);
|
10
11
|
const [failedReason, setfailedReason] = useState(null);
|
12
|
+
const [failedDetails, setFailedDetails] = useState(null);
|
11
13
|
const [isSkipped, setIsSkipped] = useState(false);
|
14
|
+
const { verbose } = useCrankScriptContext();
|
12
15
|
// Determine if the task should be skipped
|
13
16
|
const shouldSkip = typeof skip === 'function' ? skip() : skip === true;
|
14
17
|
const hasResult = !failedReason && result !== null;
|
@@ -62,7 +65,8 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
|
|
62
65
|
setResult(result);
|
63
66
|
onFinish == null ? void 0 : onFinish(result);
|
64
67
|
}).catch((reason)=>{
|
65
|
-
setfailedReason(reason.message);
|
68
|
+
setfailedReason(reason instanceof Error ? reason.message : 'Unknown error');
|
69
|
+
setFailedDetails(reason instanceof Error && reason.stack ? reason.stack : null);
|
66
70
|
setResult(false);
|
67
71
|
onFinish == null ? void 0 : onFinish(false);
|
68
72
|
});
|
@@ -98,7 +102,9 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
|
|
98
102
|
}, /*#__PURE__*/ React.createElement(Text, {
|
99
103
|
bold: !isWaiting,
|
100
104
|
color: isRunning ? 'yellow' : isWaiting ? 'gray' : failedReason ? 'red' : isSkipped ? 'gray' : 'green'
|
101
|
-
}, message, ' ', couldStartButNotReady && `— not ready yet${'.'.repeat(dotCount)}
|
105
|
+
}, message, ' ', couldStartButNotReady && `— not ready yet${'.'.repeat(dotCount)}`, verbose && failedDetails && /*#__PURE__*/ React.createElement(Text, {
|
106
|
+
color: "red"
|
107
|
+
}, failedDetails)));
|
102
108
|
};
|
103
109
|
|
104
110
|
//# sourceMappingURL=Item.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Spinner } from '@/cli/components/Spinner.js';\nimport { CheckListItem } from '@/cli/types.js';\
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/Item.tsx"],"sourcesContent":["import { StatusMessage, StatusMessageProps } from '@inkjs/ui';\nimport { Text } from 'ink';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { useCrankScriptContext } from '@/cli/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.js';\nimport { Spinner } from '@/cli/components/Spinner.js';\nimport { CheckListItem } from '@/cli/types.js';\nexport interface ItemProps<TResult> {\n item: CheckListItem<TResult>;\n start: boolean;\n}\n\nexport const Item = <TResult,>({\n item: {\n runningDescription,\n waitingDescription,\n errorDescription,\n finishedDescription,\n skipDescription,\n runner,\n onFinish,\n ready,\n quitOnError = true,\n skip,\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 | false>(null);\n const [failedReason, setfailedReason] = useState<string | null>(null);\n const [failedDetails, setFailedDetails] = useState<string | null>(null);\n const [isSkipped, setIsSkipped] = useState(false);\n const { verbose } = useCrankScriptContext();\n\n // Determine if the task should be skipped\n const shouldSkip = typeof skip === 'function' ? skip() : skip === true;\n\n const hasResult = !failedReason && result !== null;\n const isRunning =\n !failedReason && !hasResult && start && ready !== false && !shouldSkip;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason && quitOnError) {\n process.exit(1);\n }\n }, [failedReason, quitOnError]);\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 // If the task should be skipped, mark it as executed with a success result\n if (shouldSkip) {\n executed.current = true;\n setIsSkipped(true);\n setResult(true as TResult);\n onFinish?.(true as TResult);\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: unknown) => {\n setfailedReason(\n reason instanceof Error ? reason.message : 'Unknown error',\n );\n setFailedDetails(\n reason instanceof Error && reason.stack\n ? reason.stack\n : null,\n );\n setResult(false);\n onFinish?.(false);\n });\n }, [errorDescription, onFinish, runner, start, shouldSkip]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isSkipped) {\n message = skipDescription || 'Task skipped';\n variant = 'info';\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 <Spinner label={message} />;\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 : isSkipped\n ? 'gray'\n : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n {verbose && failedDetails && (\n <Text color=\"red\">{failedDetails}</Text>\n )}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Text","React","useEffect","useRef","useState","useCrankScriptContext","Spinner","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","skipDescription","runner","onFinish","ready","quitOnError","skip","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","failedDetails","setFailedDetails","isSkipped","setIsSkipped","verbose","shouldSkip","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","Error","message","stack","variant","label","bold","color","repeat"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAA4B,YAAY;AAC9D,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC3D,SAASC,qBAAqB,QAAQ,wEAAwE;AAC9G,SAASC,OAAO,QAAQ,8BAA8B;AAOtD,OAAO,MAAMC,OA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Ae,EAAE,IAAIiB,MAAM,CAAChC,UAAU,CAAC,EAC3CU,WAAWJ,+BACR,oBAAC5B;QAAKqD,OAAM;OAAOzB;AAKvC,EAAE"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { StatusMessage } from '@inkjs/ui';
|
2
|
+
import { Text } from 'ink';
|
3
|
+
import React, { Component } from 'react';
|
4
|
+
export class ErrorBoundary extends Component {
|
5
|
+
static getDerivedStateFromError(error) {
|
6
|
+
return {
|
7
|
+
error
|
8
|
+
};
|
9
|
+
}
|
10
|
+
render() {
|
11
|
+
const { verbose } = this.props;
|
12
|
+
const { error } = this.state;
|
13
|
+
if (!error) {
|
14
|
+
return this.props.children;
|
15
|
+
}
|
16
|
+
return /*#__PURE__*/ React.createElement(StatusMessage, {
|
17
|
+
variant: "error"
|
18
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
19
|
+
color: "red"
|
20
|
+
}, verbose ? error.stack : error.message));
|
21
|
+
}
|
22
|
+
constructor(...args){
|
23
|
+
super(...args);
|
24
|
+
this.state = {};
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/cli/src/components/ErrorBoundary.tsx"],"sourcesContent":["import { StatusMessage } from '@inkjs/ui';\nimport { Text } from 'ink';\nimport React, { Component, ReactNode } from 'react';\n\ninterface State {\n error?: Error;\n}\n\ninterface Props {\n verbose: boolean;\n children: ReactNode;\n}\n\nexport class ErrorBoundary extends Component<Props, State> {\n override state = {} as State;\n\n static getDerivedStateFromError(error: Error): Partial<State> {\n return { error };\n }\n\n override render() {\n const { verbose } = this.props;\n const { error } = this.state;\n\n if (!error) {\n return this.props.children;\n }\n\n return (\n <StatusMessage variant=\"error\">\n <Text color=\"red\">{verbose ? error.stack : error.message}</Text>\n </StatusMessage>\n );\n }\n}\n"],"names":["StatusMessage","Text","React","Component","ErrorBoundary","getDerivedStateFromError","error","render","verbose","props","state","children","variant","color","stack","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY;AAC1C,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,SAASC,SAAS,QAAmB,QAAQ;AAWpD,OAAO,MAAMC,sBAAsBD;IAG/B,OAAOE,yBAAyBC,KAAY,EAAkB;QAC1D,OAAO;YAAEA;QAAM;IACnB;IAESC,SAAS;QACd,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI,CAACC,KAAK;QAC9B,MAAM,EAAEH,KAAK,EAAE,GAAG,IAAI,CAACI,KAAK;QAE5B,IAAI,CAACJ,OAAO;YACR,OAAO,IAAI,CAACG,KAAK,CAACE,QAAQ;QAC9B;QAEA,qBACI,oBAACX;YAAcY,SAAQ;yBACnB,oBAACX;YAAKY,OAAM;WAAOL,UAAUF,MAAMQ,KAAK,GAAGR,MAAMS,OAAO;IAGpE;;;aAnBSL,QAAQ,CAAC;;AAoBtB"}
|
package/src/index.js
CHANGED
@@ -30,6 +30,10 @@ cli.register(TranspileCommand);
|
|
30
30
|
cli.register(CompileCommand);
|
31
31
|
cli.register(GenerateTypesCommand);
|
32
32
|
cli.register(SimulatorCommand);
|
33
|
-
|
33
|
+
try {
|
34
|
+
cli.runExit(args);
|
35
|
+
} catch (error) {
|
36
|
+
process.exit(1);
|
37
|
+
}
|
34
38
|
|
35
39
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Builtins, Cli } from 'clipanion';\nimport { CompileCommand } from '@/cli/commands/CompileCommand/index.js';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/index.js';\nimport { NewCommand } from '@/cli/commands/NewCommand/NewCommand.js';\nimport { NewLibCommand } from '@/cli/commands/NewLibCommand/index.js';\nimport { SimulatorCommand } from '@/cli/commands/SimulatorCommand/index.js';\nimport { TranspileCommand } from '@/cli/commands/TranspileCommand/index.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\nprocess.on('SIGINT', function () {\n process.exit();\n});\n\ncli.register(Builtins.HelpCommand);\ncli.register(Builtins.VersionCommand);\ncli.register(DoctorCommand);\ncli.register(NewCommand);\ncli.register(NewLibCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Builtins, Cli } from 'clipanion';\nimport { CompileCommand } from '@/cli/commands/CompileCommand/index.js';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/index.js';\nimport { NewCommand } from '@/cli/commands/NewCommand/NewCommand.js';\nimport { NewLibCommand } from '@/cli/commands/NewLibCommand/index.js';\nimport { SimulatorCommand } from '@/cli/commands/SimulatorCommand/index.js';\nimport { TranspileCommand } from '@/cli/commands/TranspileCommand/index.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\nprocess.on('SIGINT', function () {\n process.exit();\n});\n\ncli.register(Builtins.HelpCommand);\ncli.register(Builtins.VersionCommand);\ncli.register(DoctorCommand);\ncli.register(NewCommand);\ncli.register(NewLibCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\n\ntry {\n cli.runExit(args);\n} catch (error) {\n process.exit(1);\n}\n"],"names":["readFileSync","join","Builtins","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","NewCommand","NewLibCommand","SimulatorCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","on","exit","register","HelpCommand","VersionCommand","runExit","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,QAAQ,EAAEC,GAAG,QAAQ,YAAY;AAC1C,SAASC,cAAc,QAAQ,yCAAyC;AACxE,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,UAAU,QAAQ,0CAA0C;AACrE,SAASC,aAAa,QAAQ,wCAAwC;AACtE,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBZ,aACxBC,KAAKU,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIjB,IAAI;IAChBkB,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAP,QAAQQ,EAAE,CAAC,UAAU;IACjBR,QAAQS,IAAI;AAChB;AAEAN,IAAIO,QAAQ,CAACzB,SAAS0B,WAAW;AACjCR,IAAIO,QAAQ,CAACzB,SAAS2B,cAAc;AACpCT,IAAIO,QAAQ,CAACtB;AACbe,IAAIO,QAAQ,CAACpB;AACba,IAAIO,QAAQ,CAACnB;AACbY,IAAIO,QAAQ,CAACjB;AACbU,IAAIO,QAAQ,CAACvB;AACbgB,IAAIO,QAAQ,CAACrB;AACbc,IAAIO,QAAQ,CAAClB;AAEb,IAAI;IACAW,IAAIU,OAAO,CAACd;AAChB,EAAE,OAAOe,OAAO;IACZd,QAAQS,IAAI,CAAC;AACjB"}
|