crankscript 0.4.0 → 0.5.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 (71) hide show
  1. package/package.json +25 -26
  2. package/src/commands/DoctorCommand.js +2 -2
  3. package/src/commands/DoctorCommand.js.map +1 -1
  4. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.d.ts +2 -2
  5. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js +4 -4
  6. package/src/commands/EnvironmentAwareCommand/EnvironmentAwareCommand.js.map +1 -1
  7. package/src/commands/EnvironmentAwareCommand/components/HealthReport.d.ts +3 -3
  8. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js +16 -22
  9. package/src/commands/EnvironmentAwareCommand/components/HealthReport.js.map +1 -1
  10. package/src/commands/GenerateTypes/GenerateTypesCommand.d.ts +4 -4
  11. package/src/commands/GenerateTypes/GenerateTypesCommand.js +15 -9
  12. package/src/commands/GenerateTypes/GenerateTypesCommand.js.map +1 -1
  13. package/src/commands/GenerateTypes/components/GenerateTypes.d.ts +4 -3
  14. package/src/commands/GenerateTypes/components/GenerateTypes.js +12 -8
  15. package/src/commands/GenerateTypes/components/GenerateTypes.js.map +1 -1
  16. package/src/commands/GenerateTypes/fn/generateNamespace.d.ts +3 -0
  17. package/src/commands/GenerateTypes/fn/generateNamespace.js +33 -0
  18. package/src/commands/GenerateTypes/fn/generateNamespace.js.map +1 -0
  19. package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +14 -0
  20. package/src/commands/GenerateTypes/fn/getApiDefinitions.js +58 -0
  21. package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -0
  22. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.d.ts +2 -0
  23. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js +37 -0
  24. package/src/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js.map +1 -0
  25. package/src/commands/GenerateTypes/fn/parseFunctionSignature.d.ts +10 -0
  26. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js +24 -0
  27. package/src/commands/GenerateTypes/fn/parseFunctionSignature.js.map +1 -0
  28. package/src/commands/GenerateTypes/hooks/useFetchHtml.js +1 -1
  29. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.d.ts +2 -1
  30. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +29 -9
  31. package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
  32. package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +2 -2
  33. package/src/commands/GenerateTypes/hooks/useGetVersion.js +2 -2
  34. package/src/commands/GenerateTypes/hooks/useGetVersion.js.map +1 -1
  35. package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +25 -0
  36. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js +33 -0
  37. package/src/commands/GenerateTypes/hooks/useParseDocumentation.js.map +1 -0
  38. package/src/commands/GenerateTypes/utils/playdateConstants.d.ts +9 -0
  39. package/src/commands/GenerateTypes/utils/playdateConstants.js +134 -0
  40. package/src/commands/GenerateTypes/utils/playdateConstants.js.map +1 -0
  41. package/src/components/CheckList/CheckList.d.ts +1 -1
  42. package/src/components/CheckList/Item.d.ts +1 -1
  43. package/src/constants.d.ts +1 -0
  44. package/src/constants.js +5 -0
  45. package/src/constants.js.map +1 -1
  46. package/src/environment/createEnvironment.js +8 -24
  47. package/src/environment/createEnvironment.js.map +1 -1
  48. package/src/environment/dto/Environment.d.ts +1 -4
  49. package/src/environment/dto/Environment.js +1 -2
  50. package/src/environment/dto/Environment.js.map +1 -1
  51. package/src/index.d.ts +1 -1
  52. package/src/index.js +4 -4
  53. package/src/index.js.map +1 -1
  54. package/src/types.d.ts +44 -10
  55. package/src/types.js +6 -12
  56. package/src/types.js.map +1 -1
  57. package/src/environment/configuration/ConfigurationSchema.d.ts +0 -9
  58. package/src/environment/configuration/ConfigurationSchema.js +0 -9
  59. package/src/environment/configuration/ConfigurationSchema.js.map +0 -1
  60. package/src/environment/configuration/dto/Configuration.d.ts +0 -4
  61. package/src/environment/configuration/dto/Configuration.js +0 -7
  62. package/src/environment/configuration/dto/Configuration.js.map +0 -1
  63. package/src/environment/configuration/error/ConfigurationFileNotFoundError.d.ts +0 -4
  64. package/src/environment/configuration/error/ConfigurationFileNotFoundError.js +0 -8
  65. package/src/environment/configuration/error/ConfigurationFileNotFoundError.js.map +0 -1
  66. package/src/environment/configuration/error/ConfigurationFileValidationError.d.ts +0 -5
  67. package/src/environment/configuration/error/ConfigurationFileValidationError.js +0 -8
  68. package/src/environment/configuration/error/ConfigurationFileValidationError.js.map +0 -1
  69. package/src/environment/configuration/getConfiguration.d.ts +0 -4
  70. package/src/environment/configuration/getConfiguration.js +0 -31
  71. package/src/environment/configuration/getConfiguration.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { getHtmlForVersion } from '../../../commands/GenerateTypes/fn/getHtmlForVersion.js';
2
+ import { getHtmlForVersion } from '@/cli/commands/GenerateTypes/fn/getHtmlForVersion.js';
3
3
  export const useFetchHtml = (version)=>{
4
4
  const [html, setHtml] = useState(null);
5
5
  const fetchHtml = useMemo(()=>{
@@ -1,4 +1,5 @@
1
- export declare const useGenerateTypeFile: (path: string, html: string | null) => {
1
+ import { ApiDefinitions } from '@/cli/types.js';
2
+ export declare const useGenerateTypeFile: (path: string, definitions: ApiDefinitions | null) => {
2
3
  generateTypeFile: {
3
4
  waitingDescription: string;
4
5
  errorDescription: string;
@@ -1,8 +1,7 @@
1
- import { join } from 'node:path';
2
- import { load } from 'cheerio';
3
1
  import { useMemo } from 'react';
4
2
  import { Project } from 'ts-morph';
5
- export const useGenerateTypeFile = (path, html)=>{
3
+ import { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';
4
+ export const useGenerateTypeFile = (path, definitions)=>{
6
5
  const generateTypeFile = useMemo(()=>{
7
6
  return {
8
7
  waitingDescription: 'Waiting to generate the type file...',
@@ -10,21 +9,42 @@ export const useGenerateTypeFile = (path, html)=>{
10
9
  finishedDescription: ()=>'Type file generated',
11
10
  runningDescription: 'Generating the type file...',
12
11
  runner: async ()=>{
13
- if (!html) {
14
- throw new Error('HTML is not set');
12
+ if (!definitions) {
13
+ throw new Error('Definitions are not set');
15
14
  }
16
15
  const project = new Project();
17
- const typeFile = project.createSourceFile(join(path, 'playdate.d.ts'), '', {
16
+ const typeFile = project.createSourceFile(path, '', {
18
17
  overwrite: true
19
18
  });
20
19
  typeFile.addStatements('/// <reference types="lua-types/5.4" />');
21
- const $ = load(html);
20
+ for (const constantDefinition of definitions.constants){
21
+ typeFile.addEnum({
22
+ name: constantDefinition.name,
23
+ docs: [
24
+ constantDefinition.docs
25
+ ],
26
+ isConst: true,
27
+ isExported: true,
28
+ members: constantDefinition.values.map((value)=>({
29
+ name: value.name,
30
+ docs: [
31
+ value.docs
32
+ ],
33
+ value: value.value
34
+ }))
35
+ });
36
+ }
37
+ Object.keys(definitions.namespaces).forEach((namespace)=>{
38
+ const namespaceDescription = definitions.namespaces[namespace];
39
+ const namespaces = namespace.split('.');
40
+ generateNamespace(typeFile, namespaces[0], namespaceDescription, namespaces.slice(1));
41
+ });
22
42
  typeFile.saveSync();
23
43
  },
24
- ready: html !== null
44
+ ready: definitions !== null
25
45
  };
26
46
  }, [
27
- html
47
+ definitions
28
48
  ]);
29
49
  return {
30
50
  generateTypeFile
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { load } from 'cheerio';\nimport { useMemo } from 'react';\nimport { Project } from 'ts-morph';\nimport { CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (path: string, html: string | null) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(\n join(path, 'playdate.d.ts'),\n '',\n {\n overwrite: true,\n }\n );\n\n typeFile.addStatements(\n '/// <reference types=\"lua-types/5.4\" />'\n );\n\n const $ = load(html);\n\n typeFile.saveSync();\n },\n ready: html !== null,\n } satisfies CheckListItem<void>;\n }, [html]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["join","load","useMemo","Project","useGenerateTypeFile","path","html","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","$","saveSync","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,OAAO,QAAQ,WAAW;AAGnC,OAAO,MAAMC,sBAAsB,CAACC,MAAcC;IAC9C,MAAMC,mBAAmBL,QAAQ;QAC7B,OAAO;YACHM,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACN,MAAM;oBACP,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIX;gBACpB,MAAMY,WAAWD,QAAQE,gBAAgB,CACrChB,KAAKK,MAAM,kBACX,IACA;oBACIY,WAAW;gBACf;gBAGJF,SAASG,aAAa,CAClB;gBAGJ,MAAMC,IAAIlB,KAAKK;gBAEfS,SAASK,QAAQ;YACrB;YACAC,OAAOf,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHC;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { Project } from 'ts-morph';\nimport { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n\n typeFile.addStatements(\n '/// <reference types=\"lua-types/5.4\" />'\n );\n\n for (const constantDefinition of definitions.constants) {\n typeFile.addEnum({\n name: constantDefinition.name,\n docs: [constantDefinition.docs],\n isConst: true,\n isExported: true,\n members: constantDefinition.values.map((value) => ({\n name: value.name,\n docs: [value.docs],\n value: value.value,\n })),\n });\n }\n\n Object.keys(definitions.namespaces).forEach((namespace) => {\n const namespaceDescription =\n definitions.namespaces[namespace];\n const namespaces = namespace.split('.');\n generateNamespace(\n typeFile,\n namespaces[0],\n namespaceDescription,\n namespaces.slice(1)\n );\n });\n\n typeFile.saveSync();\n },\n ready: definitions !== null,\n } satisfies CheckListItem<void>;\n }, [definitions]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["useMemo","Project","generateNamespace","useGenerateTypeFile","path","definitions","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","constantDefinition","constants","addEnum","name","docs","isConst","isExported","members","values","map","value","Object","keys","namespaces","forEach","namespace","namespaceDescription","split","slice","saveSync","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,QAAQ;AAChC,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,iBAAiB,QAAQ,uDAAuD;AAGzF,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC;IAEA,MAAMC,mBAAmBN,QAAQ;QAC7B,OAAO;YACHO,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACN,aAAa;oBACd,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIZ;gBACpB,MAAMa,WAAWD,QAAQE,gBAAgB,CAACX,MAAM,IAAI;oBAChDY,WAAW;gBACf;gBAEAF,SAASG,aAAa,CAClB;gBAGJ,KAAK,MAAMC,sBAAsBb,YAAYc,SAAS,CAAE;oBACpDL,SAASM,OAAO,CAAC;wBACbC,MAAMH,mBAAmBG,IAAI;wBAC7BC,MAAM;4BAACJ,mBAAmBI,IAAI;yBAAC;wBAC/BC,SAAS;wBACTC,YAAY;wBACZC,SAASP,mBAAmBQ,MAAM,CAACC,GAAG,CAAC,CAACC,QAAW,CAAA;gCAC/CP,MAAMO,MAAMP,IAAI;gCAChBC,MAAM;oCAACM,MAAMN,IAAI;iCAAC;gCAClBM,OAAOA,MAAMA,KAAK;4BACtB,CAAA;oBACJ;gBACJ;gBAEAC,OAAOC,IAAI,CAACzB,YAAY0B,UAAU,EAAEC,OAAO,CAAC,CAACC;oBACzC,MAAMC,uBACF7B,YAAY0B,UAAU,CAACE,UAAU;oBACrC,MAAMF,aAAaE,UAAUE,KAAK,CAAC;oBACnCjC,kBACIY,UACAiB,UAAU,CAAC,EAAE,EACbG,sBACAH,WAAWK,KAAK,CAAC;gBAEzB;gBAEAtB,SAASuB,QAAQ;YACrB;YACAC,OAAOjC,gBAAgB;QAC3B;IACJ,GAAG;QAACA;KAAY;IAEhB,OAAO;QACHC;IACJ;AACJ,EAAE"}
@@ -1,5 +1,5 @@
1
- import { ConfigurationType } from '../../../environment/configuration/ConfigurationSchema.js';
2
- export declare const useGetVersion: (version: ConfigurationType["version"]) => {
1
+ import { PlaydateSdkVersion } from '@/cli/types.js';
2
+ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
3
3
  fetchedVersion: string | null;
4
4
  getVersion: {
5
5
  waitingDescription: string;
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from 'react';
2
- import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
3
- import { PlaydateSdkVersionIdentifier } from '../../../types.js';
2
+ import { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';
3
+ import { PlaydateSdkVersionIdentifier } from '@/cli/types.js';
4
4
  export const useGetVersion = (version)=>{
5
5
  const [result, setResult] = useState(null);
6
6
  const fetchLastVersion = useCallback(async ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { ConfigurationType } from '@/cli/environment/configuration/ConfigurationSchema.js';\nimport { CheckListItem, PlaydateSdkVersionIdentifier } from '@/cli/types.js';\n\nexport const useGetVersion = (version: ConfigurationType['version']) => {\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: (result) => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n return versionLiteral;\n },\n onFinish: (result) => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","PlaydateSdkVersionIdentifier","useGetVersion","version","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,cAAc,QAAQ,4CAA4C;AAE3E,SAAwBC,4BAA4B,QAAQ,iBAAiB;AAE7E,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,CAACC,QAAQC,UAAU,GAAGN,SAAwB;IACpD,MAAMO,mBAAmBT,YAAY;QACjC,MAAMU,WAAW,MAAMC,MAAMR;QAC7B,MAAMS,MAAMF,SAASE,GAAG;QAExB,MAAMC,QAAQ;QACd,MAAMC,QAAQF,IAAIE,KAAK,CAACD;QAExB,IAAI,CAACC,SAASA,MAAMC,MAAM,GAAG,GAAG;YAC5B,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOF,KAAK,CAAC,EAAE;IACnB,GAAG,EAAE;IACL,MAAMG,kBAAkBjB,YAAY,OAAOM;QACvC,MAAMI,WAAW,MAAMC,MAAM,CAAC,sBAAsB,EAAEL,QAAQ,CAAC,CAAC;QAEhE,IAAI,CAACI,SAASQ,EAAE,EAAE;YACd,MAAM,IAAIF,MAAM,CAAC,wBAAwB,EAAEV,QAAQ,CAAC;QACxD;QAEA,OAAO;IACX,GAAG,EAAE;IAEL,MAAMa,aAAalB,QAAQ;QACvB,OAAO;YACHmB,oBAAoB,CAAC,wBAAwB,CAAC;YAC9CC,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,CAAChB,SAAW,CAAC,gBAAgB,EAAEA,OAAO,CAAC;YAC5DiB,QAAQ;gBACJ,IAAIC,iBAAiBnB;gBAErB,IAAIA,YAAYF,6BAA6BsB,MAAM,EAAE;oBACjDD,iBAAiB,MAAMhB;gBAC3B;gBAEA,MAAMQ,gBAAgBQ;gBAEtB,OAAOA;YACX;YACAE,UAAU,CAACpB;gBACPC,UAAUD;YACd;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGetVersion.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport {\n CheckListItem,\n PlaydateSdkVersion,\n PlaydateSdkVersionIdentifier,\n} from '@/cli/types.js';\n\nexport const useGetVersion = (version: PlaydateSdkVersion) => {\n const [result, setResult] = useState<string | null>(null);\n const fetchLastVersion = useCallback(async () => {\n const response = await fetch(PlaydateSdkUrl);\n const url = response.url;\n\n const regex = /https:\\/\\/sdk.play.date\\/([0-9]+\\.[0-9]+\\.[0-9]+)\\//;\n const match = url.match(regex);\n\n if (!match || match.length < 2) {\n throw new Error('Could not find version in URL');\n }\n\n return match[1];\n }, []);\n const validateVersion = useCallback(async (version: string) => {\n const response = await fetch(`https://sdk.play.date/${version}/`);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch version ${version}`);\n }\n\n return true;\n }, []);\n\n const getVersion = useMemo(() => {\n return {\n waitingDescription: `Waiting to fetch version`,\n runningDescription: 'Fetching version...',\n errorDescription: 'Failed to fetch version',\n finishedDescription: (result) => `Fetched version ${result}`,\n runner: async () => {\n let versionLiteral = version;\n\n if (version === PlaydateSdkVersionIdentifier.Latest) {\n versionLiteral = await fetchLastVersion();\n }\n\n await validateVersion(versionLiteral);\n\n return versionLiteral;\n },\n onFinish: (result) => {\n setResult(result);\n },\n } satisfies CheckListItem<string>;\n }, []);\n\n return {\n fetchedVersion: result,\n getVersion,\n };\n};\n"],"names":["useCallback","useMemo","useState","PlaydateSdkUrl","PlaydateSdkVersionIdentifier","useGetVersion","version","result","setResult","fetchLastVersion","response","fetch","url","regex","match","length","Error","validateVersion","ok","getVersion","waitingDescription","runningDescription","errorDescription","finishedDescription","runner","versionLiteral","Latest","onFinish","fetchedVersion"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACvD,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAGIC,4BAA4B,QACzB,iBAAiB;AAExB,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,MAAM,CAACC,QAAQC,UAAU,GAAGN,SAAwB;IACpD,MAAMO,mBAAmBT,YAAY;QACjC,MAAMU,WAAW,MAAMC,MAAMR;QAC7B,MAAMS,MAAMF,SAASE,GAAG;QAExB,MAAMC,QAAQ;QACd,MAAMC,QAAQF,IAAIE,KAAK,CAACD;QAExB,IAAI,CAACC,SAASA,MAAMC,MAAM,GAAG,GAAG;YAC5B,MAAM,IAAIC,MAAM;QACpB;QAEA,OAAOF,KAAK,CAAC,EAAE;IACnB,GAAG,EAAE;IACL,MAAMG,kBAAkBjB,YAAY,OAAOM;QACvC,MAAMI,WAAW,MAAMC,MAAM,CAAC,sBAAsB,EAAEL,QAAQ,CAAC,CAAC;QAEhE,IAAI,CAACI,SAASQ,EAAE,EAAE;YACd,MAAM,IAAIF,MAAM,CAAC,wBAAwB,EAAEV,QAAQ,CAAC;QACxD;QAEA,OAAO;IACX,GAAG,EAAE;IAEL,MAAMa,aAAalB,QAAQ;QACvB,OAAO;YACHmB,oBAAoB,CAAC,wBAAwB,CAAC;YAC9CC,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,CAAChB,SAAW,CAAC,gBAAgB,EAAEA,OAAO,CAAC;YAC5DiB,QAAQ;gBACJ,IAAIC,iBAAiBnB;gBAErB,IAAIA,YAAYF,6BAA6BsB,MAAM,EAAE;oBACjDD,iBAAiB,MAAMhB;gBAC3B;gBAEA,MAAMQ,gBAAgBQ;gBAEtB,OAAOA;YACX;YACAE,UAAU,CAACpB;gBACPC,UAAUD;YACd;QACJ;IACJ,GAAG,EAAE;IAEL,OAAO;QACHqB,gBAAgBrB;QAChBY;IACJ;AACJ,EAAE"}
@@ -0,0 +1,25 @@
1
+ import { ApiDefinitions } from '@/cli/types.js';
2
+ export declare const useParseDocumentation: (html: string | null, version: string) => {
3
+ definitions: ApiDefinitions | null;
4
+ parseDocumentation: {
5
+ waitingDescription: string;
6
+ errorDescription: string;
7
+ finishedDescription: () => string;
8
+ runningDescription: string;
9
+ runner: () => Promise<{
10
+ namespaces: Record<string, import("@/cli/types.js").PlaydateNamespace>;
11
+ types: Record<string, import("@/cli/types.js").PlaydateType>;
12
+ constants: {
13
+ name: string;
14
+ values: {
15
+ name: string;
16
+ value: number;
17
+ docs: string;
18
+ }[];
19
+ docs: string;
20
+ }[];
21
+ }>;
22
+ onFinish: (result: ApiDefinitions) => void;
23
+ ready: boolean;
24
+ };
25
+ };
@@ -0,0 +1,33 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';
3
+ import { getFunctionDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js';
4
+ export const useParseDocumentation = (html, version)=>{
5
+ const [result, setResult] = useState(null);
6
+ const parseDocumentation = useMemo(()=>{
7
+ return {
8
+ waitingDescription: 'Waiting to parse the documentation...',
9
+ errorDescription: 'Failed to parse the documentation',
10
+ finishedDescription: ()=>'Documentation parsed',
11
+ runningDescription: 'Parsing the documentation...',
12
+ runner: async ()=>{
13
+ if (!html) {
14
+ throw new Error('HTML is not set');
15
+ }
16
+ const functions = getFunctionDescriptionsFromHtml(html, version);
17
+ return getApiDefinitions(functions);
18
+ },
19
+ onFinish: (result)=>{
20
+ setResult(result);
21
+ },
22
+ ready: html !== null
23
+ };
24
+ }, [
25
+ html
26
+ ]);
27
+ return {
28
+ definitions: result,
29
+ parseDocumentation
30
+ };
31
+ };
32
+
33
+ //# sourceMappingURL=useParseDocumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useParseDocumentation.ts"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { getApiDefinitions } from '@/cli/commands/GenerateTypes/fn/getApiDefinitions.js';\nimport { getFunctionDescriptionsFromHtml } from '@/cli/commands/GenerateTypes/fn/getFunctionDescriptionsFromHtml.js';\nimport { CheckListItem, ApiDefinitions } from '@/cli/types.js';\n\nexport const useParseDocumentation = (html: string | null, version: string) => {\n const [result, setResult] = useState<ApiDefinitions | null>(null);\n\n const parseDocumentation = useMemo(() => {\n return {\n waitingDescription: 'Waiting to parse the documentation...',\n errorDescription: 'Failed to parse the documentation',\n finishedDescription: () => 'Documentation parsed',\n runningDescription: 'Parsing the documentation...',\n runner: async () => {\n if (!html) {\n throw new Error('HTML is not set');\n }\n\n const functions = getFunctionDescriptionsFromHtml(\n html,\n version\n );\n\n return getApiDefinitions(functions);\n },\n onFinish: (result) => {\n setResult(result);\n },\n ready: html !== null,\n } satisfies CheckListItem<ApiDefinitions>;\n }, [html]);\n\n return {\n definitions: result,\n parseDocumentation,\n };\n};\n"],"names":["useMemo","useState","getApiDefinitions","getFunctionDescriptionsFromHtml","useParseDocumentation","html","version","result","setResult","parseDocumentation","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","functions","onFinish","ready","definitions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,+BAA+B,QAAQ,qEAAqE;AAGrH,OAAO,MAAMC,wBAAwB,CAACC,MAAqBC;IACvD,MAAM,CAACC,QAAQC,UAAU,GAAGP,SAAgC;IAE5D,MAAMQ,qBAAqBT,QAAQ;QAC/B,OAAO;YACHU,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACT,MAAM;oBACP,MAAM,IAAIU,MAAM;gBACpB;gBAEA,MAAMC,YAAYb,gCACdE,MACAC;gBAGJ,OAAOJ,kBAAkBc;YAC7B;YACAC,UAAU,CAACV;gBACPC,UAAUD;YACd;YACAW,OAAOb,SAAS;QACpB;IACJ,GAAG;QAACA;KAAK;IAET,OAAO;QACHc,aAAaZ;QACbE;IACJ;AACJ,EAAE"}
@@ -0,0 +1,9 @@
1
+ export declare const playdateConstants: {
2
+ name: string;
3
+ values: {
4
+ name: string;
5
+ value: number;
6
+ docs: string;
7
+ }[];
8
+ docs: string;
9
+ }[];
@@ -0,0 +1,134 @@
1
+ export const playdateConstants = [
2
+ {
3
+ name: 'PlaydateColor',
4
+ values: [
5
+ {
6
+ name: 'Black',
7
+ value: 0,
8
+ docs: ''
9
+ },
10
+ {
11
+ name: 'White',
12
+ value: 1,
13
+ docs: ''
14
+ },
15
+ {
16
+ name: 'Clear',
17
+ value: 2,
18
+ docs: ''
19
+ },
20
+ {
21
+ name: 'XOR',
22
+ value: 4,
23
+ docs: ''
24
+ }
25
+ ],
26
+ docs: ''
27
+ },
28
+ {
29
+ name: 'PlaydateImageFlip',
30
+ values: [
31
+ {
32
+ name: 'Unflipped',
33
+ value: 0,
34
+ docs: ''
35
+ },
36
+ {
37
+ name: 'FlippedX',
38
+ value: 1,
39
+ docs: ''
40
+ },
41
+ {
42
+ name: 'FlippedY',
43
+ value: 2,
44
+ docs: ''
45
+ },
46
+ {
47
+ name: 'FlippedXY',
48
+ value: 4,
49
+ docs: ''
50
+ }
51
+ ],
52
+ docs: ''
53
+ },
54
+ {
55
+ name: 'PlaydatePolygonFill',
56
+ values: [
57
+ {
58
+ name: 'NonZero',
59
+ value: 1,
60
+ docs: ''
61
+ },
62
+ {
63
+ name: 'EvenOdd',
64
+ value: 2,
65
+ docs: ''
66
+ }
67
+ ],
68
+ docs: ''
69
+ },
70
+ {
71
+ name: 'PlaydateButton',
72
+ values: [
73
+ {
74
+ name: 'Left',
75
+ value: 1,
76
+ docs: ''
77
+ },
78
+ {
79
+ name: 'Right',
80
+ value: 2,
81
+ docs: ''
82
+ },
83
+ {
84
+ name: 'Up',
85
+ value: 4,
86
+ docs: ''
87
+ },
88
+ {
89
+ name: 'Down',
90
+ value: 8,
91
+ docs: ''
92
+ },
93
+ {
94
+ name: 'B',
95
+ value: 16,
96
+ docs: ''
97
+ },
98
+ {
99
+ name: 'A',
100
+ value: 32,
101
+ docs: ''
102
+ },
103
+ {
104
+ name: 'Menu',
105
+ value: 64,
106
+ docs: ''
107
+ },
108
+ {
109
+ name: 'Lock',
110
+ value: 124,
111
+ docs: ''
112
+ }
113
+ ],
114
+ docs: ''
115
+ },
116
+ {
117
+ name: 'PlaydateLanguage',
118
+ values: [
119
+ {
120
+ name: 'English',
121
+ value: 1,
122
+ docs: ''
123
+ },
124
+ {
125
+ name: 'Japanese',
126
+ value: 2,
127
+ docs: ''
128
+ }
129
+ ],
130
+ docs: ''
131
+ }
132
+ ];
133
+
134
+ //# sourceMappingURL=playdateConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/playdateConstants.ts"],"sourcesContent":["import { ConstantDescription } from '@/cli/types.js';\n\nexport const playdateConstants = [\n {\n name: 'PlaydateColor',\n values: [\n { name: 'Black', value: 0, docs: '' },\n { name: 'White', value: 1, docs: '' },\n { name: 'Clear', value: 2, docs: '' },\n { name: 'XOR', value: 4, docs: '' },\n ],\n docs: '',\n },\n {\n name: 'PlaydateImageFlip',\n values: [\n { name: 'Unflipped', value: 0, docs: '' },\n { name: 'FlippedX', value: 1, docs: '' },\n { name: 'FlippedY', value: 2, docs: '' },\n { name: 'FlippedXY', value: 4, docs: '' },\n ],\n docs: '',\n },\n {\n name: 'PlaydatePolygonFill',\n values: [\n { name: 'NonZero', value: 1, docs: '' },\n { name: 'EvenOdd', value: 2, docs: '' },\n ],\n docs: '',\n },\n {\n name: 'PlaydateButton',\n values: [\n { name: 'Left', value: 1, docs: '' },\n { name: 'Right', value: 2, docs: '' },\n { name: 'Up', value: 4, docs: '' },\n { name: 'Down', value: 8, docs: '' },\n { name: 'B', value: 16, docs: '' },\n { name: 'A', value: 32, docs: '' },\n { name: 'Menu', value: 64, docs: '' },\n { name: 'Lock', value: 124, docs: '' },\n ],\n docs: '',\n },\n {\n name: 'PlaydateLanguage',\n values: [\n { name: 'English', value: 1, docs: '' },\n { name: 'Japanese', value: 2, docs: '' },\n ],\n docs: '',\n },\n] satisfies ConstantDescription[];\n"],"names":["playdateConstants","name","values","value","docs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAO,MAAMA,oBAAoB;IAC7B;QACIC,MAAM;QACNC,QAAQ;YACJ;gBAAED,MAAM;gBAASE,OAAO;gBAAGC,MAAM;YAAG;YACpC;gBAAEH,MAAM;gBAASE,OAAO;gBAAGC,MAAM;YAAG;YACpC;gBAAEH,MAAM;gBAASE,OAAO;gBAAGC,MAAM;YAAG;YACpC;gBAAEH,MAAM;gBAAOE,OAAO;gBAAGC,MAAM;YAAG;SACrC;QACDA,MAAM;IACV;IACA;QACIH,MAAM;QACNC,QAAQ;YACJ;gBAAED,MAAM;gBAAaE,OAAO;gBAAGC,MAAM;YAAG;YACxC;gBAAEH,MAAM;gBAAYE,OAAO;gBAAGC,MAAM;YAAG;YACvC;gBAAEH,MAAM;gBAAYE,OAAO;gBAAGC,MAAM;YAAG;YACvC;gBAAEH,MAAM;gBAAaE,OAAO;gBAAGC,MAAM;YAAG;SAC3C;QACDA,MAAM;IACV;IACA;QACIH,MAAM;QACNC,QAAQ;YACJ;gBAAED,MAAM;gBAAWE,OAAO;gBAAGC,MAAM;YAAG;YACtC;gBAAEH,MAAM;gBAAWE,OAAO;gBAAGC,MAAM;YAAG;SACzC;QACDA,MAAM;IACV;IACA;QACIH,MAAM;QACNC,QAAQ;YACJ;gBAAED,MAAM;gBAAQE,OAAO;gBAAGC,MAAM;YAAG;YACnC;gBAAEH,MAAM;gBAASE,OAAO;gBAAGC,MAAM;YAAG;YACpC;gBAAEH,MAAM;gBAAME,OAAO;gBAAGC,MAAM;YAAG;YACjC;gBAAEH,MAAM;gBAAQE,OAAO;gBAAGC,MAAM;YAAG;YACnC;gBAAEH,MAAM;gBAAKE,OAAO;gBAAIC,MAAM;YAAG;YACjC;gBAAEH,MAAM;gBAAKE,OAAO;gBAAIC,MAAM;YAAG;YACjC;gBAAEH,MAAM;gBAAQE,OAAO;gBAAIC,MAAM;YAAG;YACpC;gBAAEH,MAAM;gBAAQE,OAAO;gBAAKC,MAAM;YAAG;SACxC;QACDA,MAAM;IACV;IACA;QACIH,MAAM;QACNC,QAAQ;YACJ;gBAAED,MAAM;gBAAWE,OAAO;gBAAGC,MAAM;YAAG;YACtC;gBAAEH,MAAM;gBAAYE,OAAO;gBAAGC,MAAM;YAAG;SAC1C;QACDA,MAAM;IACV;CACH,CAAiC"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { CheckListItem } from '../../types.js';
2
+ import { CheckListItem } from '@/cli/types.js';
3
3
  interface Props {
4
4
  items: CheckListItem<unknown>[];
5
5
  onFinish?: () => void;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { CheckListItem } from '../../types.js';
2
+ import { CheckListItem } from '@/cli/types.js';
3
3
  export interface ItemProps<TResult> {
4
4
  item: CheckListItem<TResult>;
5
5
  start: boolean;
@@ -1 +1,2 @@
1
1
  export declare const CrankscriptConfigurationFileName = "crankscript.json";
2
+ export declare const TypescriptReservedNamed: string[];
package/src/constants.js CHANGED
@@ -1,3 +1,8 @@
1
1
  export const CrankscriptConfigurationFileName = 'crankscript.json';
2
+ export const TypescriptReservedNamed = [
3
+ 'delete',
4
+ 'new',
5
+ 'function'
6
+ ];
2
7
 
3
8
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["export const CrankscriptConfigurationFileName = 'crankscript.json';\n"],"names":["CrankscriptConfigurationFileName"],"rangeMappings":"","mappings":"AAAA,OAAO,MAAMA,mCAAmC,mBAAmB"}
1
+ {"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["export const CrankscriptConfigurationFileName = 'crankscript.json';\nexport const TypescriptReservedNamed = ['delete', 'new', 'function'];\n"],"names":["CrankscriptConfigurationFileName","TypescriptReservedNamed"],"rangeMappings":";;;;;","mappings":"AAAA,OAAO,MAAMA,mCAAmC,mBAAmB;AACnE,OAAO,MAAMC,0BAA0B;IAAC;IAAU;IAAO;CAAW,CAAC"}
@@ -1,27 +1,11 @@
1
- import { HealthCheckStatus } from '../types.js';
2
- import { ConfigurationFileNotFoundError } from './configuration/error/ConfigurationFileNotFoundError.js';
3
- import { ConfigurationFileValidationError } from './configuration/error/ConfigurationFileValidationError.js';
4
- import { getConfiguration } from './configuration/getConfiguration.js';
1
+ import { HealthCheckStatusType } from '../types.js';
5
2
  import { Environment } from './dto/Environment.js';
6
3
  import { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';
7
4
  /**
8
5
  * Will create a configuration object from the environment.
9
6
  */ export const createEnvironment = (input)=>{
10
7
  const { environment = process.env } = input != null ? input : {};
11
- let configuration;
12
8
  let sdkPath;
13
- try {
14
- configuration = getConfiguration();
15
- } catch (error) {
16
- return {
17
- isHealthy: false,
18
- health: {
19
- configurationFilePresent: error instanceof ConfigurationFileNotFoundError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Healthy,
20
- configurationFileValid: error instanceof ConfigurationFileValidationError && !(error instanceof ConfigurationFileNotFoundError) ? HealthCheckStatus.Unhealthy : error instanceof ConfigurationFileValidationError ? HealthCheckStatus.Unhealthy : HealthCheckStatus.Unknown,
21
- sdkPathKnown: HealthCheckStatus.Unknown
22
- }
23
- };
24
- }
25
9
  try {
26
10
  sdkPath = getPlaydateSdkPath({
27
11
  environment
@@ -30,22 +14,22 @@ import { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';
30
14
  return {
31
15
  isHealthy: false,
32
16
  health: {
33
- configurationFilePresent: HealthCheckStatus.Healthy,
34
- configurationFileValid: HealthCheckStatus.Healthy,
35
- sdkPathKnown: HealthCheckStatus.Unhealthy
17
+ sdkPathKnown: {
18
+ healthStatus: HealthCheckStatusType.Unhealthy
19
+ }
36
20
  }
37
21
  };
38
22
  }
39
23
  return {
40
24
  isHealthy: true,
41
25
  environment: new Environment({
42
- configuration,
43
26
  sdkPath
44
27
  }),
45
28
  health: {
46
- configurationFilePresent: HealthCheckStatus.Healthy,
47
- configurationFileValid: HealthCheckStatus.Healthy,
48
- sdkPathKnown: HealthCheckStatus.Healthy
29
+ sdkPathKnown: {
30
+ healthStatus: HealthCheckStatusType.Healthy,
31
+ argument: sdkPath
32
+ }
49
33
  }
50
34
  };
51
35
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../libs/cli/src/environment/createEnvironment.ts"],"sourcesContent":["import { EnvironmentHealthResult, HealthCheckStatus } from '../types.js';\nimport { Configuration } from './configuration/dto/Configuration.js';\nimport { ConfigurationFileNotFoundError } from './configuration/error/ConfigurationFileNotFoundError.js';\nimport { ConfigurationFileValidationError } from './configuration/error/ConfigurationFileValidationError.js';\nimport { getConfiguration } from './configuration/getConfiguration.js';\nimport { Environment } from './dto/Environment.js';\nimport { PlaydateSdkPath } from './path/dto/PlaydateSdkPath.js';\nimport { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';\n\n/**\n * Will create a configuration object from the environment.\n */\nexport const createEnvironment = (input?: {\n /**\n * The environment to create the configuration from.\n *\n * Defaults to `process.env`.\n */\n environment: Record<string, unknown>;\n}): EnvironmentHealthResult => {\n const { environment = process.env } = input ?? {};\n let configuration: Configuration;\n let sdkPath: PlaydateSdkPath;\n\n try {\n configuration = getConfiguration();\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n configurationFilePresent:\n error instanceof ConfigurationFileNotFoundError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.Healthy,\n configurationFileValid:\n error instanceof ConfigurationFileValidationError &&\n !(error instanceof ConfigurationFileNotFoundError)\n ? HealthCheckStatus.Unhealthy\n : error instanceof ConfigurationFileValidationError\n ? HealthCheckStatus.Unhealthy\n : HealthCheckStatus.Unknown,\n sdkPathKnown: HealthCheckStatus.Unknown,\n },\n };\n }\n\n try {\n sdkPath = getPlaydateSdkPath({ environment });\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n configurationFilePresent: HealthCheckStatus.Healthy,\n configurationFileValid: HealthCheckStatus.Healthy,\n sdkPathKnown: HealthCheckStatus.Unhealthy,\n },\n };\n }\n\n return {\n isHealthy: true,\n environment: new Environment({\n configuration,\n sdkPath,\n }),\n health: {\n configurationFilePresent: HealthCheckStatus.Healthy,\n configurationFileValid: HealthCheckStatus.Healthy,\n sdkPathKnown: HealthCheckStatus.Healthy,\n },\n };\n};\n"],"names":["HealthCheckStatus","ConfigurationFileNotFoundError","ConfigurationFileValidationError","getConfiguration","Environment","getPlaydateSdkPath","createEnvironment","input","environment","process","env","configuration","sdkPath","error","isHealthy","health","configurationFilePresent","Unhealthy","Healthy","configurationFileValid","Unknown","sdkPathKnown"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAkCA,iBAAiB,QAAQ,cAAc;AAEzE,SAASC,8BAA8B,QAAQ,0DAA0D;AACzG,SAASC,gCAAgC,QAAQ,4DAA4D;AAC7G,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE;;CAEC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAQ9B,MAAM,EAAEC,cAAcC,QAAQC,GAAG,EAAE,GAAGH,gBAAAA,QAAS,CAAC;IAChD,IAAII;IACJ,IAAIC;IAEJ,IAAI;QACAD,gBAAgBR;IACpB,EAAE,OAAOU,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,0BACIH,iBAAiBZ,iCACXD,kBAAkBiB,SAAS,GAC3BjB,kBAAkBkB,OAAO;gBACnCC,wBACIN,iBAAiBX,oCACjB,CAAEW,CAAAA,iBAAiBZ,8BAA6B,IAC1CD,kBAAkBiB,SAAS,GAC3BJ,iBAAiBX,mCACjBF,kBAAkBiB,SAAS,GAC3BjB,kBAAkBoB,OAAO;gBACnCC,cAAcrB,kBAAkBoB,OAAO;YAC3C;QACJ;IACJ;IAEA,IAAI;QACAR,UAAUP,mBAAmB;YAAEG;QAAY;IAC/C,EAAE,OAAOK,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,0BAA0BhB,kBAAkBkB,OAAO;gBACnDC,wBAAwBnB,kBAAkBkB,OAAO;gBACjDG,cAAcrB,kBAAkBiB,SAAS;YAC7C;QACJ;IACJ;IAEA,OAAO;QACHH,WAAW;QACXN,aAAa,IAAIJ,YAAY;YACzBO;YACAC;QACJ;QACAG,QAAQ;YACJC,0BAA0BhB,kBAAkBkB,OAAO;YACnDC,wBAAwBnB,kBAAkBkB,OAAO;YACjDG,cAAcrB,kBAAkBkB,OAAO;QAC3C;IACJ;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../libs/cli/src/environment/createEnvironment.ts"],"sourcesContent":["import { EnvironmentHealthResult, HealthCheckStatusType } from '../types.js';\nimport { Environment } from './dto/Environment.js';\nimport { PlaydateSdkPath } from './path/dto/PlaydateSdkPath.js';\nimport { getPlaydateSdkPath } from './path/getPlaydateSdkPath.js';\n\n/**\n * Will create a configuration object from the environment.\n */\nexport const createEnvironment = (input?: {\n /**\n * The environment to create the configuration from.\n *\n * Defaults to `process.env`.\n */\n environment: Record<string, unknown>;\n}): EnvironmentHealthResult => {\n const { environment = process.env } = input ?? {};\n let sdkPath: PlaydateSdkPath;\n\n try {\n sdkPath = getPlaydateSdkPath({ environment });\n } catch (error) {\n return {\n isHealthy: false,\n health: {\n sdkPathKnown: { healthStatus: HealthCheckStatusType.Unhealthy },\n },\n };\n }\n\n return {\n isHealthy: true,\n environment: new Environment({\n sdkPath,\n }),\n health: {\n sdkPathKnown: {\n healthStatus: HealthCheckStatusType.Healthy,\n argument: sdkPath,\n },\n },\n };\n};\n"],"names":["HealthCheckStatusType","Environment","getPlaydateSdkPath","createEnvironment","input","environment","process","env","sdkPath","error","isHealthy","health","sdkPathKnown","healthStatus","Unhealthy","Healthy","argument"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAAkCA,qBAAqB,QAAQ,cAAc;AAC7E,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE;;CAEC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAQ9B,MAAM,EAAEC,cAAcC,QAAQC,GAAG,EAAE,GAAGH,gBAAAA,QAAS,CAAC;IAChD,IAAII;IAEJ,IAAI;QACAA,UAAUN,mBAAmB;YAAEG;QAAY;IAC/C,EAAE,OAAOI,OAAO;QACZ,OAAO;YACHC,WAAW;YACXC,QAAQ;gBACJC,cAAc;oBAAEC,cAAcb,sBAAsBc,SAAS;gBAAC;YAClE;QACJ;IACJ;IAEA,OAAO;QACHJ,WAAW;QACXL,aAAa,IAAIJ,YAAY;YACzBO;QACJ;QACAG,QAAQ;YACJC,cAAc;gBACVC,cAAcb,sBAAsBe,OAAO;gBAC3CC,UAAUR;YACd;QACJ;IACJ;AACJ,EAAE"}
@@ -1,10 +1,7 @@
1
- import { ConfigurationType } from '../configuration/ConfigurationSchema.js';
2
1
  import { PlaydateSdkPath } from '../path/dto/PlaydateSdkPath.js';
3
2
  export declare class Environment {
4
- configuration: ConfigurationType;
5
3
  sdkPath: PlaydateSdkPath;
6
- constructor({ configuration, sdkPath, }: {
7
- configuration: ConfigurationType;
4
+ constructor({ sdkPath }: {
8
5
  sdkPath: PlaydateSdkPath;
9
6
  });
10
7
  }
@@ -1,6 +1,5 @@
1
1
  export class Environment {
2
- constructor({ configuration, sdkPath }){
3
- this.configuration = configuration;
2
+ constructor({ sdkPath }){
4
3
  this.sdkPath = sdkPath;
5
4
  }
6
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/cli/src/environment/dto/Environment.ts"],"sourcesContent":["import { ConfigurationType } from '../configuration/ConfigurationSchema.js';\nimport { PlaydateSdkPath } from '../path/dto/PlaydateSdkPath.js';\n\nexport class Environment {\n configuration: ConfigurationType;\n sdkPath: PlaydateSdkPath;\n\n public constructor({\n configuration,\n sdkPath,\n }: {\n configuration: ConfigurationType;\n sdkPath: PlaydateSdkPath;\n }) {\n this.configuration = configuration;\n this.sdkPath = sdkPath;\n }\n}\n"],"names":["Environment","configuration","sdkPath"],"rangeMappings":";;;;;","mappings":"AAGA,OAAO,MAAMA;IAIT,YAAmB,EACfC,aAAa,EACbC,OAAO,EAIV,CAAE;QACC,IAAI,CAACD,aAAa,GAAGA;QACrB,IAAI,CAACC,OAAO,GAAGA;IACnB;AACJ"}
1
+ {"version":3,"sources":["../../../../../../libs/cli/src/environment/dto/Environment.ts"],"sourcesContent":["import { PlaydateSdkPath } from '../path/dto/PlaydateSdkPath.js';\n\nexport class Environment {\n sdkPath: PlaydateSdkPath;\n\n public constructor({ sdkPath }: { sdkPath: PlaydateSdkPath }) {\n this.sdkPath = sdkPath;\n }\n}\n"],"names":["Environment","sdkPath"],"rangeMappings":";;;;","mappings":"AAEA,OAAO,MAAMA;IAGT,YAAmB,EAAEC,OAAO,EAAgC,CAAE;QAC1D,IAAI,CAACA,OAAO,GAAGA;IACnB;AACJ"}
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node --no-warnings=ExperimentalWarning
2
2
  export {};
package/src/index.js CHANGED
@@ -1,10 +1,10 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node --no-warnings=ExperimentalWarning
2
2
  import { readFileSync } from 'fs';
3
3
  import { join } from 'node:path';
4
4
  import { Cli } from 'clipanion';
5
- import { DoctorCommand } from './commands/DoctorCommand.js';
6
- import { GenerateTypesCommand } from './commands/GenerateTypes/GenerateTypesCommand.js';
7
- import { RootFolder } from './utils/dirname.js';
5
+ import { DoctorCommand } from '@/cli/commands/DoctorCommand.js';
6
+ import { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';
7
+ import { RootFolder } from '@/cli/utils/dirname.js';
8
8
  const packageJsonContents = readFileSync(join(RootFolder, 'package.json'), 'utf-8');
9
9
  const packageJson = JSON.parse(packageJsonContents);
10
10
  const args = process.argv.slice(2);
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 { Cli } from 'clipanion';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';\nimport { RootFolder } from '@/cli/utils/dirname.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\ncli.register(DoctorCommand);\ncli.register(GenerateTypesCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","DoctorCommand","GenerateTypesCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,UAAU,QAAQ,yBAAyB;AAEpD,MAAMC,sBAAsBN,aACxBC,KAAKI,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIZ,IAAI;IAChBa,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAJ,IAAIK,QAAQ,CAAChB;AACbW,IAAIK,QAAQ,CAACf;AACbU,IAAIM,OAAO,CAACV"}
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 { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/GenerateTypesCommand.js';\nimport { RootFolder } from '@/cli/utils/dirname.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\ncli.register(DoctorCommand);\ncli.register(GenerateTypesCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","DoctorCommand","GenerateTypesCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,UAAU,QAAQ,yBAAyB;AAEpD,MAAMC,sBAAsBN,aACxBC,KAAKI,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIZ,IAAI;IAChBa,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAJ,IAAIK,QAAQ,CAAChB;AACbW,IAAIK,QAAQ,CAACf;AACbU,IAAIM,OAAO,CAACV"}
package/src/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Environment } from './environment/dto/Environment.js';
1
+ import { Environment } from '@/cli/environment/dto/Environment.js';
2
+ import { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';
2
3
  export declare enum PlaydateSdkVersionIdentifier {
3
- FromConfig = "FromConfig",
4
4
  Latest = "latest"
5
5
  }
6
+ export type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;
6
7
  export type EnvironmentHealthResult = {
7
8
  isHealthy: true;
8
9
  environment: Environment;
@@ -11,19 +12,19 @@ export type EnvironmentHealthResult = {
11
12
  isHealthy: false;
12
13
  health: EnvironmentHealth;
13
14
  };
14
- export declare enum HealthCheckStatus {
15
+ export declare enum HealthCheckStatusType {
15
16
  Healthy = "Healthy",
16
17
  Unhealthy = "Unhealthy",
17
18
  Unknown = "Unknown"
18
19
  }
20
+ export type HealthCheckStatus<TArgument> = {
21
+ healthStatus: HealthCheckStatusType.Unknown | HealthCheckStatusType.Unhealthy;
22
+ } | {
23
+ healthStatus: HealthCheckStatusType.Healthy;
24
+ argument: TArgument;
25
+ };
19
26
  export interface EnvironmentHealth {
20
- configurationFilePresent: HealthCheckStatus;
21
- configurationFileValid: HealthCheckStatus;
22
- sdkPathKnown: HealthCheckStatus;
23
- }
24
- export declare enum ConfigurationFileValidationErrorType {
25
- InvalidJson = "InvalidJson",
26
- InvalidSchema = "InvalidSchema"
27
+ sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;
27
28
  }
28
29
  export type CheckListItem<TResult> = {
29
30
  runningDescription: string;
@@ -34,3 +35,36 @@ export type CheckListItem<TResult> = {
34
35
  onFinish?: (result: TResult) => void;
35
36
  ready?: boolean;
36
37
  };
38
+ export interface ParameterDescription {
39
+ name: string;
40
+ required: boolean;
41
+ type: string;
42
+ }
43
+ export interface FunctionDescription {
44
+ name: string;
45
+ namespaces: string[];
46
+ parameters: ParameterDescription[];
47
+ hasSelf: boolean;
48
+ docs: string;
49
+ }
50
+ export interface ConstantDescription {
51
+ name: string;
52
+ docs: string;
53
+ values: {
54
+ name: string;
55
+ value: number;
56
+ docs: string;
57
+ }[];
58
+ }
59
+ export interface PlaydateNamespace {
60
+ functions: FunctionDescription[];
61
+ callbacks: FunctionDescription[];
62
+ }
63
+ export interface PlaydateType {
64
+ methods: FunctionDescription[];
65
+ }
66
+ export interface ApiDefinitions {
67
+ namespaces: Record<string, PlaydateNamespace>;
68
+ types: Record<string, PlaydateType>;
69
+ constants: ConstantDescription[];
70
+ }