@figma/code-connect 1.3.13 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/commands/connect.d.ts +1 -1
  2. package/dist/commands/connect.d.ts.map +1 -1
  3. package/dist/commands/connect.js +104 -25
  4. package/dist/commands/connect.js.map +1 -1
  5. package/dist/common/error_formatting.d.ts +34 -0
  6. package/dist/common/error_formatting.d.ts.map +1 -0
  7. package/dist/common/error_formatting.js +115 -0
  8. package/dist/common/error_formatting.js.map +1 -0
  9. package/dist/connect/api.d.ts +13 -0
  10. package/dist/connect/api.d.ts.map +1 -1
  11. package/dist/connect/api.js.map +1 -1
  12. package/dist/connect/external_types.d.ts +1 -0
  13. package/dist/connect/external_types.d.ts.map +1 -1
  14. package/dist/connect/external_types.js +4 -0
  15. package/dist/connect/external_types.js.map +1 -1
  16. package/dist/connect/figma_connect.d.ts +3 -1
  17. package/dist/connect/figma_connect.d.ts.map +1 -1
  18. package/dist/connect/figma_connect.js.map +1 -1
  19. package/dist/connect/intrinsics.d.ts +9 -2
  20. package/dist/connect/intrinsics.d.ts.map +1 -1
  21. package/dist/connect/intrinsics.js +19 -0
  22. package/dist/connect/intrinsics.js.map +1 -1
  23. package/dist/connect/label_language_mapping.d.ts +20 -5
  24. package/dist/connect/label_language_mapping.d.ts.map +1 -1
  25. package/dist/connect/label_language_mapping.js +36 -22
  26. package/dist/connect/label_language_mapping.js.map +1 -1
  27. package/dist/connect/migration_helpers.d.ts +22 -2
  28. package/dist/connect/migration_helpers.d.ts.map +1 -1
  29. package/dist/connect/migration_helpers.js +184 -24
  30. package/dist/connect/migration_helpers.js.map +1 -1
  31. package/dist/connect/parser_common.d.ts.map +1 -1
  32. package/dist/connect/parser_common.js +1 -0
  33. package/dist/connect/parser_common.js.map +1 -1
  34. package/dist/connect/parser_executable_types.d.ts +11 -5
  35. package/dist/connect/parser_executable_types.d.ts.map +1 -1
  36. package/dist/connect/parser_executable_types.js +5 -1
  37. package/dist/connect/parser_executable_types.js.map +1 -1
  38. package/dist/connect/project.d.ts +3 -2
  39. package/dist/connect/project.d.ts.map +1 -1
  40. package/dist/connect/project.js +1 -1
  41. package/dist/connect/project.js.map +1 -1
  42. package/dist/connect/upload.d.ts.map +1 -1
  43. package/dist/connect/upload.js +9 -4
  44. package/dist/connect/upload.js.map +1 -1
  45. package/dist/html/external.d.ts +1 -1
  46. package/dist/html/external.d.ts.map +1 -1
  47. package/dist/html/external.js +1 -0
  48. package/dist/html/external.js.map +1 -1
  49. package/dist/html/parser.js +1 -1
  50. package/dist/html/parser.js.map +1 -1
  51. package/dist/react/create.d.ts.map +1 -1
  52. package/dist/react/create.js +3 -0
  53. package/dist/react/create.js.map +1 -1
  54. package/dist/react/external.d.ts +2 -2
  55. package/dist/react/external.d.ts.map +1 -1
  56. package/dist/react/external.js +2 -1
  57. package/dist/react/external.js.map +1 -1
  58. package/dist/react/parser.js +1 -1
  59. package/dist/react/parser.js.map +1 -1
  60. package/dist/react/parser_template_helpers.d.ts.map +1 -1
  61. package/dist/react/parser_template_helpers.js +4 -1
  62. package/dist/react/parser_template_helpers.js.map +1 -1
  63. package/dist/storybook/convert.js +1 -1
  64. package/dist/storybook/convert.js.map +1 -1
  65. package/package.json +4 -2
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { ComponentTypeSignature } from '../react/parser';
3
3
  import { Intrinsic } from './intrinsics';
4
+ import { SyntaxHighlightLanguage } from './label_language_mapping';
4
5
  export type ParseRequestPayload = {
5
6
  mode: 'PARSE';
6
7
  paths: string[];
@@ -51,6 +52,7 @@ export declare const ParseResponsePayload: z.ZodObject<{
51
52
  }, {
52
53
  line: number;
53
54
  }>>;
55
+ _codeConnectFilePath: z.ZodOptional<z.ZodString>;
54
56
  template: z.ZodString;
55
57
  templateData: z.ZodObject<{
56
58
  props: z.ZodRecord<z.ZodString, any>;
@@ -65,7 +67,7 @@ export declare const ParseResponsePayload: z.ZodObject<{
65
67
  imports?: string[] | undefined;
66
68
  nestable?: boolean | undefined;
67
69
  }>;
68
- language: z.ZodString;
70
+ language: z.ZodNativeEnum<typeof SyntaxHighlightLanguage>;
69
71
  label: z.ZodString;
70
72
  links: z.ZodOptional<z.ZodArray<z.ZodObject<{
71
73
  name: z.ZodString;
@@ -86,13 +88,14 @@ export declare const ParseResponsePayload: z.ZodObject<{
86
88
  imports?: string[] | undefined;
87
89
  nestable?: boolean | undefined;
88
90
  };
89
- language: string;
91
+ language: SyntaxHighlightLanguage;
90
92
  source?: string | undefined;
91
93
  sourceLocation?: {
92
94
  line: number;
93
95
  } | undefined;
94
96
  component?: string | undefined;
95
97
  variant?: Record<string, any> | undefined;
98
+ _codeConnectFilePath?: string | undefined;
96
99
  links?: {
97
100
  name: string;
98
101
  url: string;
@@ -106,13 +109,14 @@ export declare const ParseResponsePayload: z.ZodObject<{
106
109
  imports?: string[] | undefined;
107
110
  nestable?: boolean | undefined;
108
111
  };
109
- language: string;
112
+ language: SyntaxHighlightLanguage;
110
113
  source?: string | undefined;
111
114
  sourceLocation?: {
112
115
  line: number;
113
116
  } | undefined;
114
117
  component?: string | undefined;
115
118
  variant?: Record<string, any> | undefined;
119
+ _codeConnectFilePath?: string | undefined;
116
120
  links?: {
117
121
  name: string;
118
122
  url: string;
@@ -159,13 +163,14 @@ export declare const ParseResponsePayload: z.ZodObject<{
159
163
  imports?: string[] | undefined;
160
164
  nestable?: boolean | undefined;
161
165
  };
162
- language: string;
166
+ language: SyntaxHighlightLanguage;
163
167
  source?: string | undefined;
164
168
  sourceLocation?: {
165
169
  line: number;
166
170
  } | undefined;
167
171
  component?: string | undefined;
168
172
  variant?: Record<string, any> | undefined;
173
+ _codeConnectFilePath?: string | undefined;
169
174
  links?: {
170
175
  name: string;
171
176
  url: string;
@@ -190,13 +195,14 @@ export declare const ParseResponsePayload: z.ZodObject<{
190
195
  imports?: string[] | undefined;
191
196
  nestable?: boolean | undefined;
192
197
  };
193
- language: string;
198
+ language: SyntaxHighlightLanguage;
194
199
  source?: string | undefined;
195
200
  sourceLocation?: {
196
201
  line: number;
197
202
  } | undefined;
198
203
  component?: string | undefined;
199
204
  variant?: Record<string, any> | undefined;
205
+ _codeConnectFilePath?: string | undefined;
200
206
  links?: {
201
207
  name: string;
202
208
  url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"parser_executable_types.d.ts","sourceRoot":"","sources":["../../src/connect/parser_executable_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,OAAO,CAAA;IAGb,KAAK,EAAE,MAAM,EAAE,CAAA;IAIf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAOD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAuBpC,CAAA;AASD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8D/B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEnD,MAAM,MAAM,2BAA2B,GAAG;IAExC,IAAI,EAAE,SAAS,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAAA;IAEtD,YAAY,EAAE,OAAO,GAAG,MAAM,CAAA;IAE9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAA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O,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,QAAQ,CAAA;IAId,cAAc,EAAE,MAAM,CAAA;IAGtB,eAAe,CAAC,EAAE,MAAM,CAAA;IAGxB,cAAc,CAAC,EAAE,MAAM,CAAA;IAGvB,cAAc,EAAE,MAAM,CAAA;IAGtB,gBAAgB,EAAE,eAAe,EAAE,CAAA;IAInC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,oBAAoB,CAAA"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateResponsePayload = exports.ParseResponsePayload = exports.ParserExecutableMessages = void 0;
4
4
  const zod_1 = require("zod");
5
+ const label_language_mapping_1 = require("./label_language_mapping");
5
6
  const FigmaConnectLink = zod_1.z.object({
6
7
  name: zod_1.z.string(),
7
8
  url: zod_1.z.string(),
@@ -57,6 +58,9 @@ exports.ParseResponsePayload = zod_1.z.object({
57
58
  line: zod_1.z.number(),
58
59
  })
59
60
  .optional(),
61
+ // INTERNAL ONLY: Path to the Code Connect file itself, used for parserless migration
62
+ // Should be stripped out before publishing
63
+ _codeConnectFilePath: zod_1.z.string().optional(),
60
64
  // The JS template function to use for this doc
61
65
  template: zod_1.z.string(),
62
66
  templateData: zod_1.z.object({
@@ -86,7 +90,7 @@ exports.ParseResponsePayload = zod_1.z.object({
86
90
  nestable: zod_1.z.boolean().optional(),
87
91
  }),
88
92
  // The language to use for syntax highlighting
89
- language: zod_1.z.string(),
93
+ language: zod_1.z.nativeEnum(label_language_mapping_1.SyntaxHighlightLanguage),
90
94
  // Label to be used for the example in the UI
91
95
  label: zod_1.z.string(),
92
96
  // Optional array of links to be displayed in the UI.
@@ -1 +1 @@
1
- {"version":3,"file":"parser_executable_types.js","sourceRoot":"","sources":["../../src/connect/parser_executable_types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAiBvB,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAA;AAEW,QAAA,wBAAwB,GAAG,OAAC,CAAC,KAAK,CAC7C,OAAC,CAAC,MAAM,CAAC;IACP,yEAAyE;IACzE,4DAA4D;IAC5D,EAAE;IACF,uEAAuE;IACvE,0EAA0E;IAC1E,iEAAiE;IACjE,EAAE;IACF,qEAAqE;IACrE,YAAY;IACZ,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9F,4EAA4E;IAC5E,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,yEAAyE;IACzE,cAAc,EAAE,OAAC;SACd,MAAM,CAAC;QACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC5B,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CACH,CAAA;AAED,+EAA+E;AAC/E,gCAAgC;AAChC,EAAE;AACF,gEAAgE;AAChE,6EAA6E;AAC7E,+EAA+E;AAC/E,4CAA4C;AAC/B,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,yDA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AA0E;YAC1E,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SACjC,CAAC;QACF,8CAA8C;QAC9C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;QACpB,6CAA6C;QAC7C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;QACjB,qDAAqD;QACrD,iCAAiC;QACjC,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;KAC5C,CAA4C,CAC9C;IACD,gEAAgE;IAChE,QAAQ,EAAE,gCAAwB;CACnC,CAAC,CAAA;AA2GW,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,8DAA8D;IAC9D,YAAY,EAAE,OAAC,CAAC,KAAK,CACnB,OAAC,CAAC,MAAM,CAAC;QACP,wCAAwC;QACxC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;KACrB,CAAC,CACH;IACD,iEAAiE;IACjE,QAAQ,EAAE,gCAAwB;CACnC,CAAC,CAAA","sourcesContent":["import { z } from 'zod'\nimport { ComponentTypeSignature } from '../react/parser'\nimport { BaseCodeConnectObject } from './figma_connect'\nimport { Intrinsic } from './intrinsics'\n\nexport type ParseRequestPayload = {\n mode: 'PARSE'\n // An array of absolute paths for the parser to process, representing all\n // files matched by the include/exclude globs for this parser.\n paths: string[]\n // Config options passed into this parser (not all parsers) from the config.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n verbose?: boolean\n}\n\nconst FigmaConnectLink = z.object({\n name: z.string(),\n url: z.string(),\n})\n\nexport const ParserExecutableMessages = z.array(\n z.object({\n // DEBUG and INFO messages should be output to console by the CLI for the\n // user to read, according to the current log level setting.\n //\n // If any WARNING or ERROR messages are returned, the CLI can determine\n // whether it should proceed with publishing or not based on configuration\n // and the return code should be zero or non-zero as appropriate.\n //\n // There's no need for a \"result\" field as we can infer this from the\n // messages.\n level: z.union([z.literal('DEBUG'), z.literal('INFO'), z.literal('WARN'), z.literal('ERROR')]),\n // Optional type of message which can be displayed highlighted in the output\n type: z.string().optional(),\n message: z.string(),\n // Optional source location which can be displayed in a standardised form\n sourceLocation: z\n .object({\n file: z.string(),\n line: z.number().optional(),\n })\n .optional(),\n }),\n)\n\n// Zod type modelling the response from a Code Connect parser. Zod allows us to\n// easily validate the response.\n//\n// This type somewhat duplicates the `CodeConnectJSON` type from\n// `figma_connect.ts`, but as Zod doesn't allow us to fully express recursive\n// types such as Intrinsic, we keep this explicit type as well. The `satisfies`\n// should ensure the two types stay in sync.\nexport const ParseResponsePayload = z.object({\n // Array of Code Connect docs parsed from the input files\n docs: z.array(\n z.object({\n // The Figma node URL the doc links to\n figmaNode: z.string(),\n // Optional component name. This is only used for display purposes\n // so can be omitted if it's not relevant to the language/framework\n component: z.string().optional(),\n // Variant restrictions keyed by Figma property name e.g. `{ 'With icon': true }`\n variant: z.record(z.any()).optional(),\n // Optional source path/URL, which can either be a path on disk, which\n // we'll show as a SCM link, or a URL (e.g. for a Storybook parser which\n // wants to link to the story in Storybook rather than the file in Github)\n source: z.string().optional(),\n // Optional source location containing line number information.\n sourceLocation: z\n .object({\n // Optional line number to link to. This is only used if type === 'PATH',\n // to generate a link to the correct line\n line: z.number(),\n })\n .optional(),\n // The JS template function to use for this doc\n template: z.string(),\n templateData: z.object({\n // Map of information describing the props used by the template. This is\n // used by the CLI to validate props before publishing.\n //\n // TODO this Zod type is a bit loose - couldn't work out how to model it exactly\n //\n // TODO We could look to extract this from the template somehow instead,\n // (e.g. run it with figma.properties.* stubbed to record accesses) to\n // avoid needing this duplication.\n props: z.record(z.object({ kind: z.string(), args: z.any() }) as any),\n // Optional array of imports for this component. These are prepended\n // to the example code, but it's useful to keep them separate e.g. if\n // we ever want to auto-insert imports in VS Code. If more control\n // over imports is required, they can be output directly by the template\n // function. Currently they'd have to be output in the code directly, but\n // the original spec does propose templates being able to return import\n // sections separately (not implemented as there's no UI for this)\n //\n // Right now, there's no way to handle gathering imports from children and\n // post-processing them (e.g. combining multiple imports from the same file\n // into a single import). We could consider some way for templates to do this\n // in future.\n imports: z.array(z.string()).optional(),\n // Whether the example should be rendered inline if it's a nested instance\n nestable: z.boolean().optional(),\n }),\n // The language to use for syntax highlighting\n language: z.string(),\n // Label to be used for the example in the UI\n label: z.string(),\n // Optional array of links to be displayed in the UI.\n // TODO Not implemented in UI yet\n links: z.array(FigmaConnectLink).optional(),\n }) satisfies z.ZodType<BaseCodeConnectObject>,\n ),\n // Any info, warning or error messages generated during parsing.\n messages: ParserExecutableMessages,\n})\n\nexport type PropMapping = Record<string, Intrinsic>\n\nexport type ComponentPropertyDefinition = {\n // The property type\n type: 'BOOLEAN' | 'INSTANCE_SWAP' | 'TEXT' | 'VARIANT'\n // The default value of this property\n defaultValue: boolean | string\n // All possible values for this property. Only exists on VARIANT properties\n variantOptions?: string[]\n}\n\nexport interface FigmaConnectionComponent {\n // The URL of the Figma component. This field is not in the REST API but\n // is added for convenience.\n figmaNodeUrl: string\n // The ID of the Figma component\n id: string\n // The name of the Figma component\n name: string\n // The type of the Figma component\n type: 'COMPONENT' | 'COMPONENT_SET'\n // Map of the Figma component's properties, keyed by property name\n componentPropertyDefinitions: Record<string, ComponentPropertyDefinition>\n}\nexport interface FigmaConnection {\n // The export to use from sourceFilepath\n sourceExport?: string\n // A mapping of how Figma props should map to code properties\n propMapping?: PropMapping\n // The type signature for the component (React only)\n reactTypeSignature?: ComponentTypeSignature\n // Information about the Figma component. This matches the REST API (except the\n // figmaNodeUrl and normalizedName fields), which should make it easier to\n // implement and maintain as we can just pass it through\n component: FigmaConnectionComponent\n}\n\nexport type CreateRequestPayload = {\n mode: 'CREATE'\n // Absolute destination directory for the created file. The parser is free to\n // write to a different directory if appropriate (e.g. it analyses your codebase\n // to identify where this component should go), but usually it should respect this.\n destinationDir: string\n // Optional destination file name. If omitted, the parser can determine the\n // file name itself.\n destinationFile?: string\n // The filepath of the code to be connected. If present, this is used instead of\n // component.normalizedName\n sourceFilepath?: string\n // The export to use from sourceFilepath (TypeScript only)\n sourceExport?: string\n // A mapping of how Figma props should map to code properties\n propMapping?: PropMapping\n // The type signature for the component (React only)\n reactTypeSignature?: ComponentTypeSignature\n // Information about the Figma component. This matches the REST API (except the\n // figmaNodeUrl and normalizedName fields), which should make it easier to\n // implement and maintain as we can just pass it through\n component: {\n // The URL of the Figma component. This field is not in the REST API but\n // is added for convenience.\n figmaNodeUrl: string\n // The ID of the Figma component\n id: string\n // The name of the Figma component\n name: string\n // The name of the Figma component, nomalized for use in code.\n // This field is not in the REST API but is added for convenience.\n normalizedName: string\n // The type of the Figma component\n type: 'COMPONENT' | 'COMPONENT_SET'\n // Map of the Figma component's properties, keyed by property name\n componentPropertyDefinitions: Record<string, ComponentPropertyDefinition>\n }\n // The configuration object for this parser.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n verbose?: boolean\n}\n\nexport type CreateRequestPayloadMulti = {\n mode: 'CREATE'\n // Absolute destination directory for the created file. The parser is free to\n // write to a different directory if appropriate (e.g. it analyses your codebase\n // to identify where this component should go), but usually it should respect this.\n destinationDir: string\n // Optional destination file name. If omitted, the parser can determine the\n // file name itself.\n destinationFile?: string\n // The filepath of the code to be connected. If present, this is used instead of\n // component.normalizedName\n sourceFilepath?: string\n // The name of the Figma component, nomalized for use in code.\n // This field is not in the REST API but is added for convenience.\n normalizedName: string\n // The list of design-matchings this file holds\n // there can be multiple exports per file, each matching to a different design\n figmaConnections: FigmaConnection[]\n // The configuration object for this parser.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n}\n\nexport const CreateResponsePayload = z.object({\n // A list of files created, which can be output to the console\n createdFiles: z.array(\n z.object({\n // The absolute path of the created file\n filePath: z.string(),\n }),\n ),\n // Any info, warning or error messages generated during creation.\n messages: ParserExecutableMessages,\n})\n\nexport type ParserRequestPayload = ParseRequestPayload | CreateRequestPayload\n"]}
1
+ {"version":3,"file":"parser_executable_types.js","sourceRoot":"","sources":["../../src/connect/parser_executable_types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAIvB,qEAAkE;AAclE,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAA;AAEW,QAAA,wBAAwB,GAAG,OAAC,CAAC,KAAK,CAC7C,OAAC,CAAC,MAAM,CAAC;IACP,yEAAyE;IACzE,4DAA4D;IAC5D,EAAE;IACF,uEAAuE;IACvE,0EAA0E;IAC1E,iEAAiE;IACjE,EAAE;IACF,qEAAqE;IACrE,YAAY;IACZ,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9F,4EAA4E;IAC5E,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,yEAAyE;IACzE,cAAc,EAAE,OAAC;SACd,MAAM,CAAC;QACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC5B,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CACH,CAAA;AAED,+EAA+E;AAC/E,gCAAgC;AAChC,EAAE;AACF,gEAAgE;AAChE,6EAA6E;AAC7E,+EAA+E;AAC/E,4CAA4C;AAC/B,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,yDAAyD;IACzD,IAAI,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C,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;YACvC,0EAA0E;YAC1E,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SACjC,CAAC;QACF,8CAA8C;QAC9C,QAAQ,EAAE,OAAC,CAAC,UAAU,CAAC,gDAAuB,CAAC;QAC/C,6CAA6C;QAC7C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;QACjB,qDAAqD;QACrD,iCAAiC;QACjC,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;KAC5C,CAA4C,CAC9C;IACD,gEAAgE;IAChE,QAAQ,EAAE,gCAAwB;CACnC,CAAC,CAAA;AA2GW,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,8DAA8D;IAC9D,YAAY,EAAE,OAAC,CAAC,KAAK,CACnB,OAAC,CAAC,MAAM,CAAC;QACP,wCAAwC;QACxC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;KACrB,CAAC,CACH;IACD,iEAAiE;IACjE,QAAQ,EAAE,gCAAwB;CACnC,CAAC,CAAA","sourcesContent":["import { z } from 'zod'\nimport { ComponentTypeSignature } from '../react/parser'\nimport { BaseCodeConnectObject } from './figma_connect'\nimport { Intrinsic } from './intrinsics'\nimport { SyntaxHighlightLanguage } from './label_language_mapping'\n\nexport type ParseRequestPayload = {\n mode: 'PARSE'\n // An array of absolute paths for the parser to process, representing all\n // files matched by the include/exclude globs for this parser.\n paths: string[]\n // Config options passed into this parser (not all parsers) from the config.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n verbose?: boolean\n}\n\nconst FigmaConnectLink = z.object({\n name: z.string(),\n url: z.string(),\n})\n\nexport const ParserExecutableMessages = z.array(\n z.object({\n // DEBUG and INFO messages should be output to console by the CLI for the\n // user to read, according to the current log level setting.\n //\n // If any WARNING or ERROR messages are returned, the CLI can determine\n // whether it should proceed with publishing or not based on configuration\n // and the return code should be zero or non-zero as appropriate.\n //\n // There's no need for a \"result\" field as we can infer this from the\n // messages.\n level: z.union([z.literal('DEBUG'), z.literal('INFO'), z.literal('WARN'), z.literal('ERROR')]),\n // Optional type of message which can be displayed highlighted in the output\n type: z.string().optional(),\n message: z.string(),\n // Optional source location which can be displayed in a standardised form\n sourceLocation: z\n .object({\n file: z.string(),\n line: z.number().optional(),\n })\n .optional(),\n }),\n)\n\n// Zod type modelling the response from a Code Connect parser. Zod allows us to\n// easily validate the response.\n//\n// This type somewhat duplicates the `CodeConnectJSON` type from\n// `figma_connect.ts`, but as Zod doesn't allow us to fully express recursive\n// types such as Intrinsic, we keep this explicit type as well. The `satisfies`\n// should ensure the two types stay in sync.\nexport const ParseResponsePayload = z.object({\n // Array of Code Connect docs parsed from the input files\n docs: z.array(\n z.object({\n // The Figma node URL the doc links to\n figmaNode: z.string(),\n // Optional component name. This is only used for display purposes\n // so can be omitted if it's not relevant to the language/framework\n component: z.string().optional(),\n // Variant restrictions keyed by Figma property name e.g. `{ 'With icon': true }`\n variant: z.record(z.any()).optional(),\n // Optional source path/URL, which can either be a path on disk, which\n // we'll show as a SCM link, or a URL (e.g. for a Storybook parser which\n // wants to link to the story in Storybook rather than the file in Github)\n source: z.string().optional(),\n // Optional source location containing line number information.\n sourceLocation: z\n .object({\n // Optional line number to link to. This is only used if type === 'PATH',\n // to generate a link to the correct line\n line: z.number(),\n })\n .optional(),\n // INTERNAL ONLY: Path to the Code Connect file itself, used for parserless migration\n // Should be stripped out before publishing\n _codeConnectFilePath: z.string().optional(),\n // The JS template function to use for this doc\n template: z.string(),\n templateData: z.object({\n // Map of information describing the props used by the template. This is\n // used by the CLI to validate props before publishing.\n //\n // TODO this Zod type is a bit loose - couldn't work out how to model it exactly\n //\n // TODO We could look to extract this from the template somehow instead,\n // (e.g. run it with figma.properties.* stubbed to record accesses) to\n // avoid needing this duplication.\n props: z.record(z.object({ kind: z.string(), args: z.any() }) as any),\n // Optional array of imports for this component. These are prepended\n // to the example code, but it's useful to keep them separate e.g. if\n // we ever want to auto-insert imports in VS Code. If more control\n // over imports is required, they can be output directly by the template\n // function. Currently they'd have to be output in the code directly, but\n // the original spec does propose templates being able to return import\n // sections separately (not implemented as there's no UI for this)\n //\n // Right now, there's no way to handle gathering imports from children and\n // post-processing them (e.g. combining multiple imports from the same file\n // into a single import). We could consider some way for templates to do this\n // in future.\n imports: z.array(z.string()).optional(),\n // Whether the example should be rendered inline if it's a nested instance\n nestable: z.boolean().optional(),\n }),\n // The language to use for syntax highlighting\n language: z.nativeEnum(SyntaxHighlightLanguage),\n // Label to be used for the example in the UI\n label: z.string(),\n // Optional array of links to be displayed in the UI.\n // TODO Not implemented in UI yet\n links: z.array(FigmaConnectLink).optional(),\n }) satisfies z.ZodType<BaseCodeConnectObject>,\n ),\n // Any info, warning or error messages generated during parsing.\n messages: ParserExecutableMessages,\n})\n\nexport type PropMapping = Record<string, Intrinsic>\n\nexport type ComponentPropertyDefinition = {\n // The property type\n type: 'BOOLEAN' | 'INSTANCE_SWAP' | 'TEXT' | 'VARIANT'\n // The default value of this property\n defaultValue: boolean | string\n // All possible values for this property. Only exists on VARIANT properties\n variantOptions?: string[]\n}\n\nexport interface FigmaConnectionComponent {\n // The URL of the Figma component. This field is not in the REST API but\n // is added for convenience.\n figmaNodeUrl: string\n // The ID of the Figma component\n id: string\n // The name of the Figma component\n name: string\n // The type of the Figma component\n type: 'COMPONENT' | 'COMPONENT_SET'\n // Map of the Figma component's properties, keyed by property name\n componentPropertyDefinitions: Record<string, ComponentPropertyDefinition>\n}\nexport interface FigmaConnection {\n // The export to use from sourceFilepath\n sourceExport?: string\n // A mapping of how Figma props should map to code properties\n propMapping?: PropMapping\n // The type signature for the component (React only)\n reactTypeSignature?: ComponentTypeSignature\n // Information about the Figma component. This matches the REST API (except the\n // figmaNodeUrl and normalizedName fields), which should make it easier to\n // implement and maintain as we can just pass it through\n component: FigmaConnectionComponent\n}\n\nexport type CreateRequestPayload = {\n mode: 'CREATE'\n // Absolute destination directory for the created file. The parser is free to\n // write to a different directory if appropriate (e.g. it analyses your codebase\n // to identify where this component should go), but usually it should respect this.\n destinationDir: string\n // Optional destination file name. If omitted, the parser can determine the\n // file name itself.\n destinationFile?: string\n // The filepath of the code to be connected. If present, this is used instead of\n // component.normalizedName\n sourceFilepath?: string\n // The export to use from sourceFilepath (TypeScript only)\n sourceExport?: string\n // A mapping of how Figma props should map to code properties\n propMapping?: PropMapping\n // The type signature for the component (React only)\n reactTypeSignature?: ComponentTypeSignature\n // Information about the Figma component. This matches the REST API (except the\n // figmaNodeUrl and normalizedName fields), which should make it easier to\n // implement and maintain as we can just pass it through\n component: {\n // The URL of the Figma component. This field is not in the REST API but\n // is added for convenience.\n figmaNodeUrl: string\n // The ID of the Figma component\n id: string\n // The name of the Figma component\n name: string\n // The name of the Figma component, nomalized for use in code.\n // This field is not in the REST API but is added for convenience.\n normalizedName: string\n // The type of the Figma component\n type: 'COMPONENT' | 'COMPONENT_SET'\n // Map of the Figma component's properties, keyed by property name\n componentPropertyDefinitions: Record<string, ComponentPropertyDefinition>\n }\n // The configuration object for this parser.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n verbose?: boolean\n}\n\nexport type CreateRequestPayloadMulti = {\n mode: 'CREATE'\n // Absolute destination directory for the created file. The parser is free to\n // write to a different directory if appropriate (e.g. it analyses your codebase\n // to identify where this component should go), but usually it should respect this.\n destinationDir: string\n // Optional destination file name. If omitted, the parser can determine the\n // file name itself.\n destinationFile?: string\n // The filepath of the code to be connected. If present, this is used instead of\n // component.normalizedName\n sourceFilepath?: string\n // The name of the Figma component, nomalized for use in code.\n // This field is not in the REST API but is added for convenience.\n normalizedName: string\n // The list of design-matchings this file holds\n // there can be multiple exports per file, each matching to a different design\n figmaConnections: FigmaConnection[]\n // The configuration object for this parser.\n // Each parser's configuration is separate and can take any shape, though we\n // will recommend using the same naming for common concepts like \"importPaths\".\n config: Record<string, any>\n}\n\nexport const CreateResponsePayload = z.object({\n // A list of files created, which can be output to the console\n createdFiles: z.array(\n z.object({\n // The absolute path of the created file\n filePath: z.string(),\n }),\n ),\n // Any info, warning or error messages generated during creation.\n messages: ParserExecutableMessages,\n})\n\nexport type ParserRequestPayload = ParseRequestPayload | CreateRequestPayload\n"]}
@@ -1,4 +1,5 @@
1
1
  import ts from 'typescript';
2
+ import { SyntaxHighlightLanguage } from './label_language_mapping';
2
3
  export declare const DEFAULT_INCLUDE_GLOBS_BY_PARSER: {
3
4
  react: string[];
4
5
  html: string[];
@@ -39,10 +40,9 @@ export type BaseCodeConnectConfig = {
39
40
  label?: string;
40
41
  /**
41
42
  * Language to use for syntax highlighting in the uploaded code examples.
42
- * Valid values: 'typescript', 'swift', 'kotlin', 'html', 'raw'
43
43
  * If not specified, language is inferred from the label or parser type.
44
44
  */
45
- language?: string;
45
+ language?: SyntaxHighlightLanguage;
46
46
  /**
47
47
  * The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.
48
48
  */
@@ -93,6 +93,7 @@ export type CodeConnectReactConfig = BaseCodeConnectConfig & {
93
93
  };
94
94
  };
95
95
  export type CodeConnectHtmlConfig = BaseCodeConnectConfig & {};
96
+ export type CodeConnectParserlessConfig = Omit<BaseCodeConnectConfig, 'parser'>;
96
97
  export type CodeConnectConfig = CodeConnectReactConfig | CodeConnectExecutableParserConfig | CodeConnectCustomExecutableParserConfig | CodeConnectHtmlConfig | BaseCodeConnectConfig;
97
98
  interface FigmaConfig {
98
99
  codeConnect?: CodeConnectConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAA;AAY3B,eAAO,MAAM,+BAA+B;;;;;;;CAQ3C,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,OAA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AAC,GAAG,EAAE,MAAM,UAErC;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;GAyC3E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM;;;GAoCpD;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,WAAW,CAAC,CAoDtB;AAoBD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAO1F;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,CAAC,sBAAsB,CAAC,GAC/C,gBAAgB,CAOlB;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,OAAO,CAcpF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAG,MAAM,GAAG,IAAI,CAoD7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,sBAAsB,GAC7B,MAAM,GAAG,IAAI,CAoBf"}
@@ -519,7 +519,7 @@ async function getProjectInfoFromConfig(dir, config) {
519
519
  function validateLanguage(language) {
520
520
  if (!language)
521
521
  return;
522
- const validLanguages = Object.values(label_language_mapping_1.CodeConnectLanguage);
522
+ const validLanguages = Object.values(label_language_mapping_1.SyntaxHighlightLanguage);
523
523
  if (!validLanguages.includes(language)) {
524
524
  throw new Error(`Invalid language "${language}" in figma.config.json. ` +
525
525
  `Valid values are: ${validLanguages.join(', ')}`);
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":";;;;;;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\nimport ts from 'typescript'\nimport { exitWithError, logger } from '../common/logging'\nimport chalk from 'chalk'\nimport readline from 'readline'\n// We use an old version of this dep as I couldn't get ES modules working\nimport findUp from 'find-up'\nimport { exitWithFeedbackMessage } from './helpers'\nimport { CodeConnectLabel, CodeConnectLanguage } from './label_language_mapping'\n\nconst DEFAULT_CONFIG_FILE_NAME = 'figma.config.json'\nconst ENV_FILE_NAME = '.env'\n\nexport const DEFAULT_INCLUDE_GLOBS_BY_PARSER = {\n react: [`**/*.{tsx,jsx}`],\n html: [`**/*.{ts,js}`],\n swift: ['**/*.swift'],\n compose: ['**/*.kt'],\n // include globs should be included in configs for custom parsers\n custom: undefined,\n __unit_test__: [''],\n}\n\nexport const DEFAULT_LABEL_PER_PARSER: Partial<Record<CodeConnectParser, string>> = {\n react: CodeConnectLabel.React,\n html: CodeConnectLabel.WebComponents,\n}\n\n// First party parsers which call into parser executables\nexport type CodeConnectExecutableParser = 'swift' | 'compose' | 'custom' | '__unit_test__'\n\n// React is a special case for now as we call it directly from the CLI rather\n// than via an executable for legacy reasons. We will migrate it to the\n// parser executable model.\nexport type CodeConnectParser = 'react' | 'html' | CodeConnectExecutableParser\n\nexport type BaseCodeConnectConfig = {\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * included when looking for source files. If not specified, all files\n * (except any specified in `exclude`) will be included.\n */\n include?: string[]\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * excluded when looking for source files. If not specified, only\n * `node_modules` will be excluded.\n */\n exclude?: string[]\n /**\n * Optional object of substitutions applied to document URLs (in the format {\n * fromString, toString }) for testing (e.g. remapping a production URL to a\n * staging URL). Not publicly documented.\n */\n documentUrlSubstitutions?: Record<string, string>\n /**\n * The parser name, if using an internal parser.\n */\n parser: CodeConnectParser\n\n /**\n * Label to use for the uploaded code examples\n */\n label?: string\n\n /**\n * Language to use for syntax highlighting in the uploaded code examples.\n * Valid values: 'typescript', 'swift', 'kotlin', 'html', 'raw'\n * If not specified, language is inferred from the label or parser type.\n */\n language?: string\n\n /**\n * The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.\n */\n interactiveSetupFigmaFileUrl?: string\n\n /**\n * Custom Figma API URL to use instead of https://api.figma.com/v1\n */\n apiUrl?: string\n}\n\nexport type CodeConnectExecutableParserConfig = BaseCodeConnectConfig & {\n parser: CodeConnectExecutableParser\n}\n\nexport type CodeConnectCustomExecutableParserConfig = BaseCodeConnectConfig & {\n parser: 'custom'\n parserCommand: string\n}\n\n/**\n * React specific configuration\n */\nexport type CodeConnectReactConfig = BaseCodeConnectConfig & {\n parser: 'react'\n /**\n * Maps imports from their path on disk to the specified path.\n * This will rewrite the imports in generated code examples, so it works with\n * relative imports such as `import { Button } from \"./\"`.\n *\n * Example: { \"src/components/*\": \"@ui/components\" }\n * Would rewrite imports for components located in `src/components` to `@ui/components` in\n * generated code examples.\n * `import { Button } from \"./\"` -> `import { Button } from \"@ui/components/Button\"`\n */\n importPaths?: Record<string, string>\n /**\n * For import resolution - this is a temporary solution to support projects that use\n * pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when\n * the package in node_modules is a symlink. Need to look into this more and find a\n * better solution.\n */\n paths?: Record<string, string[]>\n /**\n * Storybook specific configuration\n */\n storybook?: {\n /**\n * The URL of the Storybook instance for the project\n */\n url: string\n }\n}\n\nexport type CodeConnectHtmlConfig = BaseCodeConnectConfig & {}\n\nexport type CodeConnectConfig =\n | CodeConnectReactConfig\n | CodeConnectExecutableParserConfig\n | CodeConnectCustomExecutableParserConfig\n | CodeConnectHtmlConfig\n | BaseCodeConnectConfig\n\ninterface FigmaConfig {\n codeConnect?: CodeConnectConfig\n}\n\nexport function determineConfigFromProject(\n dir: string,\n exitOnError = true,\n): FigmaConfig | undefined {\n const parser = determineParserFromProject(dir)\n if (parser) {\n const label = determineLabelFromProject(dir)\n if (label) {\n return { codeConnect: { parser, label } }\n }\n\n return { codeConnect: { parser } }\n }\n\n if (exitOnError) {\n exitWithError(\n `Code Connect was not able to determine your project type, and no config file was found. Please ensure you are running Code Connect from your project root. You may need to create a config file specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n }\n}\n\nfunction showParserMessage(message: string) {\n logger.info(\n message +\n '. If this is incorrect, please check you are running Code Connect from your project root, or add a `parser` key to your config file. See https://github.com/figma/code-connect for more information.',\n )\n}\n\nfunction packageJsonContains(packageJson: any, dependency: string) {\n return (\n (packageJson.dependencies && packageJson.dependencies[dependency]) ||\n (packageJson.peerDependencies && packageJson.peerDependencies[dependency]) ||\n (packageJson.devDependencies && packageJson.devDependencies[dependency])\n )\n}\n\n// Walk up from the given directory looking for the first directory which\n// matches heuristics for the platforms we support. This means that e.g. if you\n// have a Swift project inside a React project, we'll detect Swift. This enables\n// users to run commands from anywhere inside their project, rather than having\n// to run from the root (the same way npm works).\nfunction determineParserFromProject(dir: string): CodeConnectParser | undefined {\n let parser: CodeConnectParser | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'react')) {\n showParserMessage(\n `Using \"react\" parser as package.json containing a \"react\" ${\n packageJson.dependencies && packageJson.dependencies['react']\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n parser = 'react'\n return findUp.stop\n } else {\n showParserMessage(\n `Using \"html\" parser as package.json containing no other supported web frameworks was found in ${currentDir}`,\n )\n parser = 'html'\n return findUp.stop\n }\n } else {\n if (globSync([`${currentDir}/*.xcodeproj`, `${currentDir}/Package.swift`]).length > 0) {\n showParserMessage(\n `Using \"swift\" parser as a file matching *.xcodeproj or Package.swift was found in ${currentDir}`,\n )\n parser = 'swift'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle.kts`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle.kts was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return parser\n}\n\n// Similarly to determineParserFromProject, this walks up looking for a\n// package.json containing a library which we support and we set a specific\n// label for. An example is Angular, which is detected as 'html' parser, but we\n// set a different label for it.\nexport function determineLabelFromProject(dir: string): string | undefined {\n function showMessage(\n libraryName: string,\n moduleName: string,\n packageJson: any,\n currentDir: string,\n ) {\n showParserMessage(\n `Using \"${libraryName}\" label as package.json containing a \"${moduleName}\" ${\n packageJson.dependencies && packageJson.dependencies[moduleName]\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n }\n\n let label: string | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'angular')) {\n showMessage('Angular', 'angular', packageJson, currentDir)\n label = CodeConnectLabel.Angular\n return findUp.stop\n } else if (packageJsonContains(packageJson, 'vue')) {\n showMessage('Vue', 'vue', packageJson, currentDir)\n label = CodeConnectLabel.Vue\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return label\n}\n\nasync function checkForLegacyConfig(\n config: FigmaConfig & { codeConnect: { swift?: any; react?: any } },\n configFilePath: string,\n): Promise<FigmaConfig> | never {\n const { codeConnect } = config\n\n const newConfigBase = {\n ...(codeConnect.include ? { include: codeConnect.include } : {}),\n ...(codeConnect.exclude ? { exclude: codeConnect.exclude } : {}),\n ...(codeConnect.documentUrlSubstitutions\n ? { documentUrlSubstitutions: codeConnect.documentUrlSubstitutions }\n : {}),\n }\n const maybeNewReactConfig = {\n codeConnect: { parser: 'react', ...codeConnect.react, ...newConfigBase },\n }\n const maybeNewSwiftConfig = {\n codeConnect: { parser: 'swift', ...codeConnect.swift, ...newConfigBase },\n }\n\n if (codeConnect.react && codeConnect.swift) {\n logger.error(`${chalk.bold('⚠️ Your Code Connect configuration needs to be updated\\n')}`)\n\n logger.infoForce(`Code Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be split into two configuration files, one for React and one for Swift.\n\nThe React ${chalk.bold(\n 'figma.config.json',\n )} should be located in your React project root and contain:\n\n${JSON.stringify(maybeNewReactConfig, null, 2)}\n\nThe Swift ${chalk.bold(\n 'figma.config.json',\n )} should be located in your Swift project root and contain:\n\n${JSON.stringify(maybeNewSwiftConfig, null, 2)}\n\nYou will need to check any include/exclude paths are correct relative to the new locations.`)\n exitWithFeedbackMessage(1)\n }\n\n if (codeConnect.react || codeConnect.swift) {\n const platform = codeConnect.react ? 'React' : 'Swift'\n const newConfig = codeConnect.react ? maybeNewReactConfig : maybeNewSwiftConfig\n\n logger.infoForce(\n `${chalk.bold('⚠️ Your Code Connect configuration needs to be updated')}\n\nCode Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be updated to remove the ${chalk.bold(\n platform.toLowerCase(),\n )} key and add ${chalk.bold(`{ parser: \"${platform.toLowerCase()}\" }`)}:\n\n${JSON.stringify(newConfig, null, 2)}\n\nCode Connect can make this change for you automatically, or you can do it manually.\n\nPlease also ensure your configuration file is located in your ${platform} project root. If you move the configuration file, you will need to check any include/exclude paths are correct relative to the new location.\n\nPlease raise an issue at https://github.com/figma/code-connect/issues if you have any problems.\n\n---\n`,\n )\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n })\n\n const updateConfig = await new Promise<string>((resolve) => {\n rl.question(\n 'Would you like Code Connect to update your configuration file for you? (y/n) ',\n (answer) => {\n resolve(answer)\n },\n )\n })\n rl.close()\n\n if (updateConfig.toLowerCase() === 'y') {\n fs.writeFileSync(configFilePath, JSON.stringify(newConfig, null, 2))\n logger.infoForce(`\\nConfiguration file updated`)\n return newConfig\n } else {\n exitWithError(`\\nPlease update your configuration file manually`)\n }\n }\n\n return config\n}\n\nasync function parseConfig(configFilePath: string, dir: string): Promise<FigmaConfig | undefined> {\n try {\n const rawData = fs.readFileSync(configFilePath, 'utf-8')\n const rawConfig = JSON.parse(rawData)\n const config = await checkForLegacyConfig(rawConfig, configFilePath)\n\n if (!config.codeConnect?.parser) {\n const parser = determineParserFromProject(dir)\n\n if (!parser) {\n logger.error(\n `Code Connect was not able to determine your project type, and no \\`parser\\` was specified. Please ensure you are running Code Connect from your project root. You may need to add a \\`parser\\` key to your config file, specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n exitWithFeedbackMessage(1)\n }\n\n if (!config.codeConnect) {\n config.codeConnect = { parser }\n }\n // TS errors if this is in an else\n config.codeConnect.parser = parser\n }\n\n if (!config.codeConnect?.label) {\n const label = determineLabelFromProject(dir)\n if (label) {\n config.codeConnect.label = label\n }\n }\n\n return config\n } catch (error) {\n console.error('Error parsing config file:', error)\n return undefined\n }\n}\n\nexport function getGitRemoteURL(repoPath: string) {\n try {\n const spawn = spawnSync('git', ['config', '--get', 'remote.origin.url'], {\n cwd: repoPath,\n })\n const output = spawn.stdout\n return (output || '').toString().trim()\n } catch (error) {\n console.error('Error getting git remote URL:', error)\n return ''\n }\n}\n\n/**\n * Uses `git rev-parse` to find absolute path to the root of the git repository\n */\nexport function getGitRepoAbsolutePath(filePath: string) {\n try {\n const dirPath = fs.statSync(filePath).isDirectory() ? filePath : path.dirname(filePath)\n const spawn = spawnSync('git', ['rev-parse', '--show-toplevel'], {\n cwd: dirPath,\n })\n const output = spawn.stdout\n return (\n (output || '')\n .toString()\n // git always uses /, but other Node API use \\ on Windows\n .replaceAll('/', path.sep)\n .trim()\n )\n } catch (error: any) {\n console.error('Error running `git rev-parse`:', error.toString().split('\\n')[0])\n return ''\n }\n}\n\n/**\n * Find the default branch name (master or main) for the git repository\n */\nexport function getGitRepoDefaultBranchName(repoPath: string) {\n const DEFAULT_BRANCH_NAME = 'master'\n\n try {\n // Get all git branches\n const gitBranchResult = spawnSync('git', ['branch', '-r'], {\n cwd: repoPath,\n })\n\n if (!gitBranchResult.stdout) {\n return DEFAULT_BRANCH_NAME\n }\n\n const branches = gitBranchResult.stdout\n .toString()\n .trim()\n .split('\\n')\n .map((s) => s.trim())\n\n // Check if origin/main exists, otherwise assume master\n if (branches.includes('origin/main')) {\n return 'main'\n } else {\n return DEFAULT_BRANCH_NAME\n }\n } catch (error: any) {\n console.error('Error getting git default branch name:', error.toString().split('\\n')[0])\n return DEFAULT_BRANCH_NAME\n }\n}\n\n/**\n * Finds the URL of a remote file\n * @param filePath absolute file path on disk\n * @param repoURL remote URL, can be a GitHub, GitLab, Bitbucket, etc. URL.\n * @returns\n */\nexport function getRemoteFileUrl(filePath: string, repoURL?: string) {\n if (!repoURL) {\n return ''\n }\n\n filePath = filePath.replaceAll(path.sep, '/')\n\n let url = repoURL.trim()\n if (url.startsWith('git@')) {\n url = url.replace(':', '/')\n url = url.replace('git@', 'https://')\n }\n url = url.replace(/\\.git$/, '')\n\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath)\n // Windows uses \\ as the path separator, so replace with /\n .replaceAll(path.sep, '/')\n\n const defaultBranch = getGitRepoDefaultBranchName(repoAbsPath)\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length)\n\n if (url.includes('github.com')) {\n return `${url}/blob/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('gitlab.com')) {\n return `${url}/-/blob/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('bitbucket.org')) {\n return `${url}/src/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('dev.azure.com')) {\n // `git config --get remote.origin.url` for azure repos will return different strings depending on if it was\n // cloned with https or ssh. We need to convert this to a valid URL like \"https://dev.azure.com/org/repo/_git/repo?path=/\"\n if (repoURL.startsWith('git@')) {\n // ssh: \"git@ssh.dev.azure.com:v3/org/repo/repo\"\n const [org, project1, project2] = repoURL.split('/').slice(-3)\n return `https://dev.azure.com/${org}/${project1}/_git/${project2}?path=${relativeFilePath}&branch=${defaultBranch}`\n } else {\n // https: \"https://org@dev.azure.com/org/repo/_git/repo\"\n const [_, url] = repoURL.split('@')\n return `https://${url}?path=${relativeFilePath}&branch=${defaultBranch}`\n }\n } else {\n logger.debug('Unknown remote URL - assuming GitHub Enterprise', url)\n return `${url}/blob/${defaultBranch}${relativeFilePath}`\n }\n}\n\nexport function getStorybookUrl(filePath: string, storybookUrl: string) {\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath).replaceAll(path.sep, '/')\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length + 1) // +1 to remove the leading slash\n const storybookComponentPath = relativeFilePath\n .trim()\n .replace(/[\\s|_]/g, '-')\n .replace(/\\.[jt]sx?$/, '')\n .replaceAll('\\\\', '/')\n .split('/')\n .join('-')\n\n return `${storybookUrl}/?path=/docs/${storybookComponentPath}`\n}\n\nexport type ProjectInfo<ConfigT = CodeConnectConfig> = {\n /**\n * Absolute path of the project directory\n */\n absPath: string\n /**\n * An array of all tsx files in the project\n */\n files: string[]\n /**\n * The git remote URL of the project\n */\n remoteUrl: string\n /**\n * The parsed Code Connect config file\n */\n config: ConfigT\n}\n\nexport type ReactProjectInfo = ProjectInfo<CodeConnectReactConfig> & {\n /**\n * TS program containing all tsx files in the project\n */\n tsProgram: ts.Program\n}\n\nfunction mapToAbsolutePaths(globPaths: string[], absPath: string) {\n // glob doesn't like Windows paths so convert to *nix format\n return globPaths.map((globPath) => `${absPath.replaceAll(path.sep, '/')}/${globPath}`)\n}\n\nexport function getDefaultConfigPath(dir: string) {\n return path.resolve(path.join(dir, DEFAULT_CONFIG_FILE_NAME))\n}\n\nexport function getEnvPath(dir: string) {\n return path.resolve(path.join(dir, ENV_FILE_NAME))\n}\n\nexport async function parseOrDetermineConfig(dir: string, configPath: string) {\n const configFilePath = configPath ? path.resolve(configPath) : getDefaultConfigPath(dir)\n\n const hasConfigFile = fs.existsSync(configFilePath)\n\n if (!hasConfigFile) {\n if (configPath) {\n logger.warn(`${configPath} does not exist, proceeding with default options`)\n } else {\n logger.info(`No config file found in ${dir}, proceeding with default options`)\n }\n }\n\n const globalConfig = hasConfigFile\n ? await parseConfig(configFilePath, dir)\n : determineConfigFromProject(dir)\n\n if (!globalConfig) {\n throw new Error(`Error parsing config file: ${configFilePath}`)\n }\n\n if (!globalConfig.codeConnect) {\n throw new Error(`No options specified under 'codeConnect' in config file: ${configFilePath}`)\n }\n\n const config = globalConfig.codeConnect\n\n if (hasConfigFile) {\n if (!config) {\n logger.info(`Config file found, but no options specified under 'codeConnect'. Parsing ${dir}`)\n } else if (config && !config.include) {\n logger.info(`Config file found, but no include globs specified. Parsing ${dir}`)\n } else {\n logger.info(`Config file found, parsing ${dir} using specified include globs`)\n }\n }\n\n return {\n config,\n hasConfigFile,\n }\n}\n\n/**\n * Check if a .env file exists in the provided directory and if it contains a FIGMA_ACCESS_TOKEN.\n */\nexport async function checkForEnvAndToken(dir: string) {\n // Scan the provided directory for a .env file\n const envPath = await findUp('.env', { cwd: dir })\n\n if (!envPath) {\n // No .env file found\n return {\n hasEnvFile: false,\n envHasFigmaToken: false,\n }\n }\n\n // Read the contents of the .env file\n const envContents = fs.readFileSync(envPath, 'utf-8')\n\n // Determine if the .env file contains a FIGMA_ACCESS_TOKEN\n const envVars = envContents.split('\\n').reduce(\n (\n acc: {\n [key: string]: string\n },\n line,\n ) => {\n const [key, value] = line.split('=')\n acc[key] = value\n return acc\n },\n {},\n )\n\n const figmaAccessToken = envVars['FIGMA_ACCESS_TOKEN']\n\n return {\n hasEnvFile: true,\n envHasFigmaToken: !!figmaAccessToken,\n }\n}\n\n/**\n * Gets information about a project from config.\n *\n * @param dir Directory containing the project\n * @param config Code Connect config\n * @returns Object containing information about the project\n */\nexport async function getProjectInfoFromConfig(\n dir: string,\n config: CodeConnectConfig,\n): Promise<ProjectInfo> {\n const absPath = path.resolve(dir)\n const remoteUrl = getGitRemoteURL(absPath)\n\n const defaultIncludeGlobs = config.parser\n ? DEFAULT_INCLUDE_GLOBS_BY_PARSER[config.parser]\n : undefined\n\n // always ignore any `node_modules` folders in react projects\n const defaultExcludeGlobs = config.parser\n ? ({\n react: ['node_modules/**'],\n html: ['node_modules/**'],\n swift: ['**/__test__/**'],\n compose: [],\n custom: [],\n __unit_test__: [],\n }[config.parser] ?? [])\n : []\n\n const includeGlobs = config.include || defaultIncludeGlobs\n const excludeGlobs = config.exclude\n ? [...config.exclude, ...defaultExcludeGlobs]\n : defaultExcludeGlobs\n\n if (config.parser === 'custom' && (!includeGlobs || includeGlobs.length === 0)) {\n exitWithError('Include globs must specified in config file for custom parsers')\n }\n\n if (!includeGlobs) {\n exitWithError('No include globs specified in config file')\n }\n\n const files = globSync(mapToAbsolutePaths(includeGlobs, absPath), {\n nodir: true,\n ignore: mapToAbsolutePaths(excludeGlobs, absPath),\n // Otherwise this is true on *nix and false on Windows\n absolute: true,\n })\n\n if (files.length > 10000) {\n logger.warn(\n `Matching number of files was excessively large (${files.length}) - consider using more specific include/exclude globs in your config file.`,\n )\n }\n\n return {\n absPath,\n remoteUrl,\n config,\n files,\n }\n}\n\n/**\n * Validates the language field in the config.\n * Throws an error if the language is invalid.\n *\n * @param language The language string to validate\n */\nfunction validateLanguage(language: string | undefined): void {\n if (!language) return\n\n const validLanguages = Object.values(CodeConnectLanguage)\n if (!validLanguages.includes(language as CodeConnectLanguage)) {\n throw new Error(\n `Invalid language \"${language}\" in figma.config.json. ` +\n `Valid values are: ${validLanguages.join(', ')}`,\n )\n }\n}\n\n/**\n * Gets information about a project from a directory.\n *\n * @param dir Directory containing the project\n * @param configPath Optional path to Code Connect config file\n * @returns Object containing information about the project\n */\nexport async function getProjectInfo(dir: string, configPath: string): Promise<ProjectInfo> {\n const { config } = await parseOrDetermineConfig(dir, configPath)\n\n // Validate language field if present\n validateLanguage(config.language)\n\n return getProjectInfoFromConfig(dir, config)\n}\n\nexport function getReactProjectInfo(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n): ReactProjectInfo {\n const tsProgram = getTsProgram(projectInfo)\n\n return {\n ...projectInfo,\n tsProgram,\n }\n}\n\nexport function getTsProgram(projectInfo: ProjectInfo<CodeConnectConfig>): ts.Program {\n const compilerOptions: ts.CompilerOptions = {\n // This ensures the compiler can resolve imports such as \"ui/button\" when a\n // baseUrl is configured in the tsconfig of the project. We probably want a more\n // sophisticated way to parse the users tsconfig and pass it to the compiler eventually.\n baseUrl: projectInfo.absPath,\n // TODO: not sure why Node10 is needed her, but otherwise module resolution for\n // pnpm workspaces won't work\n moduleResolution: ts.ModuleResolutionKind.Node10,\n paths: 'paths' in projectInfo.config ? (projectInfo.config.paths ?? {}) : {},\n allowJs: true,\n }\n\n return ts.createProgram(projectInfo.files, compilerOptions)\n}\n\n/**\n * Change an imported path for a component like `./button` to e.g `@ui/button`, based on the config file.\n * Note that `filePath` here is the path to the source file on disk, not the module specifier.\n *\n * @param filePath\n * @param config\n * @returns\n */\nexport function mapImportPath(filePath: string, config: CodeConnectReactConfig): string | null {\n // Takes the reversed path and pattern parts and check if they match\n function isMatch(patternParts: string[], pathParts: string[]) {\n if (patternParts[0] === '*') {\n // if the path is just a wildcard and nothing else, match any import\n if (patternParts.length === 1) {\n return true\n }\n\n // if the _next_ part in the pattern does not exist in the path, it's not\n // a match.\n const index = pathParts.indexOf(patternParts[1])\n if (index === -1) {\n return false\n }\n\n // Skip to the matching part in the path and match the rest of\n // the pattern. E.g if the pattern is `*/ui/src` (reversed) and the path is\n // `button.tsx/components/ui/src`, we skip to `ui` and match the rest of the\n // pattern.\n patternParts = patternParts.slice(1)\n pathParts = pathParts.slice(index)\n }\n\n for (let i = 0; i < patternParts.length; i++) {\n if (patternParts[i] !== pathParts[i]) {\n return false\n }\n }\n return true\n }\n\n for (const [key, value] of Object.entries(config.importPaths || {})) {\n // Do a partial match from the end of the path\n const patternParts = key.split('/').reverse()\n const pathParts = filePath.split('/').reverse()\n if (pathParts.length < patternParts.length) {\n continue\n }\n\n // If the mapped path ends with a wildcard we want to keep the filename in\n // the final path\n if (isMatch(patternParts, pathParts)) {\n if (value.endsWith('*')) {\n const filename = pathParts[0].split('.')[0]\n return `${value.slice(0, -1)}${filename}`\n }\n return value\n }\n }\n\n return null\n}\n\n/**\n * Transform an import specifier (the path in the import statement) using importPaths config.\n * This works directly on the module specifier from the source code, preserving the user's intent.\n *\n * E.g., '@/AlertTitle' with config { \"@/*\": \"@acme/package/*\" } → '@acme/package/AlertTitle'\n *\n * @param specifier The original import specifier from the source file (e.g., '@/AlertTitle', './Button')\n * @param config The Code Connect config containing importPaths\n * @returns The transformed import path, or null if no mapping matched\n */\nexport function mapImportSpecifier(\n specifier: string,\n config: CodeConnectReactConfig,\n): string | null {\n for (const [pattern, replacement] of Object.entries(config.importPaths || {})) {\n // Convert glob pattern to regex: @/* → ^@/(.*)$\n // First escape special regex chars, then convert * to capture group\n const regexPattern = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special chars except *\n .replace(/\\*/g, '(.*)') // Convert * to capture group\n const regex = new RegExp(`^${regexPattern}$`)\n const match = specifier.match(regex)\n\n if (match) {\n // Replace * in replacement with captured group\n let result = replacement\n if (match[1] !== undefined) {\n result = replacement.replace('*', match[1])\n }\n return result\n }\n }\n return null\n}\n"]}
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":";;;;;;AA+IA,gEAmBC;AAgFD,8DAuCC;AAsID,0CAWC;AAKD,wDAkBC;AAKD,kEA6BC;AAQD,4CAmDC;AAED,0CAoBC;AAiCD,oDAE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C,CAAC,CAAA;gBAC3C,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAA;YAC3C,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAChC,SAAiB,EACjB,MAA8B;IAE9B,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9E,gDAAgD;QAChD,oEAAoE;QACpE,MAAM,YAAY,GAAG,OAAO;aACzB,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,gCAAgC;aACtE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA,CAAC,6BAA6B;QACvD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAA;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEpC,IAAI,KAAK,EAAE,CAAC;YACV,+CAA+C;YAC/C,IAAI,MAAM,GAAG,WAAW,CAAA;YACxB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { spawnSync } from 'child_process'\nimport { globSync } from 'glob'\nimport path from 'path'\nimport fs from 'fs'\nimport ts from 'typescript'\nimport { exitWithError, logger } from '../common/logging'\nimport chalk from 'chalk'\nimport readline from 'readline'\n// We use an old version of this dep as I couldn't get ES modules working\nimport findUp from 'find-up'\nimport { exitWithFeedbackMessage } from './helpers'\nimport { CodeConnectLabel, SyntaxHighlightLanguage } from './label_language_mapping'\n\nconst DEFAULT_CONFIG_FILE_NAME = 'figma.config.json'\nconst ENV_FILE_NAME = '.env'\n\nexport const DEFAULT_INCLUDE_GLOBS_BY_PARSER = {\n react: [`**/*.{tsx,jsx}`],\n html: [`**/*.{ts,js}`],\n swift: ['**/*.swift'],\n compose: ['**/*.kt'],\n // include globs should be included in configs for custom parsers\n custom: undefined,\n __unit_test__: [''],\n}\n\nexport const DEFAULT_LABEL_PER_PARSER: Partial<Record<CodeConnectParser, string>> = {\n react: CodeConnectLabel.React,\n html: CodeConnectLabel.WebComponents,\n}\n\n// First party parsers which call into parser executables\nexport type CodeConnectExecutableParser = 'swift' | 'compose' | 'custom' | '__unit_test__'\n\n// React is a special case for now as we call it directly from the CLI rather\n// than via an executable for legacy reasons. We will migrate it to the\n// parser executable model.\nexport type CodeConnectParser = 'react' | 'html' | CodeConnectExecutableParser\n\nexport type BaseCodeConnectConfig = {\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * included when looking for source files. If not specified, all files\n * (except any specified in `exclude`) will be included.\n */\n include?: string[]\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * excluded when looking for source files. If not specified, only\n * `node_modules` will be excluded.\n */\n exclude?: string[]\n /**\n * Optional object of substitutions applied to document URLs (in the format {\n * fromString, toString }) for testing (e.g. remapping a production URL to a\n * staging URL). Not publicly documented.\n */\n documentUrlSubstitutions?: Record<string, string>\n /**\n * The parser name, if using an internal parser.\n */\n parser: CodeConnectParser\n\n /**\n * Label to use for the uploaded code examples\n */\n label?: string\n\n /**\n * Language to use for syntax highlighting in the uploaded code examples.\n * If not specified, language is inferred from the label or parser type.\n */\n language?: SyntaxHighlightLanguage\n\n /**\n * The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.\n */\n interactiveSetupFigmaFileUrl?: string\n\n /**\n * Custom Figma API URL to use instead of https://api.figma.com/v1\n */\n apiUrl?: string\n}\n\nexport type CodeConnectExecutableParserConfig = BaseCodeConnectConfig & {\n parser: CodeConnectExecutableParser\n}\n\nexport type CodeConnectCustomExecutableParserConfig = BaseCodeConnectConfig & {\n parser: 'custom'\n parserCommand: string\n}\n\n/**\n * React specific configuration\n */\nexport type CodeConnectReactConfig = BaseCodeConnectConfig & {\n parser: 'react'\n /**\n * Maps imports from their path on disk to the specified path.\n * This will rewrite the imports in generated code examples, so it works with\n * relative imports such as `import { Button } from \"./\"`.\n *\n * Example: { \"src/components/*\": \"@ui/components\" }\n * Would rewrite imports for components located in `src/components` to `@ui/components` in\n * generated code examples.\n * `import { Button } from \"./\"` -> `import { Button } from \"@ui/components/Button\"`\n */\n importPaths?: Record<string, string>\n /**\n * For import resolution - this is a temporary solution to support projects that use\n * pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when\n * the package in node_modules is a symlink. Need to look into this more and find a\n * better solution.\n */\n paths?: Record<string, string[]>\n /**\n * Storybook specific configuration\n */\n storybook?: {\n /**\n * The URL of the Storybook instance for the project\n */\n url: string\n }\n}\n\nexport type CodeConnectHtmlConfig = BaseCodeConnectConfig & {}\n\nexport type CodeConnectParserlessConfig = Omit<BaseCodeConnectConfig, 'parser'>\n\nexport type CodeConnectConfig =\n | CodeConnectReactConfig\n | CodeConnectExecutableParserConfig\n | CodeConnectCustomExecutableParserConfig\n | CodeConnectHtmlConfig\n | BaseCodeConnectConfig\n\ninterface FigmaConfig {\n codeConnect?: CodeConnectConfig\n}\n\nexport function determineConfigFromProject(\n dir: string,\n exitOnError = true,\n): FigmaConfig | undefined {\n const parser = determineParserFromProject(dir)\n if (parser) {\n const label = determineLabelFromProject(dir)\n if (label) {\n return { codeConnect: { parser, label } }\n }\n\n return { codeConnect: { parser } }\n }\n\n if (exitOnError) {\n exitWithError(\n `Code Connect was not able to determine your project type, and no config file was found. Please ensure you are running Code Connect from your project root. You may need to create a config file specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n }\n}\n\nfunction showParserMessage(message: string) {\n logger.info(\n message +\n '. If this is incorrect, please check you are running Code Connect from your project root, or add a `parser` key to your config file. See https://github.com/figma/code-connect for more information.',\n )\n}\n\nfunction packageJsonContains(packageJson: any, dependency: string) {\n return (\n (packageJson.dependencies && packageJson.dependencies[dependency]) ||\n (packageJson.peerDependencies && packageJson.peerDependencies[dependency]) ||\n (packageJson.devDependencies && packageJson.devDependencies[dependency])\n )\n}\n\n// Walk up from the given directory looking for the first directory which\n// matches heuristics for the platforms we support. This means that e.g. if you\n// have a Swift project inside a React project, we'll detect Swift. This enables\n// users to run commands from anywhere inside their project, rather than having\n// to run from the root (the same way npm works).\nfunction determineParserFromProject(dir: string): CodeConnectParser | undefined {\n let parser: CodeConnectParser | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'react')) {\n showParserMessage(\n `Using \"react\" parser as package.json containing a \"react\" ${\n packageJson.dependencies && packageJson.dependencies['react']\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n parser = 'react'\n return findUp.stop\n } else {\n showParserMessage(\n `Using \"html\" parser as package.json containing no other supported web frameworks was found in ${currentDir}`,\n )\n parser = 'html'\n return findUp.stop\n }\n } else {\n if (globSync([`${currentDir}/*.xcodeproj`, `${currentDir}/Package.swift`]).length > 0) {\n showParserMessage(\n `Using \"swift\" parser as a file matching *.xcodeproj or Package.swift was found in ${currentDir}`,\n )\n parser = 'swift'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle.kts`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle.kts was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return parser\n}\n\n// Similarly to determineParserFromProject, this walks up looking for a\n// package.json containing a library which we support and we set a specific\n// label for. An example is Angular, which is detected as 'html' parser, but we\n// set a different label for it.\nexport function determineLabelFromProject(dir: string): string | undefined {\n function showMessage(\n libraryName: string,\n moduleName: string,\n packageJson: any,\n currentDir: string,\n ) {\n showParserMessage(\n `Using \"${libraryName}\" label as package.json containing a \"${moduleName}\" ${\n packageJson.dependencies && packageJson.dependencies[moduleName]\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n }\n\n let label: string | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'angular')) {\n showMessage('Angular', 'angular', packageJson, currentDir)\n label = CodeConnectLabel.Angular\n return findUp.stop\n } else if (packageJsonContains(packageJson, 'vue')) {\n showMessage('Vue', 'vue', packageJson, currentDir)\n label = CodeConnectLabel.Vue\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return label\n}\n\nasync function checkForLegacyConfig(\n config: FigmaConfig & { codeConnect: { swift?: any; react?: any } },\n configFilePath: string,\n): Promise<FigmaConfig> | never {\n const { codeConnect } = config\n\n const newConfigBase = {\n ...(codeConnect.include ? { include: codeConnect.include } : {}),\n ...(codeConnect.exclude ? { exclude: codeConnect.exclude } : {}),\n ...(codeConnect.documentUrlSubstitutions\n ? { documentUrlSubstitutions: codeConnect.documentUrlSubstitutions }\n : {}),\n }\n const maybeNewReactConfig = {\n codeConnect: { parser: 'react', ...codeConnect.react, ...newConfigBase },\n }\n const maybeNewSwiftConfig = {\n codeConnect: { parser: 'swift', ...codeConnect.swift, ...newConfigBase },\n }\n\n if (codeConnect.react && codeConnect.swift) {\n logger.error(`${chalk.bold('⚠️ Your Code Connect configuration needs to be updated\\n')}`)\n\n logger.infoForce(`Code Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be split into two configuration files, one for React and one for Swift.\n\nThe React ${chalk.bold(\n 'figma.config.json',\n )} should be located in your React project root and contain:\n\n${JSON.stringify(maybeNewReactConfig, null, 2)}\n\nThe Swift ${chalk.bold(\n 'figma.config.json',\n )} should be located in your Swift project root and contain:\n\n${JSON.stringify(maybeNewSwiftConfig, null, 2)}\n\nYou will need to check any include/exclude paths are correct relative to the new locations.`)\n exitWithFeedbackMessage(1)\n }\n\n if (codeConnect.react || codeConnect.swift) {\n const platform = codeConnect.react ? 'React' : 'Swift'\n const newConfig = codeConnect.react ? maybeNewReactConfig : maybeNewSwiftConfig\n\n logger.infoForce(\n `${chalk.bold('⚠️ Your Code Connect configuration needs to be updated')}\n\nCode Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be updated to remove the ${chalk.bold(\n platform.toLowerCase(),\n )} key and add ${chalk.bold(`{ parser: \"${platform.toLowerCase()}\" }`)}:\n\n${JSON.stringify(newConfig, null, 2)}\n\nCode Connect can make this change for you automatically, or you can do it manually.\n\nPlease also ensure your configuration file is located in your ${platform} project root. If you move the configuration file, you will need to check any include/exclude paths are correct relative to the new location.\n\nPlease raise an issue at https://github.com/figma/code-connect/issues if you have any problems.\n\n---\n`,\n )\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n })\n\n const updateConfig = await new Promise<string>((resolve) => {\n rl.question(\n 'Would you like Code Connect to update your configuration file for you? (y/n) ',\n (answer) => {\n resolve(answer)\n },\n )\n })\n rl.close()\n\n if (updateConfig.toLowerCase() === 'y') {\n fs.writeFileSync(configFilePath, JSON.stringify(newConfig, null, 2))\n logger.infoForce(`\\nConfiguration file updated`)\n return newConfig\n } else {\n exitWithError(`\\nPlease update your configuration file manually`)\n }\n }\n\n return config\n}\n\nasync function parseConfig(configFilePath: string, dir: string): Promise<FigmaConfig | undefined> {\n try {\n const rawData = fs.readFileSync(configFilePath, 'utf-8')\n const rawConfig = JSON.parse(rawData)\n const config = await checkForLegacyConfig(rawConfig, configFilePath)\n\n if (!config.codeConnect?.parser) {\n const parser = determineParserFromProject(dir)\n\n if (!parser) {\n logger.error(\n `Code Connect was not able to determine your project type, and no \\`parser\\` was specified. Please ensure you are running Code Connect from your project root. You may need to add a \\`parser\\` key to your config file, specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n exitWithFeedbackMessage(1)\n }\n\n if (!config.codeConnect) {\n config.codeConnect = { parser }\n }\n // TS errors if this is in an else\n config.codeConnect.parser = parser\n }\n\n if (!config.codeConnect?.label) {\n const label = determineLabelFromProject(dir)\n if (label) {\n config.codeConnect.label = label\n }\n }\n\n return config\n } catch (error) {\n console.error('Error parsing config file:', error)\n return undefined\n }\n}\n\nexport function getGitRemoteURL(repoPath: string) {\n try {\n const spawn = spawnSync('git', ['config', '--get', 'remote.origin.url'], {\n cwd: repoPath,\n })\n const output = spawn.stdout\n return (output || '').toString().trim()\n } catch (error) {\n console.error('Error getting git remote URL:', error)\n return ''\n }\n}\n\n/**\n * Uses `git rev-parse` to find absolute path to the root of the git repository\n */\nexport function getGitRepoAbsolutePath(filePath: string) {\n try {\n const dirPath = fs.statSync(filePath).isDirectory() ? filePath : path.dirname(filePath)\n const spawn = spawnSync('git', ['rev-parse', '--show-toplevel'], {\n cwd: dirPath,\n })\n const output = spawn.stdout\n return (\n (output || '')\n .toString()\n // git always uses /, but other Node API use \\ on Windows\n .replaceAll('/', path.sep)\n .trim()\n )\n } catch (error: any) {\n console.error('Error running `git rev-parse`:', error.toString().split('\\n')[0])\n return ''\n }\n}\n\n/**\n * Find the default branch name (master or main) for the git repository\n */\nexport function getGitRepoDefaultBranchName(repoPath: string) {\n const DEFAULT_BRANCH_NAME = 'master'\n\n try {\n // Get all git branches\n const gitBranchResult = spawnSync('git', ['branch', '-r'], {\n cwd: repoPath,\n })\n\n if (!gitBranchResult.stdout) {\n return DEFAULT_BRANCH_NAME\n }\n\n const branches = gitBranchResult.stdout\n .toString()\n .trim()\n .split('\\n')\n .map((s) => s.trim())\n\n // Check if origin/main exists, otherwise assume master\n if (branches.includes('origin/main')) {\n return 'main'\n } else {\n return DEFAULT_BRANCH_NAME\n }\n } catch (error: any) {\n console.error('Error getting git default branch name:', error.toString().split('\\n')[0])\n return DEFAULT_BRANCH_NAME\n }\n}\n\n/**\n * Finds the URL of a remote file\n * @param filePath absolute file path on disk\n * @param repoURL remote URL, can be a GitHub, GitLab, Bitbucket, etc. URL.\n * @returns\n */\nexport function getRemoteFileUrl(filePath: string, repoURL?: string) {\n if (!repoURL) {\n return ''\n }\n\n filePath = filePath.replaceAll(path.sep, '/')\n\n let url = repoURL.trim()\n if (url.startsWith('git@')) {\n url = url.replace(':', '/')\n url = url.replace('git@', 'https://')\n }\n url = url.replace(/\\.git$/, '')\n\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath)\n // Windows uses \\ as the path separator, so replace with /\n .replaceAll(path.sep, '/')\n\n const defaultBranch = getGitRepoDefaultBranchName(repoAbsPath)\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length)\n\n if (url.includes('github.com')) {\n return `${url}/blob/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('gitlab.com')) {\n return `${url}/-/blob/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('bitbucket.org')) {\n return `${url}/src/${defaultBranch}${relativeFilePath}`\n } else if (url.includes('dev.azure.com')) {\n // `git config --get remote.origin.url` for azure repos will return different strings depending on if it was\n // cloned with https or ssh. We need to convert this to a valid URL like \"https://dev.azure.com/org/repo/_git/repo?path=/\"\n if (repoURL.startsWith('git@')) {\n // ssh: \"git@ssh.dev.azure.com:v3/org/repo/repo\"\n const [org, project1, project2] = repoURL.split('/').slice(-3)\n return `https://dev.azure.com/${org}/${project1}/_git/${project2}?path=${relativeFilePath}&branch=${defaultBranch}`\n } else {\n // https: \"https://org@dev.azure.com/org/repo/_git/repo\"\n const [_, url] = repoURL.split('@')\n return `https://${url}?path=${relativeFilePath}&branch=${defaultBranch}`\n }\n } else {\n logger.debug('Unknown remote URL - assuming GitHub Enterprise', url)\n return `${url}/blob/${defaultBranch}${relativeFilePath}`\n }\n}\n\nexport function getStorybookUrl(filePath: string, storybookUrl: string) {\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath).replaceAll(path.sep, '/')\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length + 1) // +1 to remove the leading slash\n const storybookComponentPath = relativeFilePath\n .trim()\n .replace(/[\\s|_]/g, '-')\n .replace(/\\.[jt]sx?$/, '')\n .replaceAll('\\\\', '/')\n .split('/')\n .join('-')\n\n return `${storybookUrl}/?path=/docs/${storybookComponentPath}`\n}\n\nexport type ProjectInfo<ConfigT = CodeConnectConfig> = {\n /**\n * Absolute path of the project directory\n */\n absPath: string\n /**\n * An array of all tsx files in the project\n */\n files: string[]\n /**\n * The git remote URL of the project\n */\n remoteUrl: string\n /**\n * The parsed Code Connect config file\n */\n config: ConfigT\n}\n\nexport type ReactProjectInfo = ProjectInfo<CodeConnectReactConfig> & {\n /**\n * TS program containing all tsx files in the project\n */\n tsProgram: ts.Program\n}\n\nfunction mapToAbsolutePaths(globPaths: string[], absPath: string) {\n // glob doesn't like Windows paths so convert to *nix format\n return globPaths.map((globPath) => `${absPath.replaceAll(path.sep, '/')}/${globPath}`)\n}\n\nexport function getDefaultConfigPath(dir: string) {\n return path.resolve(path.join(dir, DEFAULT_CONFIG_FILE_NAME))\n}\n\nexport function getEnvPath(dir: string) {\n return path.resolve(path.join(dir, ENV_FILE_NAME))\n}\n\nexport async function parseOrDetermineConfig(dir: string, configPath: string) {\n const configFilePath = configPath ? path.resolve(configPath) : getDefaultConfigPath(dir)\n\n const hasConfigFile = fs.existsSync(configFilePath)\n\n if (!hasConfigFile) {\n if (configPath) {\n logger.warn(`${configPath} does not exist, proceeding with default options`)\n } else {\n logger.info(`No config file found in ${dir}, proceeding with default options`)\n }\n }\n\n const globalConfig = hasConfigFile\n ? await parseConfig(configFilePath, dir)\n : determineConfigFromProject(dir)\n\n if (!globalConfig) {\n throw new Error(`Error parsing config file: ${configFilePath}`)\n }\n\n if (!globalConfig.codeConnect) {\n throw new Error(`No options specified under 'codeConnect' in config file: ${configFilePath}`)\n }\n\n const config = globalConfig.codeConnect\n\n if (hasConfigFile) {\n if (!config) {\n logger.info(`Config file found, but no options specified under 'codeConnect'. Parsing ${dir}`)\n } else if (config && !config.include) {\n logger.info(`Config file found, but no include globs specified. Parsing ${dir}`)\n } else {\n logger.info(`Config file found, parsing ${dir} using specified include globs`)\n }\n }\n\n return {\n config,\n hasConfigFile,\n }\n}\n\n/**\n * Check if a .env file exists in the provided directory and if it contains a FIGMA_ACCESS_TOKEN.\n */\nexport async function checkForEnvAndToken(dir: string) {\n // Scan the provided directory for a .env file\n const envPath = await findUp('.env', { cwd: dir })\n\n if (!envPath) {\n // No .env file found\n return {\n hasEnvFile: false,\n envHasFigmaToken: false,\n }\n }\n\n // Read the contents of the .env file\n const envContents = fs.readFileSync(envPath, 'utf-8')\n\n // Determine if the .env file contains a FIGMA_ACCESS_TOKEN\n const envVars = envContents.split('\\n').reduce(\n (\n acc: {\n [key: string]: string\n },\n line,\n ) => {\n const [key, value] = line.split('=')\n acc[key] = value\n return acc\n },\n {},\n )\n\n const figmaAccessToken = envVars['FIGMA_ACCESS_TOKEN']\n\n return {\n hasEnvFile: true,\n envHasFigmaToken: !!figmaAccessToken,\n }\n}\n\n/**\n * Gets information about a project from config.\n *\n * @param dir Directory containing the project\n * @param config Code Connect config\n * @returns Object containing information about the project\n */\nexport async function getProjectInfoFromConfig(\n dir: string,\n config: CodeConnectConfig,\n): Promise<ProjectInfo> {\n const absPath = path.resolve(dir)\n const remoteUrl = getGitRemoteURL(absPath)\n\n const defaultIncludeGlobs = config.parser\n ? DEFAULT_INCLUDE_GLOBS_BY_PARSER[config.parser]\n : undefined\n\n // always ignore any `node_modules` folders in react projects\n const defaultExcludeGlobs = config.parser\n ? ({\n react: ['node_modules/**'],\n html: ['node_modules/**'],\n swift: ['**/__test__/**'],\n compose: [],\n custom: [],\n __unit_test__: [],\n }[config.parser] ?? [])\n : []\n\n const includeGlobs = config.include || defaultIncludeGlobs\n const excludeGlobs = config.exclude\n ? [...config.exclude, ...defaultExcludeGlobs]\n : defaultExcludeGlobs\n\n if (config.parser === 'custom' && (!includeGlobs || includeGlobs.length === 0)) {\n exitWithError('Include globs must specified in config file for custom parsers')\n }\n\n if (!includeGlobs) {\n exitWithError('No include globs specified in config file')\n }\n\n const files = globSync(mapToAbsolutePaths(includeGlobs, absPath), {\n nodir: true,\n ignore: mapToAbsolutePaths(excludeGlobs, absPath),\n // Otherwise this is true on *nix and false on Windows\n absolute: true,\n })\n\n if (files.length > 10000) {\n logger.warn(\n `Matching number of files was excessively large (${files.length}) - consider using more specific include/exclude globs in your config file.`,\n )\n }\n\n return {\n absPath,\n remoteUrl,\n config,\n files,\n }\n}\n\n/**\n * Validates the language field in the config.\n * Throws an error if the language is invalid.\n *\n * @param language The language string to validate\n */\nfunction validateLanguage(language: SyntaxHighlightLanguage | undefined): void {\n if (!language) return\n\n const validLanguages = Object.values(SyntaxHighlightLanguage)\n if (!validLanguages.includes(language)) {\n throw new Error(\n `Invalid language \"${language}\" in figma.config.json. ` +\n `Valid values are: ${validLanguages.join(', ')}`,\n )\n }\n}\n\n/**\n * Gets information about a project from a directory.\n *\n * @param dir Directory containing the project\n * @param configPath Optional path to Code Connect config file\n * @returns Object containing information about the project\n */\nexport async function getProjectInfo(dir: string, configPath: string): Promise<ProjectInfo> {\n const { config } = await parseOrDetermineConfig(dir, configPath)\n\n // Validate language field if present\n validateLanguage(config.language)\n\n return getProjectInfoFromConfig(dir, config)\n}\n\nexport function getReactProjectInfo(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n): ReactProjectInfo {\n const tsProgram = getTsProgram(projectInfo)\n\n return {\n ...projectInfo,\n tsProgram,\n }\n}\n\nexport function getTsProgram(projectInfo: ProjectInfo<CodeConnectConfig>): ts.Program {\n const compilerOptions: ts.CompilerOptions = {\n // This ensures the compiler can resolve imports such as \"ui/button\" when a\n // baseUrl is configured in the tsconfig of the project. We probably want a more\n // sophisticated way to parse the users tsconfig and pass it to the compiler eventually.\n baseUrl: projectInfo.absPath,\n // TODO: not sure why Node10 is needed her, but otherwise module resolution for\n // pnpm workspaces won't work\n moduleResolution: ts.ModuleResolutionKind.Node10,\n paths: 'paths' in projectInfo.config ? (projectInfo.config.paths ?? {}) : {},\n allowJs: true,\n }\n\n return ts.createProgram(projectInfo.files, compilerOptions)\n}\n\n/**\n * Change an imported path for a component like `./button` to e.g `@ui/button`, based on the config file.\n * Note that `filePath` here is the path to the source file on disk, not the module specifier.\n *\n * @param filePath\n * @param config\n * @returns\n */\nexport function mapImportPath(filePath: string, config: CodeConnectReactConfig): string | null {\n // Takes the reversed path and pattern parts and check if they match\n function isMatch(patternParts: string[], pathParts: string[]) {\n if (patternParts[0] === '*') {\n // if the path is just a wildcard and nothing else, match any import\n if (patternParts.length === 1) {\n return true\n }\n\n // if the _next_ part in the pattern does not exist in the path, it's not\n // a match.\n const index = pathParts.indexOf(patternParts[1])\n if (index === -1) {\n return false\n }\n\n // Skip to the matching part in the path and match the rest of\n // the pattern. E.g if the pattern is `*/ui/src` (reversed) and the path is\n // `button.tsx/components/ui/src`, we skip to `ui` and match the rest of the\n // pattern.\n patternParts = patternParts.slice(1)\n pathParts = pathParts.slice(index)\n }\n\n for (let i = 0; i < patternParts.length; i++) {\n if (patternParts[i] !== pathParts[i]) {\n return false\n }\n }\n return true\n }\n\n for (const [key, value] of Object.entries(config.importPaths || {})) {\n // Do a partial match from the end of the path\n const patternParts = key.split('/').reverse()\n const pathParts = filePath.split('/').reverse()\n if (pathParts.length < patternParts.length) {\n continue\n }\n\n // If the mapped path ends with a wildcard we want to keep the filename in\n // the final path\n if (isMatch(patternParts, pathParts)) {\n if (value.endsWith('*')) {\n const filename = pathParts[0].split('.')[0]\n return `${value.slice(0, -1)}${filename}`\n }\n return value\n }\n }\n\n return null\n}\n\n/**\n * Transform an import specifier (the path in the import statement) using importPaths config.\n * This works directly on the module specifier from the source code, preserving the user's intent.\n *\n * E.g., '@/AlertTitle' with config { \"@/*\": \"@acme/package/*\" } → '@acme/package/AlertTitle'\n *\n * @param specifier The original import specifier from the source file (e.g., '@/AlertTitle', './Button')\n * @param config The Code Connect config containing importPaths\n * @returns The transformed import path, or null if no mapping matched\n */\nexport function mapImportSpecifier(\n specifier: string,\n config: CodeConnectReactConfig,\n): string | null {\n for (const [pattern, replacement] of Object.entries(config.importPaths || {})) {\n // Convert glob pattern to regex: @/* → ^@/(.*)$\n // First escape special regex chars, then convert * to capture group\n const regexPattern = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special chars except *\n .replace(/\\*/g, '(.*)') // Convert * to capture group\n const regex = new RegExp(`^${regexPattern}$`)\n const match = specifier.match(regex)\n\n if (match) {\n // Replace * in replacement with captured group\n let result = replacement\n if (match[1] !== undefined) {\n result = replacement.replace('*', match[1])\n }\n return result\n }\n }\n return null\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/connect/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAO1D,UAAU,IAAI;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,eAAe,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA0CD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,eAAe,EAAE,EACvB,OAAO,EAAE,OAAO,GACf,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAkBhC;AAED,wBAAsB,MAAM,CAAC,EAC3B,WAAW,EACX,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,EAAE,cAAc,GACvB,EAAE,IAAI,iBAkLN"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/connect/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAO1D,UAAU,IAAI;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,eAAe,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AA0CD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,eAAe,EAAE,EACvB,OAAO,EAAE,OAAO,GACf,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAkBhC;AAED,wBAAsB,MAAM,CAAC,EAC3B,WAAW,EACX,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,EAAE,cAAc,GACvB,EAAE,IAAI,iBAwLN"}
@@ -50,10 +50,15 @@ function createDocsMap(docs, verbose) {
50
50
  }
51
51
  async function upload({ accessToken, docs, batchSize, verbose, apiUrl: apiUrlOverride, }) {
52
52
  const apiUrl = (0, figma_rest_api_1.getApiUrl)(docs?.[0]?.figmaNode ?? '', apiUrlOverride) + '/code_connect';
53
+ // Strip internal fields before uploading to Figma
54
+ const cleanedDocs = docs.map((doc) => {
55
+ const { _codeConnectFilePath, ...cleanDoc } = doc;
56
+ return cleanDoc;
57
+ });
53
58
  try {
54
59
  logging_1.logger.info(`Uploading to Figma...`);
55
60
  // Create a map from fileKey-nodeId to original docs for detailed output
56
- const docsMap = createDocsMap(docs, verbose);
61
+ const docsMap = createDocsMap(cleanedDocs, verbose);
57
62
  let allUploadedNodes = new Set();
58
63
  let allFailedNodes = new Map(); // key -> failure reason
59
64
  if (batchSize) {
@@ -63,7 +68,7 @@ async function upload({ accessToken, docs, batchSize, verbose, apiUrl: apiUrlOve
63
68
  }
64
69
  // batch together based on fileKey + nodeId as all variants etc of the same node should be uploaded together
65
70
  // Otherwise, the server will overwrite the previous upload
66
- const groupedDocs = docs.reduce((acc, doc) => {
71
+ const groupedDocs = cleanedDocs.reduce((acc, doc) => {
67
72
  const parsedData = (0, validation_1.parseFigmaNode)(verbose, doc);
68
73
  if (!parsedData) {
69
74
  (0, helpers_1.exitWithFeedbackMessage)(1);
@@ -114,7 +119,7 @@ async function upload({ accessToken, docs, batchSize, verbose, apiUrl: apiUrlOve
114
119
  process.stderr.write(`\n`);
115
120
  }
116
121
  else {
117
- var size = Buffer.byteLength(JSON.stringify(docs)) / (1024 * 1024);
122
+ var size = Buffer.byteLength(JSON.stringify(cleanedDocs)) / (1024 * 1024);
118
123
  // Server has a limit of 5mb
119
124
  if (size > 5) {
120
125
  logging_1.logger.error(`Failed to upload to Figma: The request is too large (${size.toFixed(2)}mb).`);
@@ -123,7 +128,7 @@ async function upload({ accessToken, docs, batchSize, verbose, apiUrl: apiUrlOve
123
128
  }
124
129
  logging_1.logger.debug(`Uploading ${size.toFixed(2)}mb to Figma`);
125
130
  logging_1.logger.info(`uploading to ${apiUrl}`);
126
- const response = await fetch_1.request.post(apiUrl, docs, {
131
+ const response = await fetch_1.request.post(apiUrl, cleanedDocs, {
127
132
  headers: (0, figma_rest_api_1.getHeaders)(accessToken),
128
133
  });
129
134
  const data = response.data;