crankscript 0.10.0 → 0.10.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/assets/plugin.js CHANGED
@@ -162,7 +162,8 @@ var transformClassDeclaration = function (declaration, context) {
162
162
  .map(function (method) { return transformMethodDeclaration(context, method, className); })
163
163
  .filter(function (method) { return method !== undefined; });
164
164
  statements.push.apply(statements, methods);
165
- // export
165
+ // export the class if needed
166
+ // todo: check if there is a cleaner way to do this
166
167
  if ('localSymbol' in declaration &&
167
168
  typeof declaration.localSymbol === 'object' &&
168
169
  'exportSymbol' in declaration.localSymbol &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crankscript",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "scripts": {
5
5
  "dev": "tsx src/index.ts",
6
6
  "post-build": "tsc-alias --project tsconfig.json",
@@ -19,6 +19,7 @@
19
19
  "react": "^18.3.1",
20
20
  "tiged": "^3.0.0-rc.0",
21
21
  "ts-morph": "^23.0.0",
22
+ "turndown": "^7.2.0",
22
23
  "typanion": "^3.14.0",
23
24
  "typescript-to-lua": "^1.27.0"
24
25
  },
@@ -1,5 +1,6 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
2
  import { load } from 'cheerio';
3
+ import Turndown from 'turndown';
3
4
  import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
4
5
  import { parseFunctionSignature } from '../../../commands/GenerateTypes/fn/parseFunctionSignature.js';
5
6
  const extractFunctionCalls = (input)=>{
@@ -21,6 +22,7 @@ export const getDescriptionsFromHtml = (html, version)=>{
21
22
  const functions = [];
22
23
  const properties = [];
23
24
  const visitedSignatures = [];
25
+ const turndown = new Turndown();
24
26
  for (const element of functionSignatures){
25
27
  var _$_attr;
26
28
  const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
@@ -39,7 +41,8 @@ export const getDescriptionsFromHtml = (html, version)=>{
39
41
  docsString = docsString.slice(0, docsString.length - '</div>'.length);
40
42
  }
41
43
  docsString = docsString.replace(/<a href="#/g, '<a href="' + PlaydateSdkUrl + version + '#');
42
- const baseDocs = id ? `${docsString}\n[Read more](${PlaydateSdkUrl}${version}#${id})` : docsString;
44
+ docsString = turndown.turndown(docsString);
45
+ const baseDocs = id ? `${docsString}\n\n[Read more](${PlaydateSdkUrl}${version}#${id})` : docsString;
43
46
  for (const title of titles){
44
47
  const signature = normalizeSignature(title);
45
48
  if (visitedSignatures.includes(signature)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('> .title').text();\n\n if (\n titleText.indexOf('#') !== -1 ||\n /[a-zA-Z]\\[/.test(titleText) ||\n /^-[a-zA-Z]/.test(titleText) ||\n /[+*/]/.test(titleText) ||\n titleText.indexOf(' - ') !== -1 ||\n titleText.indexOf(' .. ') !== -1\n ) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n const baseDocs = id\n ? `${docsString}\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AA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/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport Turndown from 'turndown';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n const turndown = new Turndown();\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('> .title').text();\n\n if (\n titleText.indexOf('#') !== -1 ||\n /[a-zA-Z]\\[/.test(titleText) ||\n /^-[a-zA-Z]/.test(titleText) ||\n /[+*/]/.test(titleText) ||\n titleText.indexOf(' - ') !== -1 ||\n titleText.indexOf(' .. ') !== -1\n ) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n docsString = turndown.turndown(docsString);\n\n const baseDocs = id\n ? `${docsString}\\n\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","Turndown","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","turndown","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,OAAOC,cAAc,WAAW;AAChC,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,sBAAsB,QAAQ,4DAA4D;AAGnG,MAAMC,uBAAuB,CAACC;IAC1B,MAAMC,oBACF;IACJ,MAAMC,UAAoB,EAAE;IAC5B,IAAIC;IAEJ,MAAO,AAACA,CAAAA,QAAQF,kBAAkBG,IAAI,CAACJ,MAAK,MAAO,KAAM;QACrDE,QAAQG,IAAI,CA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AWtB,KAAK,CACzB,GACAsB,WAAWC,MAAM,GAAG,SAASA,MAAM;QAE3C;QAEAD,aAAaA,WAAWG,OAAO,CAC3B,eACA,cAAcvC,iBAAiBiB,UAAU;QAG7CmB,aAAaZ,SAASA,QAAQ,CAACY;QAE/B,MAAMI,WAAWd,KACX,CAAC,EAAEU,WAAW,gBAAgB,EAAEpC,eAAe,EAAEiB,QAAQ,CAAC,EAAES,GAAG,CAAC,CAAC,GACjEU;QAEN,KAAK,MAAMK,SAASP,OAAQ;YACxB,MAAMvB,YAAYD,mBAAmB+B;YAErC,IAAIlB,kBAAkBmB,QAAQ,CAAC/B,YAAY;gBACvC;YACJ;YAEAY,kBAAkBf,IAAI,CAACG;YAEvB,IAAIiB,YAAY;gBACZN,WAAWd,IAAI,CAAC;oBACZmC,MAAMF,MAAMN,KAAK,CAAC,KAAKrB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;oBACnC8B,YAAYjC,UAAUwB,KAAK,CAAC,KAAKrB,KAAK,CAAC,GAAG,CAAC;oBAC3CH;oBACAkC,MAAML;gBACV;YACJ,OAAO;gBACH,IAAI;oBACA,MAAMM,cAAc7C,uBAAuBU;oBAE3C,MAAMkC,OAAOC,YAAYC,OAAO,GAC1BP,WACA,CAAC,EAAEA,SAAS,WAAW,CAAC;oBAE9BnB,UAAUb,IAAI,CAAC,aACRsC;wBACHD;;gBAER,EAAE,OAAOG,GAAG;gBACR,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,OAAO;QAAE3B;QAAWC;IAAW;AACnC,EAAE"}
@@ -3,6 +3,7 @@ import { RenderableCommand } from '../../commands/RenderableCommand.js';
3
3
  export declare const projectPathOption: string;
4
4
  export declare class TranspileCommand extends RenderableCommand {
5
5
  static paths: string[][];
6
+ static usage: import("clipanion").Usage;
6
7
  projectPath: string;
7
8
  render(): React.JSX.Element;
8
9
  }
@@ -1,5 +1,5 @@
1
1
  import process from 'node:process';
2
- import { Option } from 'clipanion';
2
+ import { Command, Option } from 'clipanion';
3
3
  import React from 'react';
4
4
  import * as t from 'typanion';
5
5
  import { RenderableCommand } from '../../commands/RenderableCommand.js';
@@ -24,5 +24,8 @@ TranspileCommand.paths = [
24
24
  'transpile'
25
25
  ]
26
26
  ];
27
+ TranspileCommand.usage = Command.Usage({
28
+ description: 'Transpile TypeScript files to Lua'
29
+ });
27
30
 
28
31
  //# sourceMappingURL=TranspileCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { 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 projectPath = projectPathOption;\n\n override render() {\n return <Transpile path={this.projectPath} />;\n }\n}\n"],"names":["process","Option","React","t","RenderableCommand","Transpile","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","path","projectPath","paths"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,SAASC,MAAM,QAAQ,YAAY;AACnC,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,SAAS,QAAQ,0DAA0D;AAEpF,OAAO,MAAMC,oBAAoBL,OAAOM,MAAM,CAAC,aAAaP,QAAQQ,GAAG,IAAI;IACvEC,aAAa,CAAC,uEAAuE,EAAET,QAAQQ,GAAG,GAAG,EAAE,CAAC;IACxGE,WAAWP,EAAEQ,QAAQ;AACzB,GAAG;AAEH,OAAO,MAAMC,yBAAyBR;IAKzBS,SAAS;QACd,qBAAO,oBAACR;YAAUS,MAAM,IAAI,CAACC,WAAW;;IAC5C;;;aAJAA,cAAcT;;AAKlB;AARaM,iBACOI,QAAQ;IAAC;QAAC;KAAY;CAAC"}
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 return <Transpile path={this.projectPath} />;\n }\n}\n"],"names":["process","Command","Option","React","t","RenderableCommand","Transpile","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","path","projectPath","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;AAEpF,OAAO,MAAMC,oBAAoBL,OAAOM,MAAM,CAAC,aAAaR,QAAQS,GAAG,IAAI;IACvEC,aAAa,CAAC,uEAAuE,EAAEV,QAAQS,GAAG,GAAG,EAAE,CAAC;IACxGE,WAAWP,EAAEQ,QAAQ;AACzB,GAAG;AAEH,OAAO,MAAMC,yBAAyBR;IASzBS,SAAS;QACd,qBAAO,oBAACR;YAAUS,MAAM,IAAI,CAACC,WAAW;;IAC5C;;;aAJAA,cAAcT;;AAKlB;AAZaM,iBACOI,QAAQ;IAAC;QAAC;KAAY;CAAC;AAD9BJ,iBAGOK,QAAQjB,QAAQkB,KAAK,CAAC;IAClCT,aAAa;AACjB"}
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node --no-warnings=ExperimentalWarning
2
2
  import { readFileSync } from 'fs';
3
3
  import { join } from 'node:path';
4
- import { Cli } from 'clipanion';
4
+ import { Builtins, Cli } from 'clipanion';
5
5
  import { CompileCommand } from './commands/CompileCommand/index.js';
6
6
  import { DoctorCommand } from './commands/DoctorCommand.js';
7
7
  import { GenerateTypesCommand } from './commands/GenerateTypes/index.js';
@@ -20,6 +20,8 @@ const cli = new Cli({
20
20
  process.on('SIGINT', function() {
21
21
  process.exit();
22
22
  });
23
+ cli.register(Builtins.HelpCommand);
24
+ cli.register(Builtins.VersionCommand);
23
25
  cli.register(DoctorCommand);
24
26
  cli.register(NewCommand);
25
27
  cli.register(TranspileCommand);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Cli } from 'clipanion';\nimport { 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 { 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(DoctorCommand);\ncli.register(NewCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","NewCommand","SimulatorCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","on","exit","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,cAAc,QAAQ,yCAAyC;AACxE,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,UAAU,QAAQ,0CAA0C;AACrE,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBV,aACxBC,KAAKQ,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIhB,IAAI;IAChBiB,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAP,QAAQQ,EAAE,CAAC,UAAU;IACjBR,QAAQS,IAAI;AAChB;AAEAN,IAAIO,QAAQ,CAACrB;AACbc,IAAIO,QAAQ,CAACnB;AACbY,IAAIO,QAAQ,CAACjB;AACbU,IAAIO,QAAQ,CAACtB;AACbe,IAAIO,QAAQ,CAACpB;AACba,IAAIO,QAAQ,CAAClB;AACbW,IAAIQ,OAAO,CAACZ"}
1
+ {"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { 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 { 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(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Builtins","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","NewCommand","SimulatorCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","on","exit","register","HelpCommand","VersionCommand","runExit"],"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,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBX,aACxBC,KAAKS,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIhB,IAAI;IAChBiB,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAP,QAAQQ,EAAE,CAAC,UAAU;IACjBR,QAAQS,IAAI;AAChB;AAEAN,IAAIO,QAAQ,CAACxB,SAASyB,WAAW;AACjCR,IAAIO,QAAQ,CAACxB,SAAS0B,cAAc;AACpCT,IAAIO,QAAQ,CAACrB;AACbc,IAAIO,QAAQ,CAACnB;AACbY,IAAIO,QAAQ,CAACjB;AACbU,IAAIO,QAAQ,CAACtB;AACbe,IAAIO,QAAQ,CAACpB;AACba,IAAIO,QAAQ,CAAClB;AACbW,IAAIU,OAAO,CAACd"}