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
package/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# crankscript
|
2
|
+
|
3
|
+
## 0.15.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [`a25ad06`](https://github.com/crankscript/crankscript/commit/a25ad06575995c2e39a8352586a81d72d8cc1199) Thanks [@alberteddu](https://github.com/alberteddu)! - Add crankscript simulator support for standalone files with `crankscript simulator file.ts`
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 crankscript
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
@@ -1,32 +1,33 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
"
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"
|
31
|
-
"
|
32
|
-
}
|
2
|
+
"name": "crankscript",
|
3
|
+
"version": "0.15.1",
|
4
|
+
"bin": {
|
5
|
+
"crankscript": "./src/index.js"
|
6
|
+
},
|
7
|
+
"license": "MIT",
|
8
|
+
"dependencies": {
|
9
|
+
"@inkjs/ui": "^2.0.0",
|
10
|
+
"@swc/helpers": "~0.5.11",
|
11
|
+
"cheerio": "^1.0.0",
|
12
|
+
"chokidar": "^4.0.3",
|
13
|
+
"clipanion": "^4.0.0-rc.4",
|
14
|
+
"ink": "^5.0.1",
|
15
|
+
"open": "^10.1.0",
|
16
|
+
"react": "^18.3.1",
|
17
|
+
"tiged": "^3.0.0-rc.0",
|
18
|
+
"ts-morph": "^23.0.0",
|
19
|
+
"turndown": "^7.2.0",
|
20
|
+
"typanion": "^3.14.0",
|
21
|
+
"typescript": "5.7.3",
|
22
|
+
"typescript-to-lua": "^1.27.0"
|
23
|
+
},
|
24
|
+
"type": "module",
|
25
|
+
"main": "./src/index.js",
|
26
|
+
"typings": "./src/index.d.ts",
|
27
|
+
"types": "./src/index.d.ts",
|
28
|
+
"module": "./src/index.js",
|
29
|
+
"scripts": {
|
30
|
+
"dev": "tsx src/index.ts",
|
31
|
+
"post-build": "tsc-alias --project tsconfig.json"
|
32
|
+
}
|
33
|
+
}
|
@@ -4,7 +4,9 @@ import { getPdcPathFromEnvironment } from '../../../commands/CompileCommand/fn/g
|
|
4
4
|
import { useCompileTasks } from '../../../commands/CompileCommand/hooks/useCompileTasks.js';
|
5
5
|
import { CheckList } from '../../../components/CheckList/index.js';
|
6
6
|
export const Compile = ({ environment })=>{
|
7
|
-
const items = useCompileTasks(
|
7
|
+
const items = useCompileTasks({
|
8
|
+
pdcPath: getPdcPathFromEnvironment(environment)
|
9
|
+
});
|
8
10
|
return /*#__PURE__*/ React.createElement(CheckList, {
|
9
11
|
items: items,
|
10
12
|
onFinish: ()=>process.exit
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import process from 'node:process';\nimport React from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n}\n\nexport const Compile = ({ environment }: Props) => {\n const items = useCompileTasks(getPdcPathFromEnvironment(environment));\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["process","React","getPdcPathFromEnvironment","useCompileTasks","CheckList","Compile","environment","items","onFinish","exit"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import process from 'node:process';\nimport React from 'react';\nimport { getPdcPathFromEnvironment } from '@/cli/commands/CompileCommand/fn/getPdcPathFromEnvironment.js';\nimport { useCompileTasks } from '@/cli/commands/CompileCommand/hooks/useCompileTasks.js';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\ninterface Props {\n environment: Environment;\n}\n\nexport const Compile = ({ environment }: Props) => {\n const items = useCompileTasks({\n pdcPath: getPdcPathFromEnvironment(environment),\n });\n\n return <CheckList items={items} onFinish={() => process.exit} />;\n};\n"],"names":["process","React","getPdcPathFromEnvironment","useCompileTasks","CheckList","Compile","environment","items","pdcPath","onFinish","exit"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,yBAAyB,QAAQ,gEAAgE;AAC1G,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,SAAS,QAAQ,sCAAsC;AAOhE,OAAO,MAAMC,UAAU,CAAC,EAAEC,WAAW,EAAS;IAC1C,MAAMC,QAAQJ,gBAAgB;QAC1BK,SAASN,0BAA0BI;IACvC;IAEA,qBAAO,oBAACF;QAAUG,OAAOA;QAAOE,UAAU,IAAMT,QAAQU,IAAI;;AAChE,EAAE"}
|
@@ -1,2 +1,7 @@
|
|
1
1
|
import { CheckListItem } from '../../../types.js';
|
2
|
-
|
2
|
+
interface Props {
|
3
|
+
pdcPath: string;
|
4
|
+
outputPath?: string;
|
5
|
+
}
|
6
|
+
export declare const useCompileTasks: ({ pdcPath, outputPath }: Props) => CheckListItem<unknown>[];
|
7
|
+
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { existsSync } from 'node:fs';
|
2
2
|
import { useMemo } from 'react';
|
3
3
|
import { compile } from '../../../commands/CompileCommand/hooks/task/compile.js';
|
4
|
-
export const useCompileTasks = (pdcPath)=>{
|
4
|
+
export const useCompileTasks = ({ pdcPath, outputPath })=>{
|
5
5
|
return useMemo(()=>[
|
6
6
|
{
|
7
7
|
waitingDescription: 'Waiting to check for pdc binary...',
|
@@ -24,7 +24,7 @@ export const useCompileTasks = (pdcPath)=>{
|
|
24
24
|
runner: async ()=>{
|
25
25
|
await compile({
|
26
26
|
pdcPath,
|
27
|
-
target: process.cwd()
|
27
|
+
target: outputPath != null ? outputPath : process.cwd()
|
28
28
|
});
|
29
29
|
},
|
30
30
|
ready: true
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport { compile } from '@/cli/commands/CompileCommand/hooks/task/compile.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useCompileTasks = (pdcPath:
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/hooks/useCompileTasks.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport { compile } from '@/cli/commands/CompileCommand/hooks/task/compile.js';\nimport { CheckListItem } from '@/cli/types.js';\n\ninterface Props {\n pdcPath: string;\n outputPath?: string;\n}\n\nexport const useCompileTasks = ({ pdcPath, outputPath }: Props) => {\n return useMemo(\n () => [\n {\n waitingDescription: 'Waiting to check for pdc binary...',\n errorDescription: 'Could not find pdc binary',\n runningDescription: 'Checking for pdc binary...',\n finishedDescription: result =>\n `Found pdc binary at \"${result}\"`,\n runner: async () => {\n if (!existsSync(pdcPath)) {\n throw new Error('Could not find pdc binary');\n }\n\n return pdcPath;\n },\n ready: true,\n } satisfies CheckListItem<string>,\n {\n waitingDescription: 'Waiting for pdc binary path...',\n errorDescription: 'Could not compile lua code',\n runningDescription: 'Compiling lua code...',\n finishedDescription: () => 'Lua code compiled',\n runner: async () => {\n await compile({\n pdcPath,\n target: outputPath ?? process.cwd(),\n });\n },\n ready: true,\n },\n ],\n [],\n ) as CheckListItem<unknown>[];\n};\n"],"names":["existsSync","useMemo","compile","useCompileTasks","pdcPath","outputPath","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready","target","process","cwd"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,OAAO,QAAQ,sDAAsD;AAQ9E,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,OAAO,EAAEC,UAAU,EAAS;IAC1D,OAAOJ,QACH,IAAM;YACF;gBACIK,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqBC,CAAAA,SACjB,CAAC,qBAAqB,EAAEA,OAAO,CAAC,CAAC;gBACrCC,QAAQ;oBACJ,IAAI,CAACX,WAAWI,UAAU;wBACtB,MAAM,IAAIQ,MAAM;oBACpB;oBAEA,OAAOR;gBACX;gBACAS,OAAO;YACX;YACA;gBACIP,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BE,QAAQ;oBACJ,MAAMT,QAAQ;wBACVE;wBACAU,QAAQT,qBAAAA,aAAcU,QAAQC,GAAG;oBACrC;gBACJ;gBACAH,OAAO;YACX;SACH,EACD,EAAE;AAEV,EAAE"}
|
@@ -4,6 +4,7 @@ import { Environment } from '../../environment/dto/Environment.js';
|
|
4
4
|
export declare abstract class EnvironmentAwareCommand extends RenderableCommand {
|
5
5
|
private environment;
|
6
6
|
protected abstract renderWithEnvironment(environment: Environment): JSX.Element;
|
7
|
+
verbose: boolean;
|
7
8
|
render(): JSX.Element;
|
8
9
|
execute(): Promise<void>;
|
9
10
|
}
|
@@ -1,7 +1,11 @@
|
|
1
|
+
import { StatusMessage } from '@inkjs/ui';
|
2
|
+
import { Option } from 'clipanion';
|
3
|
+
import { Text } from 'ink';
|
1
4
|
import React from 'react';
|
2
5
|
import { HealthReport } from '../../commands/EnvironmentAwareCommand/components/HealthReport.js';
|
3
6
|
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
4
7
|
import { createEnvironment } from '../../environment/createEnvironment.js';
|
8
|
+
import { CrankScriptProvider } from './contexts/CrankScriptContext.js';
|
5
9
|
export class EnvironmentAwareCommand extends RenderableCommand {
|
6
10
|
render() {
|
7
11
|
if (!this.environment) {
|
@@ -18,7 +22,27 @@ export class EnvironmentAwareCommand extends RenderableCommand {
|
|
18
22
|
return;
|
19
23
|
}
|
20
24
|
this.environment = environmentHealth.environment;
|
21
|
-
|
25
|
+
try {
|
26
|
+
const toRender = this.render();
|
27
|
+
this.renderElement(/*#__PURE__*/ React.createElement(CrankScriptProvider, {
|
28
|
+
verbose: this.verbose
|
29
|
+
}, toRender));
|
30
|
+
} catch (error) {
|
31
|
+
this.renderElement(/*#__PURE__*/ React.createElement(StatusMessage, {
|
32
|
+
variant: "error"
|
33
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
34
|
+
color: "red"
|
35
|
+
}, error instanceof Error ? error.message : 'An unknown error occurred', this.verbose && error instanceof Error && error.stack && /*#__PURE__*/ React.createElement(Text, {
|
36
|
+
color: "red"
|
37
|
+
}, error.stack))));
|
38
|
+
process.exit(1);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
constructor(...args){
|
42
|
+
super(...args);
|
43
|
+
this.verbose = Option.Boolean('-vvv,--verbose', false, {
|
44
|
+
description: 'Enable verbose logging'
|
45
|
+
});
|
22
46
|
}
|
23
47
|
}
|
24
48
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.tsx"],"sourcesContent":["import React, { JSX } from 'react';\nimport { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { createEnvironment } from '@/cli/environment/createEnvironment.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport abstract class EnvironmentAwareCommand extends RenderableCommand {\n private environment: Environment | undefined;\n\n protected abstract renderWithEnvironment(\n environment: Environment,\n ): JSX.Element;\n\n override render() {\n if (!this.environment) {\n throw new Error('Environment is not set');\n }\n\n return this.renderWithEnvironment(this.environment);\n }\n\n override async execute() {\n const environmentHealth = createEnvironment();\n\n if (!environmentHealth.isHealthy) {\n this.renderElement(\n <HealthReport environment={environmentHealth} />,\n );\n\n return;\n }\n\n this.environment = environmentHealth.environment;\n\n this.renderElement(this.
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.tsx"],"sourcesContent":["import { StatusMessage } from '@inkjs/ui';\nimport { Option } from 'clipanion';\nimport { Text } from 'ink';\nimport React, { JSX } from 'react';\nimport { HealthReport } from '@/cli/commands/EnvironmentAwareCommand/components/HealthReport.js';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { createEnvironment } from '@/cli/environment/createEnvironment.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { CrankScriptProvider } from './contexts/CrankScriptContext.js';\n\nexport abstract class EnvironmentAwareCommand extends RenderableCommand {\n private environment: Environment | undefined;\n\n protected abstract renderWithEnvironment(\n environment: Environment,\n ): JSX.Element;\n\n verbose = Option.Boolean('-vvv,--verbose', false, {\n description: 'Enable verbose logging',\n });\n\n override render() {\n if (!this.environment) {\n throw new Error('Environment is not set');\n }\n\n return this.renderWithEnvironment(this.environment);\n }\n\n override async execute() {\n const environmentHealth = createEnvironment();\n\n if (!environmentHealth.isHealthy) {\n this.renderElement(\n <HealthReport environment={environmentHealth} />,\n );\n\n return;\n }\n\n this.environment = environmentHealth.environment;\n\n try {\n const toRender = this.render();\n this.renderElement(\n <CrankScriptProvider verbose={this.verbose}>\n {toRender}\n </CrankScriptProvider>,\n );\n } catch (error) {\n this.renderElement(\n <StatusMessage variant=\"error\">\n <Text color=\"red\">\n {error instanceof Error\n ? error.message\n : 'An unknown error occurred'}\n {this.verbose &&\n error instanceof Error &&\n error.stack && (\n <Text color=\"red\">{error.stack}</Text>\n )}\n </Text>\n </StatusMessage>,\n );\n\n process.exit(1);\n }\n }\n}\n"],"names":["StatusMessage","Option","Text","React","HealthReport","RenderableCommand","createEnvironment","CrankScriptProvider","EnvironmentAwareCommand","render","environment","Error","renderWithEnvironment","execute","environmentHealth","isHealthy","renderElement","toRender","verbose","error","variant","color","message","stack","process","exit","Boolean","description"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY;AAC1C,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,IAAI,QAAQ,MAAM;AAC3B,OAAOC,WAAoB,QAAQ;AACnC,SAASC,YAAY,QAAQ,oEAAoE;AACjG,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,iBAAiB,QAAQ,yCAAyC;AAE3E,SAASC,mBAAmB,QAAQ,mCAAmC;AAEvE,OAAO,MAAeC,gCAAgCH;IAWzCI,SAAS;QACd,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE;YACnB,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAO,IAAI,CAACC,qBAAqB,CAAC,IAAI,CAACF,WAAW;IACtD;IAEA,MAAeG,UAAU;QACrB,MAAMC,oBAAoBR;QAE1B,IAAI,CAACQ,kBAAkBC,SAAS,EAAE;YAC9B,IAAI,CAACC,aAAa,eACd,oBAACZ;gBAAaM,aAAaI;;YAG/B;QACJ;QAEA,IAAI,CAACJ,WAAW,GAAGI,kBAAkBJ,WAAW;QAEhD,IAAI;YACA,MAAMO,WAAW,IAAI,CAACR,MAAM;YAC5B,IAAI,CAACO,aAAa,eACd,oBAACT;gBAAoBW,SAAS,IAAI,CAACA,OAAO;eACrCD;QAGb,EAAE,OAAOE,OAAO;YACZ,IAAI,CAACH,aAAa,eACd,oBAAChB;gBAAcoB,SAAQ;6BACnB,oBAAClB;gBAAKmB,OAAM;eACPF,iBAAiBR,QACZQ,MAAMG,OAAO,GACb,6BACL,IAAI,CAACJ,OAAO,IACTC,iBAAiBR,SACjBQ,MAAMI,KAAK,kBACP,oBAACrB;gBAAKmB,OAAM;eAAOF,MAAMI,KAAK;YAMlDC,QAAQC,IAAI,CAAC;QACjB;IACJ;;;aAlDAP,UAAUjB,OAAOyB,OAAO,CAAC,kBAAkB,OAAO;YAC9CC,aAAa;QACjB;;AAiDJ"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
type CrankScriptContextType = {
|
3
|
+
verbose: boolean;
|
4
|
+
};
|
5
|
+
export declare const CrankScriptContext: React.Context<CrankScriptContextType>;
|
6
|
+
export declare const CrankScriptProvider: ({ children, verbose, }: {
|
7
|
+
children: React.ReactNode;
|
8
|
+
verbose: boolean;
|
9
|
+
}) => React.JSX.Element;
|
10
|
+
export declare const useCrankScriptContext: () => CrankScriptContextType;
|
11
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
2
|
+
export const CrankScriptContext = /*#__PURE__*/ createContext({
|
3
|
+
verbose: false
|
4
|
+
});
|
5
|
+
export const CrankScriptProvider = ({ children, verbose })=>{
|
6
|
+
return /*#__PURE__*/ React.createElement(CrankScriptContext.Provider, {
|
7
|
+
value: {
|
8
|
+
verbose
|
9
|
+
}
|
10
|
+
}, children);
|
11
|
+
};
|
12
|
+
export const useCrankScriptContext = ()=>{
|
13
|
+
const context = useContext(CrankScriptContext);
|
14
|
+
if (!context) {
|
15
|
+
throw new Error('CrankScriptContext not found');
|
16
|
+
}
|
17
|
+
return context;
|
18
|
+
};
|
19
|
+
|
20
|
+
//# sourceMappingURL=CrankScriptContext.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/EnvironmentAwareCommand/contexts/CrankScriptContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\n\ntype CrankScriptContextType = {\n verbose: boolean;\n};\n\nexport const CrankScriptContext = createContext<CrankScriptContextType>({\n verbose: false,\n});\n\nexport const CrankScriptProvider = ({\n children,\n verbose,\n}: {\n children: React.ReactNode;\n verbose: boolean;\n}) => {\n return (\n <CrankScriptContext.Provider value={{ verbose }}>\n {children}\n </CrankScriptContext.Provider>\n );\n};\n\nexport const useCrankScriptContext = () => {\n const context = useContext(CrankScriptContext);\n\n if (!context) {\n throw new Error('CrankScriptContext not found');\n }\n\n return context;\n};\n"],"names":["React","createContext","useContext","CrankScriptContext","verbose","CrankScriptProvider","children","Provider","value","useCrankScriptContext","context","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAMzD,OAAO,MAAMC,mCAAqBF,cAAsC;IACpEG,SAAS;AACb,GAAG;AAEH,OAAO,MAAMC,sBAAsB,CAAC,EAChCC,QAAQ,EACRF,OAAO,EAIV;IACG,qBACI,oBAACD,mBAAmBI,QAAQ;QAACC,OAAO;YAAEJ;QAAQ;OACzCE;AAGb,EAAE;AAEF,OAAO,MAAMG,wBAAwB;IACjC,MAAMC,UAAUR,WAAWC;IAE3B,IAAI,CAACO,SAAS;QACV,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX,EAAE"}
|
@@ -8,7 +8,7 @@ export const useFormatTypeFile = (path)=>{
|
|
8
8
|
let hasEslint = false;
|
9
9
|
try {
|
10
10
|
// Check if prettier is available
|
11
|
-
execSync('
|
11
|
+
execSync('pnpm exec prettier --version', {
|
12
12
|
stdio: 'ignore'
|
13
13
|
});
|
14
14
|
hasPrettier = true;
|
@@ -17,7 +17,7 @@ export const useFormatTypeFile = (path)=>{
|
|
17
17
|
}
|
18
18
|
try {
|
19
19
|
// Check if eslint is available
|
20
|
-
execSync('
|
20
|
+
execSync('pnpm exec eslint --version', {
|
21
21
|
stdio: 'ignore'
|
22
22
|
});
|
23
23
|
hasEslint = true;
|
@@ -39,13 +39,13 @@ export const useFormatTypeFile = (path)=>{
|
|
39
39
|
try {
|
40
40
|
// Run prettier on the generated file if available
|
41
41
|
if (hasPrettier) {
|
42
|
-
execSync(`
|
42
|
+
execSync(`pnpm exec prettier --write "${path}"`, {
|
43
43
|
stdio: 'ignore'
|
44
44
|
});
|
45
45
|
}
|
46
46
|
// Run eslint if available
|
47
47
|
if (hasEslint) {
|
48
|
-
execSync(`
|
48
|
+
execSync(`pnpm exec eslint --fix "${path}"`, {
|
49
49
|
stdio: 'ignore'
|
50
50
|
});
|
51
51
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFormatTypeFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { useMemo } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFormatTypeFile = (path: string) => {\n const formatTypeFile = useMemo(() => {\n // Check if prettier and eslint are available\n const checkToolsAvailability = () => {\n let hasPrettier = false;\n let hasEslint = false;\n\n try {\n // Check if prettier is available\n execSync('
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useFormatTypeFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { useMemo } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useFormatTypeFile = (path: string) => {\n const formatTypeFile = useMemo(() => {\n // Check if prettier and eslint are available\n const checkToolsAvailability = () => {\n let hasPrettier = false;\n let hasEslint = false;\n\n try {\n // Check if prettier is available\n execSync('pnpm exec prettier --version', { stdio: 'ignore' });\n hasPrettier = true;\n } catch (error) {\n // Prettier not available\n }\n\n try {\n // Check if eslint is available\n execSync('pnpm exec eslint --version', { stdio: 'ignore' });\n hasEslint = true;\n } catch (error) {\n // ESLint not available\n }\n\n return { hasPrettier, hasEslint };\n };\n\n const { hasPrettier, hasEslint } = checkToolsAvailability();\n\n return {\n waitingDescription: 'Waiting to format the type file...',\n errorDescription: 'Failed to format the type file',\n finishedDescription: () => 'Type file formatted',\n runningDescription: 'Formatting the type file...',\n runner: async () => {\n try {\n // Run prettier on the generated file if available\n if (hasPrettier) {\n execSync(`pnpm exec prettier --write \"${path}\"`, {\n stdio: 'ignore',\n });\n }\n\n // Run eslint if available\n if (hasEslint) {\n execSync(`pnpm exec eslint --fix \"${path}\"`, {\n stdio: 'ignore',\n });\n }\n\n return true;\n } catch (error) {\n console.error('Error formatting file:', error);\n return false;\n }\n },\n ready: true,\n // Skip only if both tools are unavailable\n skip: !hasPrettier && !hasEslint,\n } satisfies CheckListItem<boolean>;\n }, [path]);\n\n return {\n formatTypeFile,\n };\n};\n"],"names":["execSync","useMemo","useFormatTypeFile","path","formatTypeFile","checkToolsAvailability","hasPrettier","hasEslint","stdio","error","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","console","ready","skip"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,OAAO,QAAQ,QAAQ;AAGhC,OAAO,MAAMC,oBAAoB,CAACC;IAC9B,MAAMC,iBAAiBH,QAAQ;QAC3B,6CAA6C;QAC7C,MAAMI,yBAAyB;YAC3B,IAAIC,cAAc;YAClB,IAAIC,YAAY;YAEhB,IAAI;gBACA,iCAAiC;gBACjCP,SAAS,gCAAgC;oBAAEQ,OAAO;gBAAS;gBAC3DF,cAAc;YAClB,EAAE,OAAOG,OAAO;YACZ,yBAAyB;YAC7B;YAEA,IAAI;gBACA,+BAA+B;gBAC/BT,SAAS,8BAA8B;oBAAEQ,OAAO;gBAAS;gBACzDD,YAAY;YAChB,EAAE,OAAOE,OAAO;YACZ,uBAAuB;YAC3B;YAEA,OAAO;gBAAEH;gBAAaC;YAAU;QACpC;QAEA,MAAM,EAAED,WAAW,EAAEC,SAAS,EAAE,GAAGF;QAEnC,OAAO;YACHK,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI;oBACA,kDAAkD;oBAClD,IAAIR,aAAa;wBACbN,SAAS,CAAC,4BAA4B,EAAEG,KAAK,CAAC,CAAC,EAAE;4BAC7CK,OAAO;wBACX;oBACJ;oBAEA,0BAA0B;oBAC1B,IAAID,WAAW;wBACXP,SAAS,CAAC,wBAAwB,EAAEG,KAAK,CAAC,CAAC,EAAE;4BACzCK,OAAO;wBACX;oBACJ;oBAEA,OAAO;gBACX,EAAE,OAAOC,OAAO;oBACZM,QAAQN,KAAK,CAAC,0BAA0BA;oBACxC,OAAO;gBACX;YACJ;YACAO,OAAO;YACP,0CAA0C;YAC1CC,MAAM,CAACX,eAAe,CAACC;QAC3B;IACJ,GAAG;QAACJ;KAAK;IAET,OAAO;QACHC;IACJ;AACJ,EAAE"}
|
@@ -4,9 +4,11 @@ import { Environment } from '../../environment/dto/Environment.js';
|
|
4
4
|
export declare class SimulatorCommand extends EnvironmentAwareCommand {
|
5
5
|
static paths: string[][];
|
6
6
|
static usage: import("clipanion").Usage;
|
7
|
+
file: string | undefined;
|
7
8
|
watch: boolean;
|
8
9
|
recompileOnly: boolean;
|
9
10
|
background: boolean;
|
11
|
+
additionalGlobs: string[];
|
10
12
|
projectPath: string;
|
11
13
|
renderWithEnvironment(environment: Environment): React.JSX.Element;
|
12
14
|
}
|
@@ -1,20 +1,40 @@
|
|
1
1
|
import { Command, Option } from 'clipanion';
|
2
2
|
import React from 'react';
|
3
|
+
import * as t from 'typanion';
|
3
4
|
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
4
5
|
import { Simulator } from '../../commands/SimulatorCommand/components/Simulator.js';
|
5
|
-
import {
|
6
|
+
import { TemporaryFolderCreator } from '../../commands/SimulatorCommand/components/TemporaryFolderCreator.js';
|
7
|
+
import { defaultProjectPath, projectPathOption } from '../../commands/TranspileCommand/index.js';
|
6
8
|
export class SimulatorCommand extends EnvironmentAwareCommand {
|
7
9
|
renderWithEnvironment(environment) {
|
8
|
-
|
10
|
+
if (this.file && this.projectPath !== defaultProjectPath) {
|
11
|
+
throw new Error('Cannot provide a --path when running a single file');
|
12
|
+
}
|
13
|
+
if (this.additionalGlobs.length > 0 && !this.watch) {
|
14
|
+
throw new Error('Can only provide --additional-globs when watching for changes');
|
15
|
+
}
|
16
|
+
const content = /*#__PURE__*/ React.createElement(Simulator, {
|
9
17
|
environment: environment,
|
10
18
|
path: this.projectPath,
|
11
19
|
watch: this.watch,
|
12
20
|
recompileOnly: this.recompileOnly,
|
13
|
-
background: this.background
|
21
|
+
background: this.background,
|
22
|
+
entryFile: this.file,
|
23
|
+
additionalGlobs: this.additionalGlobs
|
14
24
|
});
|
25
|
+
if (!this.file) {
|
26
|
+
return content;
|
27
|
+
}
|
28
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(TemporaryFolderCreator, {
|
29
|
+
entryFile: this.file
|
30
|
+
}, content));
|
15
31
|
}
|
16
32
|
constructor(...args){
|
17
33
|
super(...args);
|
34
|
+
this.file = Option.String({
|
35
|
+
name: 'file',
|
36
|
+
required: false
|
37
|
+
});
|
18
38
|
this.watch = Option.Boolean('-w,--watch', false, {
|
19
39
|
description: 'Watch for changes'
|
20
40
|
});
|
@@ -24,6 +44,10 @@ export class SimulatorCommand extends EnvironmentAwareCommand {
|
|
24
44
|
this.background = Option.Boolean('-b,--background', false, {
|
25
45
|
description: 'Do not bring simulator to foreground'
|
26
46
|
});
|
47
|
+
this.additionalGlobs = Option.Array('-g,--additional-globs', [], {
|
48
|
+
description: 'Additional globs to watch for changes',
|
49
|
+
validator: t.isArray(t.isString())
|
50
|
+
});
|
27
51
|
this.projectPath = projectPathOption;
|
28
52
|
}
|
29
53
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/SimulatorCommand/SimulatorCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Simulator } from '@/cli/commands/SimulatorCommand/components/Simulator.js';\nimport {
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/SimulatorCommand/SimulatorCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Simulator } from '@/cli/commands/SimulatorCommand/components/Simulator.js';\nimport { TemporaryFolderCreator } from '@/cli/commands/SimulatorCommand/components/TemporaryFolderCreator.js';\nimport {\n defaultProjectPath,\n projectPathOption,\n} from '@/cli/commands/TranspileCommand/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport class SimulatorCommand extends EnvironmentAwareCommand {\n static override paths = [['simulator']];\n\n static override usage = Command.Usage({\n description: 'Transpile, compile, and run the simulator',\n });\n\n file = Option.String({\n name: 'file',\n required: false,\n });\n\n watch = Option.Boolean('-w,--watch', false, {\n description: 'Watch for changes',\n });\n\n recompileOnly = Option.Boolean('-r,--recompile-only', false, {\n description:\n 'Use with --watch to only recompile without launching the simulator when files change',\n });\n\n background = Option.Boolean('-b,--background', false, {\n description: 'Do not bring simulator to foreground',\n });\n\n additionalGlobs = Option.Array('-g,--additional-globs', [], {\n description: 'Additional globs to watch for changes',\n validator: t.isArray(t.isString()),\n });\n\n projectPath = projectPathOption;\n\n override renderWithEnvironment(environment: Environment) {\n if (this.file && this.projectPath !== defaultProjectPath) {\n throw new Error(\n 'Cannot provide a --path when running a single file',\n );\n }\n\n if (this.additionalGlobs.length > 0 && !this.watch) {\n throw new Error(\n 'Can only provide --additional-globs when watching for changes',\n );\n }\n\n const content = (\n <Simulator\n environment={environment}\n path={this.projectPath}\n watch={this.watch}\n recompileOnly={this.recompileOnly}\n background={this.background}\n entryFile={this.file}\n additionalGlobs={this.additionalGlobs}\n />\n );\n\n if (!this.file) {\n return content;\n }\n\n return (\n <>\n <TemporaryFolderCreator entryFile={this.file}>\n {content}\n </TemporaryFolderCreator>\n </>\n );\n }\n}\n"],"names":["Command","Option","React","t","EnvironmentAwareCommand","Simulator","TemporaryFolderCreator","defaultProjectPath","projectPathOption","SimulatorCommand","renderWithEnvironment","environment","file","projectPath","Error","additionalGlobs","length","watch","content","path","recompileOnly","background","entryFile","String","name","required","Boolean","description","Array","validator","isArray","isString","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,uBAAuB,QAAQ,kDAAkD;AAC1F,SAASC,SAAS,QAAQ,0DAA0D;AACpF,SAASC,sBAAsB,QAAQ,uEAAuE;AAC9G,SACIC,kBAAkB,EAClBC,iBAAiB,QACd,2CAA2C;AAGlD,OAAO,MAAMC,yBAAyBL;IAgCzBM,sBAAsBC,WAAwB,EAAE;QACrD,IAAI,IAAI,CAACC,IAAI,IAAI,IAAI,CAACC,WAAW,KAAKN,oBAAoB;YACtD,MAAM,IAAIO,MACN;QAER;QAEA,IAAI,IAAI,CAACC,eAAe,CAACC,MAAM,GAAG,KAAK,CAAC,IAAI,CAACC,KAAK,EAAE;YAChD,MAAM,IAAIH,MACN;QAER;QAEA,MAAMI,wBACF,oBAACb;YACGM,aAAaA;YACbQ,MAAM,IAAI,CAACN,WAAW;YACtBI,OAAO,IAAI,CAACA,KAAK;YACjBG,eAAe,IAAI,CAACA,aAAa;YACjCC,YAAY,IAAI,CAACA,UAAU;YAC3BC,WAAW,IAAI,CAACV,IAAI;YACpBG,iBAAiB,IAAI,CAACA,eAAe;;QAI7C,IAAI,CAAC,IAAI,CAACH,IAAI,EAAE;YACZ,OAAOM;QACX;QAEA,qBACI,wDACI,oBAACZ;YAAuBgB,WAAW,IAAI,CAACV,IAAI;WACvCM;IAIjB;;;aA7DAN,OAAOX,OAAOsB,MAAM,CAAC;YACjBC,MAAM;YACNC,UAAU;QACd;aAEAR,QAAQhB,OAAOyB,OAAO,CAAC,cAAc,OAAO;YACxCC,aAAa;QACjB;aAEAP,gBAAgBnB,OAAOyB,OAAO,CAAC,uBAAuB,OAAO;YACzDC,aACI;QACR;aAEAN,aAAapB,OAAOyB,OAAO,CAAC,mBAAmB,OAAO;YAClDC,aAAa;QACjB;aAEAZ,kBAAkBd,OAAO2B,KAAK,CAAC,yBAAyB,EAAE,EAAE;YACxDD,aAAa;YACbE,WAAW1B,EAAE2B,OAAO,CAAC3B,EAAE4B,QAAQ;QACnC;aAEAlB,cAAcL;;AAuClB;AArEaC,iBACOuB,QAAQ;IAAC;QAAC;KAAY;CAAC;AAD9BvB,iBAGOwB,QAAQjC,QAAQkC,KAAK,CAAC;IAClCP,aAAa;AACjB"}
|
@@ -6,6 +6,8 @@ interface Props {
|
|
6
6
|
watch?: boolean;
|
7
7
|
recompileOnly?: boolean;
|
8
8
|
background?: boolean;
|
9
|
+
entryFile?: string;
|
10
|
+
additionalGlobs?: string[];
|
9
11
|
}
|
10
|
-
export declare const Simulator: ({ environment, path, watch, recompileOnly, background, }: Props) => React.JSX.Element;
|
12
|
+
export declare const Simulator: ({ environment, path, watch, recompileOnly, background, entryFile, additionalGlobs, }: Props) => React.JSX.Element;
|
11
13
|
export {};
|
@@ -1,90 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
import { join } from 'node:path';
|
1
|
+
import { join } from 'path';
|
3
2
|
import { StatusMessage } from '@inkjs/ui';
|
4
|
-
import
|
5
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
6
|
-
import { getPdcPathFromEnvironment } from '../../../commands/CompileCommand/fn/getPdcPathFromEnvironment.js';
|
7
|
-
import { useCompileTasks } from '../../../commands/CompileCommand/hooks/useCompileTasks.js';
|
8
|
-
import { getSimulatorPathFromEnvironment } from '../../../commands/SimulatorCommand/fn/getSimulatorPathFromEnvironment.js';
|
9
|
-
import { validateEntryPoint } from '../../../commands/TranspileCommand/fn/validateEntryPoint.js';
|
10
|
-
import { useTranspileTasks } from '../../../commands/TranspileCommand/hooks/useTranspileTasks.js';
|
3
|
+
import React from 'react';
|
11
4
|
import { CheckList } from '../../../components/CheckList/index.js';
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
export const Simulator = ({ environment, path, watch = false, recompileOnly = false, background = false })=>{
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
import { createTemporaryFolderPathFromEntryFile } from '../fn/createTemporaryFolderPathFromEntryFile.js';
|
6
|
+
import { useSimulatorTasks } from '../hooks/useSimulatorTasks.js';
|
7
|
+
export const Simulator = ({ environment, path, watch = false, recompileOnly = false, background = false, entryFile, additionalGlobs = [] })=>{
|
8
|
+
const temporaryFolder = entryFile ? createTemporaryFolderPathFromEntryFile(entryFile) : undefined;
|
9
|
+
const gameOutputPath = entryFile ? temporaryFolder : undefined;
|
10
|
+
const luaOutputPath = entryFile ? temporaryFolder ? join(temporaryFolder, 'Source') : undefined : undefined;
|
11
|
+
const projectPath = entryFile && temporaryFolder ? temporaryFolder : path;
|
12
|
+
const { tasks, handleFinish, isWatching, hasChangedMessage, hasFailure, hasChanged } = useSimulatorTasks({
|
13
|
+
environment,
|
14
|
+
path: projectPath,
|
15
|
+
watchForChanges: watch,
|
16
|
+
recompileOnly,
|
17
|
+
background,
|
18
|
+
entryFile,
|
19
|
+
gameOutputPath,
|
20
|
+
luaOutputPath,
|
21
|
+
requireWithinProjectPath: !entryFile,
|
22
|
+
additionalGlobs
|
28
23
|
});
|
29
|
-
const compileTasks = useCompileTasks(getPdcPathFromEnvironment(environment));
|
30
|
-
const didRun = useRef(false);
|
31
|
-
const [hasFailure, setHasFailure] = useState(false);
|
32
|
-
useEffect(()=>{
|
33
|
-
if (hasChanged) {
|
34
|
-
setHasChanged(false);
|
35
|
-
}
|
36
|
-
}, [
|
37
|
-
hasChanged,
|
38
|
-
setHasChanged
|
39
|
-
]);
|
40
|
-
const handleFinish = useCallback((hasFailure)=>{
|
41
|
-
setHasFailure(hasFailure);
|
42
|
-
if (didRun.current && recompileOnly) {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
didRun.current = true;
|
46
|
-
open('Game.pdx', {
|
47
|
-
background,
|
48
|
-
app: isMac ? undefined : {
|
49
|
-
name: getSimulatorPathFromEnvironment(environment)
|
50
|
-
}
|
51
|
-
}).then(()=>{
|
52
|
-
if (!watch) {
|
53
|
-
if (!isWindows) {
|
54
|
-
process.exit();
|
55
|
-
}
|
56
|
-
// Wait for the simulator to start
|
57
|
-
// See https://github.com/sindresorhus/open/issues/298
|
58
|
-
setTimeout(process.exit, 1000);
|
59
|
-
} else {
|
60
|
-
setHasChangedMessage(false);
|
61
|
-
if (watcher.current) {
|
62
|
-
watcher.current.close();
|
63
|
-
}
|
64
|
-
setIsWatching(true);
|
65
|
-
watcher.current = watchDir(join(path, 'src'), {
|
66
|
-
recursive: true
|
67
|
-
}, ()=>{
|
68
|
-
setHasChanged(true);
|
69
|
-
setHasChangedMessage(true);
|
70
|
-
setIsWatching(false);
|
71
|
-
});
|
72
|
-
}
|
73
|
-
});
|
74
|
-
}, [
|
75
|
-
watch,
|
76
|
-
setHasChanged,
|
77
|
-
setIsWatching
|
78
|
-
]);
|
79
|
-
const tasks = useMemo(()=>{
|
80
|
-
return [
|
81
|
-
...transpileTasks,
|
82
|
-
...compileTasks
|
83
|
-
];
|
84
|
-
}, [
|
85
|
-
transpileTasks,
|
86
|
-
compileTasks
|
87
|
-
]);
|
88
24
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, !hasChanged && /*#__PURE__*/ React.createElement(CheckList, {
|
89
25
|
items: tasks,
|
90
26
|
onFinish: handleFinish
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import {
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/SimulatorCommand/components/Simulator.tsx"],"sourcesContent":["import { join } from 'path';\nimport { StatusMessage } from '@inkjs/ui';\nimport React from 'react';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { createTemporaryFolderPathFromEntryFile } from '../fn/createTemporaryFolderPathFromEntryFile.js';\nimport { useSimulatorTasks } from '../hooks/useSimulatorTasks.js';\n\ninterface Props {\n environment: Environment;\n path: string;\n watch?: boolean;\n recompileOnly?: boolean;\n background?: boolean;\n entryFile?: string;\n additionalGlobs?: string[];\n}\n\nexport const Simulator = ({\n environment,\n path,\n watch = false,\n recompileOnly = false,\n background = false,\n entryFile,\n additionalGlobs = [],\n}: Props) => {\n const temporaryFolder = entryFile\n ? createTemporaryFolderPathFromEntryFile(entryFile)\n : undefined;\n const gameOutputPath = entryFile ? temporaryFolder : undefined;\n const luaOutputPath = entryFile\n ? temporaryFolder\n ? join(temporaryFolder, 'Source')\n : undefined\n : undefined;\n const projectPath = entryFile && temporaryFolder ? temporaryFolder : path;\n\n const {\n tasks,\n handleFinish,\n isWatching,\n hasChangedMessage,\n hasFailure,\n hasChanged,\n } = useSimulatorTasks({\n environment,\n path: projectPath,\n watchForChanges: watch,\n recompileOnly,\n background,\n entryFile,\n gameOutputPath,\n luaOutputPath,\n requireWithinProjectPath: !entryFile,\n additionalGlobs,\n });\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":["join","StatusMessage","React","CheckList","createTemporaryFolderPathFromEntryFile","useSimulatorTasks","Simulator","environment","path","watch","recompileOnly","background","entryFile","additionalGlobs","temporaryFolder","undefined","gameOutputPath","luaOutputPath","projectPath","tasks","handleFinish","isWatching","hasChangedMessage","hasFailure","hasChanged","watchForChanges","requireWithinProjectPath","items","onFinish","variant"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,aAAa,QAAQ,YAAY;AAC1C,OAAOC,WAAW,QAAQ;AAC1B,SAASC,SAAS,QAAQ,sCAAsC;AAEhE,SAASC,sCAAsC,QAAQ,kDAAkD;AACzG,SAASC,iBAAiB,QAAQ,gCAAgC;AAYlE,OAAO,MAAMC,YAAY,CAAC,EACtBC,WAAW,EACXC,IAAI,EACJC,QAAQ,KAAK,EACbC,gBAAgB,KAAK,EACrBC,aAAa,KAAK,EAClBC,SAAS,EACTC,kBAAkB,EAAE,EAChB;IACJ,MAAMC,kBAAkBF,YAClBR,uCAAuCQ,aACvCG;IACN,MAAMC,iBAAiBJ,YAAYE,kBAAkBC;IACrD,MAAME,gBAAgBL,YAChBE,kBACId,KAAKc,iBAAiB,YACtBC,YACJA;IACN,MAAMG,cAAcN,aAAaE,kBAAkBA,kBAAkBN;IAErE,MAAM,EACFW,KAAK,EACLC,YAAY,EACZC,UAAU,EACVC,iBAAiB,EACjBC,UAAU,EACVC,UAAU,EACb,GAAGnB,kBAAkB;QAClBE;QACAC,MAAMU;QACNO,iBAAiBhB;QACjBC;QACAC;QACAC;QACAI;QACAC;QACAS,0BAA0B,CAACd;QAC3BC;IACJ;IAEA,qBACI,0CACK,CAACW,4BAAc,oBAACrB;QAAUwB,OAAOR;QAAOS,UAAUR;QAClDC,cAAc,CAACC,mCACZ,0CACKC,4BACG,oBAACtB;QAAc4B,SAAQ;OAAU,qCAIrC,oBAAC5B;QAAc4B,SAAQ;OAAO,6BAKrCP,mCACG,oBAACrB;QAAc4B,SAAQ;OAAO;AAI9C,EAAE"}
|