crankscript 0.11.14 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/package.json +3 -3
  2. package/src/commands/GenerateTypes/components/GenerateTypes.js +6 -2
  3. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
  4. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +5 -2
  5. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -1
  6. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.d.ts +11 -0
  7. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js +70 -0
  8. package/src/commands/GenerateTypes/hooks/useFormatTypeFile.js.map +1 -0
  9. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +11 -4
  10. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
  11. package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +5 -35
  12. package/src/commands/GenerateTypes/types.d.ts +12 -0
  13. package/src/commands/GenerateTypes/types.js +3 -0
  14. package/src/commands/GenerateTypes/types.js.map +1 -0
  15. package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +7 -37
  16. package/src/commands/GenerateTypes/utils/createTypeProvider.js +51 -27
  17. package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
  18. package/src/commands/NewCommand/components/New.js +25 -2
  19. package/src/commands/NewCommand/components/New.js.map +1 -1
  20. package/src/commands/NewLibCommand/NewLibCommand.d.ts +10 -0
  21. package/src/commands/NewLibCommand/NewLibCommand.js +35 -0
  22. package/src/commands/NewLibCommand/NewLibCommand.js.map +1 -0
  23. package/src/commands/NewLibCommand/components/NewLib.d.ts +8 -0
  24. package/src/commands/NewLibCommand/components/NewLib.js +49 -0
  25. package/src/commands/NewLibCommand/components/NewLib.js.map +1 -0
  26. package/src/commands/NewLibCommand/index.d.ts +1 -0
  27. package/src/commands/NewLibCommand/index.js +3 -0
  28. package/src/commands/NewLibCommand/index.js.map +1 -0
  29. package/src/commands/SimulatorCommand/components/Simulator.js +12 -1
  30. package/src/commands/SimulatorCommand/components/Simulator.js.map +1 -1
  31. package/src/commands/TranspileCommand/TranspileCommand.d.ts +2 -0
  32. package/src/commands/TranspileCommand/TranspileCommand.js +20 -1
  33. package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
  34. package/src/commands/TranspileCommand/components/Transpile.d.ts +5 -2
  35. package/src/commands/TranspileCommand/components/Transpile.js +5 -2
  36. package/src/commands/TranspileCommand/components/Transpile.js.map +1 -1
  37. package/src/commands/TranspileCommand/fn/transpile.d.ts +7 -1
  38. package/src/commands/TranspileCommand/fn/transpile.js +15 -6
  39. package/src/commands/TranspileCommand/fn/transpile.js.map +1 -1
  40. package/src/commands/TranspileCommand/fn/validateEntryPoint.d.ts +5 -0
  41. package/src/commands/TranspileCommand/fn/validateEntryPoint.js +22 -0
  42. package/src/commands/TranspileCommand/fn/validateEntryPoint.js.map +1 -0
  43. package/src/commands/TranspileCommand/fn/validateExitPoint.d.ts +5 -0
  44. package/src/commands/TranspileCommand/fn/validateExitPoint.js +26 -0
  45. package/src/commands/TranspileCommand/fn/validateExitPoint.js.map +1 -0
  46. package/src/commands/TranspileCommand/hooks/useTranspileTasks.d.ts +6 -1
  47. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js +5 -2
  48. package/src/commands/TranspileCommand/hooks/useTranspileTasks.js.map +1 -1
  49. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.d.ts +11 -0
  50. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js +3 -0
  51. package/src/commands/TranspileCommand/model/ValidatedEntryPoint.js.map +1 -0
  52. package/src/commands/TranspileCommand/model/ValidatedExitPoint.d.ts +11 -0
  53. package/src/commands/TranspileCommand/model/ValidatedExitPoint.js +3 -0
  54. package/src/commands/TranspileCommand/model/ValidatedExitPoint.js.map +1 -0
  55. package/src/components/CheckList/CheckList.d.ts +3 -3
  56. package/src/components/CheckList/CheckList.js.map +1 -1
  57. package/src/components/CheckList/Item.d.ts +1 -1
  58. package/src/components/CheckList/Item.js +20 -5
  59. package/src/components/CheckList/Item.js.map +1 -1
  60. package/src/index.js +2 -0
  61. package/src/index.js.map +1 -1
  62. package/src/types.d.ts +20 -16
  63. package/src/types.js +4 -0
  64. package/src/types.js.map +1 -1
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { getErrorMessage } from '../../../commands/TranspileCommand/fn/getErrorMessage.js';
3
3
  import { transpile } from '../../../commands/TranspileCommand/fn/transpile.js';
4
- export const useTranspileTasks = (path)=>{
4
+ export const useTranspileTasks = ({ entryPoint, exitPoint })=>{
5
5
  return useMemo(()=>[
6
6
  {
7
7
  waitingDescription: 'Waiting to transpile code...',
@@ -9,7 +9,10 @@ export const useTranspileTasks = (path)=>{
9
9
  runningDescription: 'Transpiling code...',
10
10
  finishedDescription: ()=>'Code transpiled',
11
11
  runner: async ()=>{
12
- const result = transpile(path);
12
+ const result = transpile({
13
+ entryPoint,
14
+ exitPoint
15
+ });
13
16
  if (result.diagnostics.length > 0) {
14
17
  const errors = getErrorMessage(result.diagnostics);
15
18
  throw new Error(`${result.diagnostics.length === 1 ? 'An error' : 'Errors'} occurred while transpiling the code:\n${errors}`);
@@ -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 { CheckListItem } from '@/cli/types.js';\n\nexport const useTranspileTasks = (path: string) => {\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(path);\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","useTranspileTasks","path","waitingDescription","errorDescription","runningDescription","finishedDescription","runner","result","diagnostics","length","errors","Error","ready","quitOnError"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,SAASC,eAAe,QAAQ,wDAAwD;AACxF,SAASC,SAAS,QAAQ,kDAAkD;AAG5E,OAAO,MAAMC,oBAAoB,CAACC;IAC9B,OAAOJ,QACH,IAAM;YACF;gBACIK,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJ,MAAMC,SAASR,UAAUE;oBAEzB,IAAIM,OAAOC,WAAW,CAACC,MAAM,GAAG,GAAG;wBAC/B,MAAMC,SAASZ,gBAAgBS,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;SACH,EACD,EAAE;AAEV,EAAE"}
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","useTranspileTasks","entryPoint","exitPoint","waitingDescription","errorDescription","runningDescription","finishedDescription","runner","result","diagnostics","length","errors","Error","ready","quitOnError"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,SAASC,eAAe,QAAQ,wDAAwD;AACxF,SAASC,SAAS,QAAQ,kDAAkD;AAK5E,OAAO,MAAMC,oBAAoB,CAAC,EAC9BC,UAAU,EACVC,SAAS,EAIZ;IACG,OAAOL,QACH,IAAM;YACF;gBACIM,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJ,MAAMC,SAAST,UAAU;wBACrBE;wBACAC;oBACJ;oBAEA,IAAIM,OAAOC,WAAW,CAACC,MAAM,GAAG,GAAG;wBAC/B,MAAMC,SAASb,gBAAgBU,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;SACH,EACD,EAAE;AAEV,EAAE"}
@@ -0,0 +1,11 @@
1
+ export type ValidatedEntryPoint = {
2
+ __validated: true;
3
+ /**
4
+ * The path to a directory containing a tsconfig.json file
5
+ */
6
+ projectPath: string;
7
+ /**
8
+ * The entry point to transpile. Must be within the path.
9
+ */
10
+ entryFile: string;
11
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=ValidatedEntryPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/model/ValidatedEntryPoint.ts"],"sourcesContent":["export type ValidatedEntryPoint = {\n __validated: true;\n\n /**\n * The path to a directory containing a tsconfig.json file\n */\n projectPath: string;\n /**\n * The entry point to transpile. Must be within the path.\n */\n entryFile: string;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAWE"}
@@ -0,0 +1,11 @@
1
+ export type ValidatedExitPoint = {
2
+ __validated: true;
3
+ /**
4
+ * The path to a directory containing a tsconfig.json file
5
+ */
6
+ projectPath: string;
7
+ /**
8
+ * The path to the output directory. Must be within the project path.
9
+ */
10
+ exitPath: string;
11
+ };
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=ValidatedExitPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/model/ValidatedExitPoint.ts"],"sourcesContent":["export type ValidatedExitPoint = {\n __validated: true;\n\n /**\n * The path to a directory containing a tsconfig.json file\n */\n projectPath: string;\n /**\n * The path to the output directory. Must be within the project path.\n */\n exitPath: string;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WAWE"}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { CheckListItem } from '../../types.js';
3
- export interface CheckListProps {
4
- items: CheckListItem<unknown>[];
3
+ export interface CheckListProps<TResult = unknown> {
4
+ items: CheckListItem<TResult>[];
5
5
  onFinish?: (hasFailure: boolean) => void;
6
6
  }
7
- export declare const CheckList: ({ items, onFinish }: CheckListProps) => React.JSX.Element;
7
+ export declare const CheckList: <TResult>({ items, onFinish, }: CheckListProps<TResult>) => React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\nexport interface CheckListProps {\n items: CheckListItem<unknown>[];\n onFinish?: (hasFailure: boolean) => void;\n}\n\nexport const CheckList = ({ items, onFinish }: CheckListProps) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n onFinish?.(hasFailure);\n setHasFailure(false);\n }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={item.waitingDescription}\n item={{\n ...item,\n onFinish: (result: unknown) => {\n if (result === false) {\n setHasFailure(true);\n }\n\n item?.onFinish?.(result);\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","onFinish","currentIndex","setCurrentIndex","hasFailure","setHasFailure","length","handleFinish","index","map","item","key","waitingDescription","result","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,OAAO,MAAMC,YAAY,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAkB;IACzD,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,SAAwB;IAChE,MAAM,CAACO,YAAYC,cAAc,GAAGR,SAAS;IAE7CD,UAAU;QACN,IAAIM,iBAAiB,QAAQF,MAAMM,MAAM,GAAG,GAAG;YAC3CH,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcF;KAAM;IAExB,MAAMO,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIR,MAAMM,MAAM,EAAE;YAC1BH,gBAAgBK,QAAQ;QAC5B,OAAO;YACHP,4BAAAA,SAAWG;YACXC,cAAc;QAClB;IACJ;IAEA,qBACI,0CACKL,MAAMS,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACV;YACGa,KAAKD,KAAKE,kBAAkB;YAC5BF,MAAM,aACCA;gBACHT,UAAU,CAACY;wBAKPH;oBAJA,IAAIG,WAAW,OAAO;wBAClBR,cAAc;oBAClB;oBAEAK,yBAAAA,iBAAAA,KAAMT,QAAQ,qBAAdS,oBAAAA,MAAiBG;oBACjBN,aAAaC;gBACjB;;YAEJM,OAAON,UAAUN;;AAKrC,EAAE"}
1
+ {"version":3,"sources":["../../../../../../libs/cli/src/components/CheckList/CheckList.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { CheckListItem } from '@/cli/types.js';\nimport { Item } from './Item.js';\n\nexport interface CheckListProps<TResult = unknown> {\n items: CheckListItem<TResult>[];\n onFinish?: (hasFailure: boolean) => void;\n}\n\nexport const CheckList = <TResult,>({\n items,\n onFinish,\n}: CheckListProps<TResult>) => {\n const [currentIndex, setCurrentIndex] = useState<number | null>(null);\n const [hasFailure, setHasFailure] = useState(false);\n\n useEffect(() => {\n if (currentIndex === null && items.length > 0) {\n setCurrentIndex(0);\n }\n }, [currentIndex, items]);\n\n const handleFinish = (index: number) => {\n if (index + 1 < items.length) {\n setCurrentIndex(index + 1);\n } else {\n onFinish?.(hasFailure);\n setHasFailure(false);\n }\n };\n\n return (\n <>\n {items.map((item, index) => (\n <Item\n key={item.waitingDescription}\n item={{\n ...item,\n onFinish: (result: TResult | false) => {\n if (result === false) {\n setHasFailure(true);\n }\n\n item?.onFinish?.(result);\n handleFinish(index);\n },\n }}\n start={index === currentIndex}\n />\n ))}\n </>\n );\n};\n"],"names":["React","useEffect","useState","Item","CheckList","items","onFinish","currentIndex","setCurrentIndex","hasFailure","setHasFailure","length","handleFinish","index","map","item","key","waitingDescription","result","start"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,IAAI,QAAQ,YAAY;AAOjC,OAAO,MAAMC,YAAY,CAAW,EAChCC,KAAK,EACLC,QAAQ,EACc;IACtB,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,SAAwB;IAChE,MAAM,CAACO,YAAYC,cAAc,GAAGR,SAAS;IAE7CD,UAAU;QACN,IAAIM,iBAAiB,QAAQF,MAAMM,MAAM,GAAG,GAAG;YAC3CH,gBAAgB;QACpB;IACJ,GAAG;QAACD;QAAcF;KAAM;IAExB,MAAMO,eAAe,CAACC;QAClB,IAAIA,QAAQ,IAAIR,MAAMM,MAAM,EAAE;YAC1BH,gBAAgBK,QAAQ;QAC5B,OAAO;YACHP,4BAAAA,SAAWG;YACXC,cAAc;QAClB;IACJ;IAEA,qBACI,0CACKL,MAAMS,GAAG,CAAC,CAACC,MAAMF,sBACd,oBAACV;YACGa,KAAKD,KAAKE,kBAAkB;YAC5BF,MAAM,aACCA;gBACHT,UAAU,CAACY;wBAKPH;oBAJA,IAAIG,WAAW,OAAO;wBAClBR,cAAc;oBAClB;oBAEAK,yBAAAA,iBAAAA,KAAMT,QAAQ,qBAAdS,oBAAAA,MAAiBG;oBACjBN,aAAaC;gBACjB;;YAEJM,OAAON,UAAUN;;AAKrC,EAAE"}
@@ -4,4 +4,4 @@ export interface ItemProps<TResult> {
4
4
  item: CheckListItem<TResult>;
5
5
  start: boolean;
6
6
  }
7
- export declare const Item: <TResult>({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, runner, onFinish, ready, quitOnError, }, start, }: ItemProps<TResult>) => React.JSX.Element;
7
+ export declare const Item: <TResult>({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, skipDescription, runner, onFinish, ready, quitOnError, skip, }, start, }: ItemProps<TResult>) => React.JSX.Element;
@@ -2,19 +2,22 @@ import { StatusMessage } from '@inkjs/ui';
2
2
  import { Text } from 'ink';
3
3
  import React, { useEffect, useRef, useState } from 'react';
4
4
  import { Spinner } from '../../components/Spinner.js';
5
- export const Item = ({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, runner, onFinish, ready, quitOnError = true }, start })=>{
5
+ export const Item = ({ item: { runningDescription, waitingDescription, errorDescription, finishedDescription, skipDescription, runner, onFinish, ready, quitOnError = true, skip }, start })=>{
6
6
  const executed = useRef(false);
7
7
  const interval = useRef(null);
8
8
  const [dotCount, setDotCount] = useState(0);
9
9
  const [result, setResult] = useState(null);
10
10
  const [failedReason, setfailedReason] = useState(null);
11
+ const [isSkipped, setIsSkipped] = useState(false);
12
+ // Determine if the task should be skipped
13
+ const shouldSkip = typeof skip === 'function' ? skip() : skip === true;
11
14
  const hasResult = !failedReason && result !== null;
12
- const isRunning = !failedReason && !hasResult && start && ready !== false;
15
+ const isRunning = !failedReason && !hasResult && start && ready !== false && !shouldSkip;
13
16
  const isWaiting = !failedReason && !hasResult && (!start || !ready);
14
17
  const couldStartButNotReady = !failedReason && !hasResult && start && ready === false;
15
18
  useEffect(()=>{
16
19
  if (failedReason && quitOnError) {
17
- process.exit();
20
+ process.exit(1);
18
21
  }
19
22
  }, [
20
23
  failedReason,
@@ -42,6 +45,14 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
42
45
  if (!start || executed.current || ready === false) {
43
46
  return;
44
47
  }
48
+ // If the task should be skipped, mark it as executed with a success result
49
+ if (shouldSkip) {
50
+ executed.current = true;
51
+ setIsSkipped(true);
52
+ setResult(true);
53
+ onFinish == null ? void 0 : onFinish(true);
54
+ return;
55
+ }
45
56
  runner().then((result)=>{
46
57
  executed.current = true;
47
58
  if (result === false) {
@@ -59,13 +70,17 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
59
70
  errorDescription,
60
71
  onFinish,
61
72
  runner,
62
- start
73
+ start,
74
+ shouldSkip
63
75
  ]);
64
76
  let message = waitingDescription;
65
77
  let variant = 'info';
66
78
  if (failedReason) {
67
79
  message = ` ${failedReason}`;
68
80
  variant = 'error';
81
+ } else if (isSkipped) {
82
+ message = skipDescription || 'Task skipped';
83
+ variant = 'info';
69
84
  } else if (isRunning) {
70
85
  message = runningDescription;
71
86
  variant = 'warning';
@@ -82,7 +97,7 @@ export const Item = ({ item: { runningDescription, waitingDescription, errorDesc
82
97
  variant: variant
83
98
  }, /*#__PURE__*/ React.createElement(Text, {
84
99
  bold: !isWaiting,
85
- color: isRunning ? 'yellow' : isWaiting ? 'gray' : failedReason ? 'red' : 'green'
100
+ color: isRunning ? 'yellow' : isWaiting ? 'gray' : failedReason ? 'red' : isSkipped ? 'gray' : 'green'
86
101
  }, message, ' ', couldStartButNotReady && `— not ready yet${'.'.repeat(dotCount)}`));
87
102
  };
88
103
 
@@ -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';\n\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 runner,\n onFinish,\n ready,\n quitOnError = true,\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 hasResult = !failedReason && result !== null;\n const isRunning = !failedReason && !hasResult && start && ready !== false;\n const isWaiting = !failedReason && !hasResult && (!start || !ready);\n const couldStartButNotReady =\n !failedReason && !hasResult && start && ready === false;\n\n useEffect(() => {\n if (failedReason && quitOnError) {\n process.exit();\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 runner()\n .then(result => {\n executed.current = true;\n\n if (result === false) {\n setfailedReason(errorDescription);\n\n return;\n }\n\n setResult(result);\n onFinish?.(result);\n })\n .catch(reason => {\n setfailedReason(reason.message);\n setResult(false);\n onFinish?.(false);\n });\n }, [errorDescription, onFinish, runner, start]);\n\n let message = waitingDescription;\n let variant: StatusMessageProps['variant'] = 'info';\n\n if (failedReason) {\n message = ` ${failedReason}`;\n variant = 'error';\n } else if (isRunning) {\n message = runningDescription;\n variant = 'warning';\n } else if (hasResult) {\n message = finishedDescription(result);\n variant = 'success';\n }\n\n if (isRunning) {\n return <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 : 'green'\n }\n >\n {message}{' '}\n {couldStartButNotReady &&\n `— not ready yet${'.'.repeat(dotCount)}`}\n </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Text","React","useEffect","useRef","useState","Spinner","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","runner","onFinish","ready","quitOnError","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","message","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,OAAO,QAAQ,8BAA8B;AAQtD,OAAO,MAAMC,OAAO,CAAW,EAC3BC,MAAM,EACFC,kBAAkB,EAClBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACLC,cAAc,IAAI,EACrB,EACDC,KAAK,EACY;IACjB,MAAMC,WAAWd,OAAO;IACxB,MAAMe,WAAWf,OAA8B;IAC/C,MAAM,CAACgB,UAAUC,YAAY,GAAGhB,SAAS;IACzC,MAAM,CAACiB,QAAQC,UAAU,GAAGlB,SAAiC;IAC7D,MAAM,CAACmB,cAAcC,gBAAgB,GAAGpB,SAAwB;IAChE,MAAMqB,YAAY,CAACF,gBAAgBF,WAAW;IAC9C,MAAMK,YAAY,CAACH,gBAAgB,CAACE,aAAaT,SAASF,UAAU;IACpE,MAAMa,YAAY,CAACJ,gBAAgB,CAACE,aAAc,CAAA,CAACT,SAAS,CAACF,KAAI;IACjE,MAAMc,wBACF,CAACL,gBAAgB,CAACE,aAAaT,SAASF,UAAU;IAEtDZ,UAAU;QACN,IAAIqB,gBAAgBR,aAAa;YAC7Bc,QAAQC,IAAI;QAChB;IACJ,GAAG;QAACP;QAAcR;KAAY;IAE9Bb,UAAU;QACN,IAAI0B,uBAAuB;YACvBV,SAASa,OAAO,GAAGC,YAAY;gBAC3BZ,YAAYa,CAAAA,QAAS,AAACA,CAAAA,QAAQ,CAAA,IAAK;YACvC,GAAG;QACP,OAAO;YACH,IAAIf,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;QAEA,OAAO;YACH,IAAIb,SAASa,OAAO,EAAE;gBAClBG,cAAchB,SAASa,OAAO;YAClC;QACJ;IACJ,GAAG;QAACH;KAAsB;IAE1B1B,UAAU;QACN,IAAI,CAACc,SAASC,SAASc,OAAO,IAAIjB,UAAU,OAAO;YAC/C;QACJ;QAEAF,SACKuB,IAAI,CAACd,CAAAA;YACFJ,SAASc,OAAO,GAAG;YAEnB,IAAIV,WAAW,OAAO;gBAClBG,gBAAgBd;gBAEhB;YACJ;YAEAY,UAAUD;YACVR,4BAAAA,SAAWQ;QACf,GACCe,KAAK,CAACC,CAAAA;YACHb,gBAAgBa,OAAOC,OAAO;YAC9BhB,UAAU;YACVT,4BAAAA,SAAW;QACf;IACR,GAAG;QAACH;QAAkBG;QAAUD;QAAQI;KAAM;IAE9C,IAAIsB,UAAU7B;IACd,IAAI8B,UAAyC;IAE7C,IAAIhB,cAAc;QACde,UAAU,CAAC,CAAC,EAAEf,aAAa,CAAC;QAC5BgB,UAAU;IACd,OAAO,IAAIb,WAAW;QAClBY,UAAU9B;QACV+B,UAAU;IACd,OAAO,IAAId,WAAW;QAClBa,UAAU3B,oBAAoBU;QAC9BkB,UAAU;IACd;IAEA,IAAIb,WAAW;QACX,qBAAO,oBAACrB;YAAQmC,OAAOF;;IAC3B;IAEA,qBACI,oBAACvC;QAAcwC,SAASA;qBACpB,oBAACvC;QACGyC,MAAM,CAACd;QACPe,OACIhB,YACM,WACAC,YACA,SACAJ,eACA,QACA;OAGTe,SAAS,KACTV,yBACG,CAAC,eAAe,EAAE,IAAIe,MAAM,CAACxB,UAAU,CAAC;AAI5D,EAAE"}
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';\n\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 [isSkipped, setIsSkipped] = useState(false);\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 => {\n setfailedReason(reason.message);\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 </Text>\n </StatusMessage>\n );\n};\n"],"names":["StatusMessage","Text","React","useEffect","useRef","useState","Spinner","Item","item","runningDescription","waitingDescription","errorDescription","finishedDescription","skipDescription","runner","onFinish","ready","quitOnError","skip","start","executed","interval","dotCount","setDotCount","result","setResult","failedReason","setfailedReason","isSkipped","setIsSkipped","shouldSkip","hasResult","isRunning","isWaiting","couldStartButNotReady","process","exit","current","setInterval","count","clearInterval","then","catch","reason","message","variant","label","bold","color","repeat"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ import { CompileCommand } from './commands/CompileCommand/index.js';
6
6
  import { DoctorCommand } from './commands/DoctorCommand.js';
7
7
  import { GenerateTypesCommand } from './commands/GenerateTypes/index.js';
8
8
  import { NewCommand } from './commands/NewCommand/NewCommand.js';
9
+ import { NewLibCommand } from './commands/NewLibCommand/index.js';
9
10
  import { SimulatorCommand } from './commands/SimulatorCommand/index.js';
10
11
  import { TranspileCommand } from './commands/TranspileCommand/index.js';
11
12
  import { RootFolder } from './constants.js';
@@ -24,6 +25,7 @@ cli.register(Builtins.HelpCommand);
24
25
  cli.register(Builtins.VersionCommand);
25
26
  cli.register(DoctorCommand);
26
27
  cli.register(NewCommand);
28
+ cli.register(NewLibCommand);
27
29
  cli.register(TranspileCommand);
28
30
  cli.register(CompileCommand);
29
31
  cli.register(GenerateTypesCommand);
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 { 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"}
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);\ncli.runExit(args);\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"],"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;AACbW,IAAIU,OAAO,CAACd"}
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClassDeclarationStructure, FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure } from 'ts-morph';
1
+ import { ClassDeclarationStructure, FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure, PropertyDeclarationStructure, VariableDeclarationStructure } from 'ts-morph';
2
2
  import { Environment } from './environment/dto/Environment.js';
3
3
  import { PlaydateSdkPath } from './environment/path/dto/PlaydateSdkPath.js';
4
4
  export declare enum PlaydateSdkVersionIdentifier {
@@ -32,10 +32,12 @@ export type CheckListItem<TResult> = {
32
32
  waitingDescription: string;
33
33
  errorDescription: string;
34
34
  finishedDescription: (result: TResult | false) => string;
35
+ skipDescription?: string;
35
36
  runner: () => Promise<TResult> | Promise<false>;
36
37
  onFinish?: (result: TResult | false) => void;
37
38
  ready?: boolean;
38
39
  quitOnError?: boolean;
40
+ skip?: boolean | (() => boolean);
39
41
  };
40
42
  export interface ParameterDescription {
41
43
  name: string;
@@ -64,27 +66,17 @@ export interface ApiObject {
64
66
  export interface ApiDefinitions {
65
67
  global: ApiObject;
66
68
  }
67
- export interface ParameterDetails {
68
- name: string;
69
- type: string;
70
- overrideOptions?: Partial<Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>>;
71
- }
72
- export interface PropertyDetails {
69
+ export interface PropertyDetails extends Partial<PropertyDeclarationStructure> {
73
70
  signature: string;
74
- type: string;
75
- isStatic?: boolean;
76
- isReadOnly?: boolean;
77
71
  }
78
- export interface FunctionDetails {
72
+ export type FunctionDetails = {
79
73
  signature: string;
80
74
  parameters: ParameterDetails[];
81
- returnType: string;
82
75
  overrideParameters?: boolean;
83
- overrideOptions?: Partial<FunctionDeclarationStructure | MethodDeclarationStructure>;
84
- }
85
- export interface ConstantDefinition {
76
+ } & (Partial<FunctionDeclarationStructure> | Partial<MethodDeclarationStructure>);
77
+ export type ParameterDetails = ParameterDeclarationStructure;
78
+ export interface ConstantDefinition extends Partial<VariableDeclarationStructure> {
86
79
  name: string;
87
- type: string;
88
80
  }
89
81
  export type TypeProviderData = {
90
82
  globalStatements: string[];
@@ -92,6 +84,15 @@ export type TypeProviderData = {
92
84
  constants: Record<string, (ConstantDefinition | string)[]>;
93
85
  classes: Record<string, Partial<ClassDeclarationStructure>>;
94
86
  properties: Record<string, PropertyDetails>;
87
+ /**
88
+ * Properties that are described in prose rather than in formal API documentation.
89
+ * While 'properties' contains actual property definitions with their full path as the key,
90
+ * 'dynamicProperties' contains additional properties that belong to a parent namespace.
91
+ *
92
+ * For example, if the docs mention "You can access rect.x, rect.y" in prose,
93
+ * the key would be "playdate.geometry.rect" and the value would be the properties
94
+ * that should be added to that namespace.
95
+ */
95
96
  dynamicProperties: Record<string, Pick<PropertyDescription, 'name' | 'docs'>[]>;
96
97
  functions: Record<string, FunctionDetails>;
97
98
  };
@@ -101,3 +102,6 @@ export type FunctionTypeOverrideMap = Record<string, {
101
102
  export declare enum TemplateName {
102
103
  Blank = "blank"
103
104
  }
105
+ export declare enum LibraryTemplateName {
106
+ Blank = "blank"
107
+ }
package/src/types.js CHANGED
@@ -12,5 +12,9 @@ export var TemplateName;
12
12
  (function(TemplateName) {
13
13
  TemplateName["Blank"] = "blank";
14
14
  })(TemplateName || (TemplateName = {}));
15
+ export var LibraryTemplateName;
16
+ (function(LibraryTemplateName) {
17
+ LibraryTemplateName["Blank"] = "blank";
18
+ })(LibraryTemplateName || (LibraryTemplateName = {}));
15
19
 
16
20
  //# sourceMappingURL=types.js.map
package/src/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult | false) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult | false) => void;\n ready?: boolean;\n quitOnError?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n >;\n}\n\nexport interface ConstantDefinition {\n name: string;\n type: string;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n constants: Record<string, (ConstantDefinition | string)[]>;\n classes: Record<string, Partial<ClassDeclarationStructure>>;\n properties: Record<string, PropertyDetails>;\n dynamicProperties: Record<\n string,\n Pick<PropertyDescription, 'name' | 'docs'>[]\n >;\n functions: Record<string, FunctionDetails>;\n};\n\nexport type FunctionTypeOverrideMap = Record<string, { isMethod: boolean }>;\n\nexport enum TemplateName {\n Blank = 'blank',\n}\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType","TemplateName"],"rangeMappings":";;;;;;;;;;;;;","mappings":";UASYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA;;UA6GAC;;GAAAA,iBAAAA"}
1
+ {"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n PropertyDeclarationStructure,\n VariableDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult | false) => string;\n skipDescription?: string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult | false) => void;\n ready?: boolean;\n quitOnError?: boolean;\n skip?: boolean | (() => boolean);\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\n}\n\nexport interface PropertyDetails extends Partial<PropertyDeclarationStructure> {\n signature: string;\n}\n\nexport type FunctionDetails = {\n signature: string;\n parameters: ParameterDetails[];\n overrideParameters?: boolean;\n} & (\n | Partial<FunctionDeclarationStructure>\n | Partial<MethodDeclarationStructure>\n);\n\nexport type ParameterDetails = ParameterDeclarationStructure;\n\nexport interface ConstantDefinition\n extends Partial<VariableDeclarationStructure> {\n name: string;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n constants: Record<string, (ConstantDefinition | string)[]>;\n classes: Record<string, Partial<ClassDeclarationStructure>>;\n properties: Record<string, PropertyDetails>;\n /**\n * Properties that are described in prose rather than in formal API documentation.\n * While 'properties' contains actual property definitions with their full path as the key,\n * 'dynamicProperties' contains additional properties that belong to a parent namespace.\n *\n * For example, if the docs mention \"You can access rect.x, rect.y\" in prose,\n * the key would be \"playdate.geometry.rect\" and the value would be the properties\n * that should be added to that namespace.\n */\n dynamicProperties: Record<\n string,\n Pick<PropertyDescription, 'name' | 'docs'>[]\n >;\n functions: Record<string, FunctionDetails>;\n};\n\nexport type FunctionTypeOverrideMap = Record<string, { isMethod: boolean }>;\n\nexport enum TemplateName {\n Blank = 'blank',\n}\n\nexport enum LibraryTemplateName {\n Blank = 'blank',\n}\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType","TemplateName","LibraryTemplateName"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";UAWYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA;;UA8GAC;;GAAAA,iBAAAA;;UAIAC;;GAAAA,wBAAAA"}