@figma/code-connect 1.4.9 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/commands/connect.d.ts +5 -0
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +55 -10
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/connect_template.d.ts.map +1 -1
- package/dist/commands/connect_template.js +2 -2
- package/dist/commands/connect_template.js.map +1 -1
- package/dist/commands/preview_utils.d.ts +103 -5
- package/dist/commands/preview_utils.d.ts.map +1 -1
- package/dist/commands/preview_utils.js +453 -76
- package/dist/commands/preview_utils.js.map +1 -1
- package/dist/commands/property_list_table.d.ts +11 -0
- package/dist/commands/property_list_table.d.ts.map +1 -0
- package/dist/commands/property_list_table.js +67 -0
- package/dist/commands/property_list_table.js.map +1 -0
- package/dist/common/updates.d.ts +4 -1
- package/dist/common/updates.d.ts.map +1 -1
- package/dist/common/updates.js +26 -5
- package/dist/common/updates.js.map +1 -1
- package/dist/connect/api.d.ts.map +1 -1
- package/dist/connect/api.js.map +1 -1
- package/dist/connect/batch_templates.d.ts +1 -1
- package/dist/connect/batch_templates.d.ts.map +1 -1
- package/dist/connect/batch_templates.js +2 -2
- package/dist/connect/batch_templates.js.map +1 -1
- package/dist/connect/migration_batch_helpers.d.ts.map +1 -1
- package/dist/connect/migration_batch_helpers.js +1 -15
- package/dist/connect/migration_batch_helpers.js.map +1 -1
- package/dist/connect/migration_helpers.d.ts +6 -0
- package/dist/connect/migration_helpers.d.ts.map +1 -1
- package/dist/connect/migration_helpers.js +66 -0
- package/dist/connect/migration_helpers.js.map +1 -1
- package/dist/connect/property_combinations.d.ts +69 -0
- package/dist/connect/property_combinations.d.ts.map +1 -0
- package/dist/connect/property_combinations.js +172 -0
- package/dist/connect/property_combinations.js.map +1 -0
- package/dist/connect/raw_template_bundler.d.ts +13 -0
- package/dist/connect/raw_template_bundler.d.ts.map +1 -0
- package/dist/connect/raw_template_bundler.js +178 -0
- package/dist/connect/raw_template_bundler.js.map +1 -0
- package/dist/connect/raw_templates.d.ts +1 -1
- package/dist/connect/raw_templates.d.ts.map +1 -1
- package/dist/connect/raw_templates.js +85 -24
- package/dist/connect/raw_templates.js.map +1 -1
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js.map +1 -1
- package/figma-types-no-require.d.ts +8 -6
- package/figma-types.d.ts +8 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Code Connect
|
|
2
2
|
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> Previously, Code Connect required framework-specific parsers for React, iOS, Android and Web Components. Late in 2025, we introduced a new [template API](https://developers.figma.com/docs/code-connect/template-api/) that removed framework requirements and allows users to more flexibly control how code snippets are rendered inside of Figma. Going forward, new users should opt for this template format and we recommend existing users to follow our [migration guide](https://developers.figma.com/docs/code-connect/templates-migration-guide/) to move to the new format. Following August 17th, 2026, we will no longer be updating or actively maintaining the legacy parsers.
|
|
5
|
+
|
|
3
6
|
Code Connect is a tool for connecting your design system components in code with your design system in Figma. When using Code Connect, Figma's Dev Mode will display true-to-production code snippets from your design system instead of autogenerated code examples. In addition to connecting component definitions, Code Connect also supports mapping properties from code to Figma enabling dynamic and correct examples. This can be useful for when you have an existing design system and are looking to drive consistent and correct adoption of that design system across design and engineering.
|
|
4
7
|
|
|
5
8
|
Code Connect is easy to set up, easy to maintain, type-safe, and extensible. The easiest way to get started is using **template files** — a framework-agnostic way to represent any code snippet, giving you full control over how components appear in Dev Mode. Code Connect also includes framework-specific integrations for React (and React Native), Storybook, HTML (e.g. Web Components, Angular and Vue), SwiftUI and Jetpack Compose.
|
|
@@ -16,6 +16,11 @@ export type BaseCommand = commander.Command & {
|
|
|
16
16
|
apiUrl?: string;
|
|
17
17
|
includeProps?: boolean;
|
|
18
18
|
batch?: BatchMigrationMode;
|
|
19
|
+
delete?: boolean;
|
|
20
|
+
all?: boolean;
|
|
21
|
+
maxCombinations?: string;
|
|
22
|
+
props?: string[];
|
|
23
|
+
inspect?: boolean;
|
|
19
24
|
};
|
|
20
25
|
type BatchMigrationMode = 'auto' | 'all' | 'none';
|
|
21
26
|
export declare function addConnectCommandToProgram(program: commander.Command): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAMtC,OAAO,EAKL,WAAW,EAKZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAqC1D,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,OAAO,CAAA;IACxB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AAMtC,OAAO,EAKL,WAAW,EAKZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAqC1D,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,GAAG;IAC5C,KAAK,EAAE,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
|
|
90
90
|
}
|
|
91
91
|
function addConnectCommandToProgram(program) {
|
|
92
92
|
// Main command, invoked with `figma connect`
|
|
93
|
-
const connectCommand = addBaseCommand(program, 'connect', 'Figma Code Connect').action((0, updates_1.
|
|
93
|
+
const connectCommand = addBaseCommand(program, 'connect', 'Figma Code Connect').action((0, updates_1.withVersionWarnings)(run_wizard_1.runWizard, { hideDeprecationWarning: true }));
|
|
94
94
|
// Make shared base flags work on either side of the subcommand name —
|
|
95
95
|
// `figma connect -v publish` and `figma connect publish -v` both honour -v.
|
|
96
96
|
connectCommand.hook('preAction', (_thisCommand, actionCommand) => {
|
|
@@ -105,32 +105,37 @@ function addConnectCommandToProgram(program) {
|
|
|
105
105
|
.option('-b --batch-size <batch_size>', 'optional batch size (in number of documents) to use when uploading. Use this if you hit "request too large" errors. See README for more information.')
|
|
106
106
|
.option('--include-template-files', '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.')
|
|
107
107
|
.option('--force', 'overwrite existing UI-created Code Connect mappings if they conflict with the files being published')
|
|
108
|
-
.action((0, updates_1.
|
|
108
|
+
.action((0, updates_1.withVersionWarnings)(handlePublish));
|
|
109
109
|
addBaseCommand(connectCommand, 'unpublish', 'Run to find any files that have figma connections and unpublish them from Figma. ' +
|
|
110
110
|
'By default this looks for a config file named "figma.config.json", and uses the `include` and `exclude` fields to determine which files to parse. ' +
|
|
111
111
|
'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse. ' +
|
|
112
112
|
'Alternatively, use `--node` and `--label` to unpublish a specific component.')
|
|
113
113
|
.option('--node <link_to_node>', 'specify the node to unpublish. This will unpublish for the specified label.')
|
|
114
114
|
.option('-l --label <label>', 'label to unpublish for')
|
|
115
|
-
.action((0, updates_1.
|
|
115
|
+
.action((0, updates_1.withVersionWarnings)(handleUnpublish));
|
|
116
116
|
addBaseCommand(connectCommand, 'parse', 'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.')
|
|
117
117
|
.option('-l --label <label>', 'label to apply to the parsed files')
|
|
118
118
|
.option('--include-template-files', '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.')
|
|
119
|
-
.action((0, updates_1.
|
|
119
|
+
.action((0, updates_1.withVersionWarnings)(handleParse));
|
|
120
120
|
addBaseCommand(connectCommand, 'create', 'Generate a Code Connect file with boilerplate in the current directory for a Figma node URL')
|
|
121
121
|
.argument('<figma-node-url>', 'Figma node URL to create the Code Connect file from')
|
|
122
|
-
.action((0, updates_1.
|
|
122
|
+
.action((0, updates_1.withVersionWarnings)(handleCreate));
|
|
123
123
|
addBaseCommand(connectCommand, 'migrate', 'Parse Code Connect files and migrate their templates into .figma.ts or .figma.js files that can be published directly without parsing.')
|
|
124
124
|
.option('--include-props', 'preserve __props metadata blocks in migrated templates (removed by default). Use if your templates use the React .getProps() or .render() modifiers, or read executeTemplate().metadata.__props from the migrated components')
|
|
125
125
|
.option('--javascript', 'output migrated templates as JavaScript (.figma.js) instead of TypeScript (.figma.ts)')
|
|
126
|
+
.option('--delete', 'delete source Code Connect files after they are successfully migrated')
|
|
126
127
|
.addOption(new commander.Option('--batch <mode>', 'batch migration mode: auto attempts files with 10 or more Code Connect docs; all attempts every source file; none disables batch migration')
|
|
127
128
|
.choices(['auto', 'all', 'none'])
|
|
128
129
|
.default('auto'))
|
|
129
|
-
.action((0, updates_1.
|
|
130
|
+
.action((0, updates_1.withVersionWarnings)(handleMigrate, { hideDeprecationWarning: true }));
|
|
130
131
|
addBaseCommand(connectCommand, 'preview', 'Preview how Code Connect snippets will render in the Figma inspect panel')
|
|
131
132
|
.argument('[files...]', 'Code Connect files to preview (e.g., Button.figma.tsx). Leave empty to preview all files.')
|
|
132
133
|
.option('--output <format>', 'Output format: table (default) or json', 'table')
|
|
133
|
-
.
|
|
134
|
+
.option('--all', "Render the snippet for every possible combination of the component's boolean and variant properties. Requires a single component file argument.")
|
|
135
|
+
.option('--max-combinations <number>', 'Maximum number of property combinations to render with --all. Defaults to 500 and cannot exceed 500.')
|
|
136
|
+
.option('--props <pairs...>', 'Render a single property combination with the given property values, e.g. --props Variant=Primary "Has Icon Start=true". Each pair is a separate space-separated argument (quote a pair only if its name or value contains spaces). Prefix a pair with a type (BOOLEAN/TEXT/VARIANT/INSTANCE_SWAP) to disambiguate properties that share a name but differ in type, e.g. "BOOLEAN:textMsg=false" "TEXT:textMsg=Hello". Unspecified properties use their defaults. Cannot be combined with --all.')
|
|
137
|
+
.option('--inspect', "List the component's properties/variants (name, type, options, default) without rendering. Respects --output.")
|
|
138
|
+
.action((0, updates_1.withVersionWarnings)(preview_utils_1.handlePreview));
|
|
134
139
|
}
|
|
135
140
|
function getAccessToken(cmd) {
|
|
136
141
|
return cmd.token ?? process.env.FIGMA_ACCESS_TOKEN;
|
|
@@ -275,13 +280,19 @@ async function getCodeConnectObjects(cmd, projectInfo, silent = false, isForMigr
|
|
|
275
280
|
}
|
|
276
281
|
}
|
|
277
282
|
}
|
|
283
|
+
// At this point `codeConnectObjects` holds only docs produced by a native
|
|
284
|
+
// parser (raw templates and batch files are appended below), so a non-empty
|
|
285
|
+
// list is proof the project still relies on the deprecated parsers.
|
|
286
|
+
if (codeConnectObjects.length > 0) {
|
|
287
|
+
(0, updates_1.flagParserBasedCodeConnect)();
|
|
288
|
+
}
|
|
278
289
|
if (rawTemplateFiles.length > 0) {
|
|
279
290
|
// Resolve the label before parsing so language inference works correctly
|
|
280
291
|
const resolvedLabel = cmd.label || projectInfo.config.label;
|
|
281
292
|
const rawTemplateDocs = [];
|
|
282
293
|
for (const file of rawTemplateFiles) {
|
|
283
294
|
try {
|
|
284
|
-
const doc = (0, raw_templates_1.parseRawFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
295
|
+
const doc = await (0, raw_templates_1.parseRawFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
285
296
|
// Store the Code Connect file path for migration purposes
|
|
286
297
|
doc._codeConnectFilePath = file;
|
|
287
298
|
if (!silent || cmd.verbose) {
|
|
@@ -322,7 +333,7 @@ async function getCodeConnectObjects(cmd, projectInfo, silent = false, isForMigr
|
|
|
322
333
|
const resolvedLabel = cmd.label || projectInfo.config.label;
|
|
323
334
|
for (const file of batchFiles) {
|
|
324
335
|
try {
|
|
325
|
-
const docs = (0, batch_templates_1.parseBatchFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
336
|
+
const docs = await (0, batch_templates_1.parseBatchFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
326
337
|
docs.forEach((doc) => {
|
|
327
338
|
doc._codeConnectFilePath = file;
|
|
328
339
|
});
|
|
@@ -611,6 +622,7 @@ async function handleMigrate(cmd) {
|
|
|
611
622
|
const gitRootPath = (0, project_2.getGitRepoAbsolutePath)(dir);
|
|
612
623
|
const useTypeScript = !cmd.javascript;
|
|
613
624
|
const batchMigratedDocs = new Set();
|
|
625
|
+
const migratedDocs = new Set();
|
|
614
626
|
const batchDocsByPath = (0, migration_batch_helpers_1.getBatchMigrationGroups)(allCodeConnectObjects, {
|
|
615
627
|
batchAll: cmd.batch === 'all',
|
|
616
628
|
disabled: cmd.batch === 'none',
|
|
@@ -633,7 +645,10 @@ async function handleMigrate(cmd) {
|
|
|
633
645
|
logging_1.logger.info(`${(0, logging_1.success)('✓')} Migrated ${result.componentCount} component(s) to batch ${(0, logging_1.highlight)(result.batchPath || batchPath)}`);
|
|
634
646
|
migratedCount += result.componentCount;
|
|
635
647
|
batchMigratedCount += result.componentCount;
|
|
636
|
-
docs.forEach((doc) =>
|
|
648
|
+
docs.forEach((doc) => {
|
|
649
|
+
batchMigratedDocs.add(doc);
|
|
650
|
+
migratedDocs.add(doc);
|
|
651
|
+
});
|
|
637
652
|
}
|
|
638
653
|
}
|
|
639
654
|
const regularCodeConnectObjects = allCodeConnectObjects.filter((doc) => !batchMigratedDocs.has(doc));
|
|
@@ -684,6 +699,9 @@ async function handleMigrate(cmd) {
|
|
|
684
699
|
else {
|
|
685
700
|
logging_1.logger.info(`${(0, logging_1.success)('✓')} Migrated${hasVariants ? ' (with variants)' : ''} to ${(0, logging_1.highlight)(outputPath)}`);
|
|
686
701
|
migratedCount++;
|
|
702
|
+
if (group.main)
|
|
703
|
+
migratedDocs.add(group.main);
|
|
704
|
+
group.variants.forEach((doc) => migratedDocs.add(doc));
|
|
687
705
|
}
|
|
688
706
|
}
|
|
689
707
|
catch (error) {
|
|
@@ -727,6 +745,33 @@ async function handleMigrate(cmd) {
|
|
|
727
745
|
console.log('');
|
|
728
746
|
logging_1.logger.warn("If you'd like to create batch files for these, we recommend using a coding agent. See example prompt: https://developers.figma.com/docs/code-connect/template-files/#migration-script");
|
|
729
747
|
}
|
|
748
|
+
if (cmd.delete) {
|
|
749
|
+
const projectFilePaths = new Set(projectInfo.files.map((file) => path_1.default.resolve(file)));
|
|
750
|
+
const docsBySourcePath = new Map();
|
|
751
|
+
for (const doc of allCodeConnectObjects) {
|
|
752
|
+
if (!doc._codeConnectFilePath)
|
|
753
|
+
continue;
|
|
754
|
+
const sourcePath = path_1.default.resolve(doc._codeConnectFilePath);
|
|
755
|
+
if (!projectFilePaths.has(sourcePath))
|
|
756
|
+
continue;
|
|
757
|
+
const sourceDocs = docsBySourcePath.get(sourcePath) ?? [];
|
|
758
|
+
sourceDocs.push(doc);
|
|
759
|
+
docsBySourcePath.set(sourcePath, sourceDocs);
|
|
760
|
+
}
|
|
761
|
+
for (const [sourcePath, sourceDocs] of docsBySourcePath) {
|
|
762
|
+
if (!sourceDocs.every((doc) => migratedDocs.has(doc)))
|
|
763
|
+
continue;
|
|
764
|
+
try {
|
|
765
|
+
fs_1.default.unlinkSync(sourcePath);
|
|
766
|
+
logging_1.logger.info(`${(0, logging_1.success)('✓')} Deleted ${(0, logging_1.highlight)(sourcePath)}`);
|
|
767
|
+
}
|
|
768
|
+
catch (error) {
|
|
769
|
+
const errorMsg = `Failed to delete ${sourcePath}: ${error}`;
|
|
770
|
+
logging_1.logger.error(errorMsg);
|
|
771
|
+
errors.push(errorMsg);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
730
775
|
// Summary
|
|
731
776
|
console.log('');
|
|
732
777
|
logging_1.logger.info(`Migration complete: ${(0, logging_1.success)(`${migratedCount} migrated`)}, ${skippedCount} skipped`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,gEAyGC;AAED,wCAEC;AAED,oDAUC;AAED,wBAEC;AAED,oCAIC;AAkCD,sDA4MC;AAvdD,qDAAsC;AACtC,4CAAmB;AACnB,mDAA+C;AAC/C,8CAA0C;AAC1C,sDAAoD;AACpD,8CAA4D;AAC5D,gDAU2B;AAC3B,+CAA8F;AAE9F,kDAA4D;AAC5D,wDAAoD;AACpD,6DAAwD;AACxD,sEAA0E;AAC1E,+DAAgD;AAChD,gFAA8F;AAE9F,gDAAuB;AACvB,+CAAmD;AACnD,gDAA2F;AAC3F,+DAA+D;AAC/D,2CAA6C;AAC7C,4DAOiC;AACjC,4CAAsE;AACtE,8EAA6E;AAC7E,oEAIqC;AACrC,gFAG2C;AAC3C,4DAA2F;AAC3F,gEAA2D;AAC3D,6DAAiF;AACjF,gDAA2D;AAqB3D,SAAS,cAAc,CAAC,OAA0B,EAAE,IAAY,EAAE,WAAmB;IACnF,OAAO,OAAO;SACX,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CAAC,WAAW,CAAC;SACxB,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;SAC9C,MAAM,CACL,qBAAqB,EACrB,sEAAsE,CACvE;SACA,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;SAClD,MAAM,CAAC,cAAc,EAAE,sCAAsC,CAAC;SAC9D,MAAM,CAAC,qBAAqB,EAAE,iDAAiD,CAAC;SAChF,MAAM,CAAC,mBAAmB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a,WAAW,CAAC,KAAK,YAAY,UAAU,CACvF,CAAA;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACf,gBAAM,CAAC,KAAK,CAAC,eAAe,MAAM,CAAC,MAAM,YAAY,CAAC,CAAA;QACtD,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAM,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAA;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACxB,IAAA,uBAAa,EAAC,wBAAwB,CAAC,CAAA;IACzC,CAAC;AACH,CAAC;AAED,SAAS,iCAAiC,CAAC,MAAc;IACvD,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IAC/D,OAAO,cAAc,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAc,EAAE,SAAiB,EAAE,EAAE;QACxF,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import * as commander from 'commander'\nimport fs from 'fs'\nimport { handlePreview } from './preview_utils'\nimport { upload } from '../connect/upload'\nimport { validateDocs } from '../connect/validation'\nimport { createCodeConnectFromUrl } from '../connect/create'\nimport {\n CodeConnectConfig,\n CodeConnectExecutableParserConfig,\n CodeConnectParserlessConfig,\n CodeConnectReactConfig,\n ProjectInfo,\n getProjectInfo,\n getReactProjectInfo,\n getRemoteFileUrl,\n getTsProgram,\n} from '../connect/project'\nimport { LogLevel, error, exitWithError, highlight, logger, success } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { convertStorybookFiles } from '../storybook/convert'\nimport { delete_docs } from '../connect/delete_docs'\nimport { runWizard } from '../connect/wizard/run_wizard'\nimport { callParser, handleMessages } from '../connect/parser_executables'\nimport { fromError } from 'zod-validation-error'\nimport { ParseRequestPayload, ParseResponsePayload } from '../connect/parser_executable_types'\nimport z from 'zod'\nimport path from 'path'\nimport { withUpdateCheck } from '../common/updates'\nimport { applyDocumentUrlSubstitutions, exitWithFeedbackMessage } from '../connect/helpers'\nimport { filterProjectInfoByFile } from './filter_project_info'\nimport { parseHtmlDoc } from '../html/parser'\nimport {\n InternalError,\n isFigmaConnectFile,\n parseCodeConnect,\n ParseFn,\n ParserError,\n ResolveImportsFn,\n} from '../connect/parser_common'\nimport { findAndResolveImports, parseReactDoc } from '../react/parser'\nimport { getInferredLanguageForRaw } from '../connect/label_language_mapping'\nimport {\n groupCodeConnectObjectsByFigmaUrl,\n writeTemplateFile,\n writeVariantTemplateFile,\n} from '../connect/migration_helpers'\nimport {\n getBatchMigrationGroups,\n writeBatchTemplateFiles,\n} from '../connect/migration_batch_helpers'\nimport { CodePropertiesError, isRawTemplate, parseRawFile } from '../connect/raw_templates'\nimport { parseBatchFile } from '../connect/batch_templates'\nimport { convertRemoteFileUrlToRelativePath } from '../connect/wizard/run_wizard'\nimport { getGitRepoAbsolutePath } from '../connect/project'\n\nexport type BaseCommand = commander.Command & {\n token: string\n verbose: boolean\n outFile: string\n outDir: string\n config: string\n dryRun: boolean\n dir: string\n file: string[]\n jsonFile: string\n skipUpdateCheck: boolean\n exitOnUnreadableFiles: boolean\n apiUrl?: string\n includeProps?: boolean\n batch?: BatchMigrationMode\n}\n\ntype BatchMigrationMode = 'auto' | 'all' | 'none'\n\nfunction addBaseCommand(command: commander.Command, name: string, description: string) {\n return command\n .command(name)\n .description(description)\n .usage('[options]')\n .option('-r --dir <dir>', 'directory to parse')\n .option(\n '-f --file <file...>',\n 'paths to one or more Code Connect files to process (space-separated)',\n )\n .option('-t --token <token>', 'figma access token')\n .option('-v --verbose', 'enable verbose logging for debugging')\n .option('-o --outFile <file>', 'specify a file to output generated Code Connect')\n .option('-o --outDir <dir>', 'specify a directory to output generated Code Connect')\n .option('-c --config <path>', 'path to a figma config file')\n .option('-a --api-url <url>', 'custom Figma API URL to use instead of https://api.figma.com/v1')\n .option('--skip-update-check', 'skips checking for an updated version of the Figma CLI')\n .option(\n '--exit-on-unreadable-files',\n 'exit if any Code Connect files cannot be parsed. We recommend using this option for CI/CD.',\n )\n .option('--dry-run', 'tests publishing without actually publishing')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n}\n\nexport function addConnectCommandToProgram(program: commander.Command) {\n // Main command, invoked with `figma connect`\n const connectCommand = addBaseCommand(program, 'connect', 'Figma Code Connect').action(\n withUpdateCheck(runWizard),\n )\n\n // Make shared base flags work on either side of the subcommand name —\n // `figma connect -v publish` and `figma connect publish -v` both honour -v.\n connectCommand.hook('preAction', (_thisCommand, actionCommand) => {\n Object.assign(actionCommand.opts(), actionCommand.optsWithGlobals())\n })\n\n // Sub-commands, invoked with e.g. `figma connect publish`\n addBaseCommand(\n connectCommand,\n 'publish',\n 'Run Code Connect locally to find any files that have figma connections and publish them to Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse.',\n )\n .option('--skip-validation', 'skip validation of Code Connect docs')\n .option('-l --label <label>', 'label to apply to the published files')\n .option(\n '-b --batch-size <batch_size>',\n 'optional batch size (in number of documents) to use when uploading. Use this if you hit \"request too large\" errors. See README for more information.',\n )\n .option(\n '--include-template-files',\n '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.',\n )\n .option(\n '--force',\n 'overwrite existing UI-created Code Connect mappings if they conflict with the files being published',\n )\n .action(withUpdateCheck(handlePublish))\n\n addBaseCommand(\n connectCommand,\n 'unpublish',\n 'Run to find any files that have figma connections and unpublish them from Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse. ' +\n 'Alternatively, use `--node` and `--label` to unpublish a specific component.',\n )\n .option(\n '--node <link_to_node>',\n 'specify the node to unpublish. This will unpublish for the specified label.',\n )\n .option('-l --label <label>', 'label to unpublish for')\n .action(withUpdateCheck(handleUnpublish))\n\n addBaseCommand(\n connectCommand,\n 'parse',\n 'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.',\n )\n .option('-l --label <label>', 'label to apply to the parsed files')\n .option(\n '--include-template-files',\n '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.',\n )\n .action(withUpdateCheck(handleParse))\n\n addBaseCommand(\n connectCommand,\n 'create',\n 'Generate a Code Connect file with boilerplate in the current directory for a Figma node URL',\n )\n .argument('<figma-node-url>', 'Figma node URL to create the Code Connect file from')\n .action(withUpdateCheck(handleCreate))\n\n addBaseCommand(\n connectCommand,\n 'migrate',\n 'Parse Code Connect files and migrate their templates into .figma.ts or .figma.js files that can be published directly without parsing.',\n )\n .option(\n '--include-props',\n 'preserve __props metadata blocks in migrated templates (removed by default). Use if your templates use the React .getProps() or .render() modifiers, or read executeTemplate().metadata.__props from the migrated components',\n )\n .option(\n '--javascript',\n 'output migrated templates as JavaScript (.figma.js) instead of TypeScript (.figma.ts)',\n )\n .addOption(\n new commander.Option(\n '--batch <mode>',\n 'batch migration mode: auto attempts files with 10 or more Code Connect docs; all attempts every source file; none disables batch migration',\n )\n .choices(['auto', 'all', 'none'])\n .default('auto'),\n )\n .action(withUpdateCheck(handleMigrate))\n\n addBaseCommand(\n connectCommand,\n 'preview',\n 'Preview how Code Connect snippets will render in the Figma inspect panel',\n )\n .argument(\n '[files...]',\n 'Code Connect files to preview (e.g., Button.figma.tsx). Leave empty to preview all files.',\n )\n .option('--output <format>', 'Output format: table (default) or json', 'table')\n .action(withUpdateCheck(handlePreview))\n}\n\nexport function getAccessToken(cmd: BaseCommand) {\n return cmd.token ?? process.env.FIGMA_ACCESS_TOKEN\n}\n\nexport function getAccessTokenOrExit(cmd: BaseCommand) {\n const token = getAccessToken(cmd)\n\n if (!token) {\n exitWithError(\n `Couldn't find a Figma access token. Please provide one with \\`--token <access_token>\\` or set the FIGMA_ACCESS_TOKEN environment variable`,\n )\n }\n\n return token\n}\n\nexport function getDir(cmd: BaseCommand) {\n return cmd.dir ?? process.cwd()\n}\n\nexport function setupHandler(cmd: BaseCommand) {\n if (cmd.verbose) {\n logger.setLogLevel(LogLevel.Debug)\n }\n}\n\ntype ParserDoc = z.infer<typeof ParseResponsePayload>['docs'][0]\n\nfunction transformDocFromParser(\n doc: ParserDoc,\n remoteUrl: string,\n config: CodeConnectConfig,\n): ParserDoc {\n let source = doc.source\n if (source) {\n try {\n const url = new URL(source)\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error('Invalid URL scheme')\n }\n } catch (e) {\n source = getRemoteFileUrl(source, remoteUrl, config.defaultBranch)\n }\n }\n\n // TODO This logic is duplicated in parser.ts parseDoc due to some type issues\n let figmaNode = doc.figmaNode\n if (config.documentUrlSubstitutions) {\n figmaNode = applyDocumentUrlSubstitutions(figmaNode, config.documentUrlSubstitutions)\n }\n\n return {\n ...doc,\n source,\n figmaNode,\n }\n}\n\nexport async function getCodeConnectObjects(\n cmd: BaseCommand & { label?: string },\n projectInfo: ProjectInfo,\n silent = false,\n isForMigration = false,\n): Promise<CodeConnectJSON[]> {\n if (cmd.jsonFile) {\n try {\n const docsFromJson = JSON.parse(fs.readFileSync(cmd.jsonFile, 'utf8'))\n // Strip internal fields from JSON input\n return docsFromJson.map((doc: CodeConnectJSON) => {\n const { _codeConnectFilePath, ...cleanDoc } = doc\n return cleanDoc as CodeConnectJSON\n })\n } catch (e) {\n logger.error('Failed to parse JSON file:', e)\n }\n }\n\n let codeConnectObjects: CodeConnectJSON[] = []\n\n // Parserless template files (.figma.ts/.figma.js with a leading url/component/source\n // directive) are handled directly below by parseRawFile and never need a native parser.\n // Identify them up front so we can decide whether the native parser is needed at all.\n const rawTemplateFiles = projectInfo.files.filter((f: string) => {\n // Suffix may be used by HTML / custom parsers\n const isPotentialRawTemplate =\n f.endsWith('.figma.js') ||\n f.endsWith('.figma.template.js') ||\n f.endsWith('.figma.ts') ||\n f.endsWith('.figma.template.ts')\n if (!isPotentialRawTemplate) return false\n try {\n return isRawTemplate(fs.readFileSync(f, 'utf-8'))\n } catch {\n return false\n }\n })\n\n // A project is \"template-only\" when it has at least one matched file and every\n // matched file is a parserless template. Such projects never need the native\n // parser, so skip invoking it. This avoids spawning a native build (e.g.\n // `swift run figma-swift`) that does no useful work and can fail outright — for\n // example a Swift package on macOS 12 whose `Figma` dependency requires macOS 13.\n // The native parser only ever produces docs from native source files\n // (.swift/.kt/.tsx etc.), which are disjoint from raw templates, so skipping it\n // here drops no docs.\n //\n // An empty file set is deliberately NOT treated as template-only: we leave the\n // existing behavior intact (the configured parser still runs), so e.g. a Swift\n // config that matches no files surfaces the same parser output as before.\n const rawTemplateFileSet = new Set(rawTemplateFiles)\n const isTemplateOnlyProject =\n rawTemplateFiles.length > 0 && projectInfo.files.every((f) => rawTemplateFileSet.has(f))\n\n if (isTemplateOnlyProject) {\n // Verbose-only: this is a diagnostic detail and must not alter normal output.\n if (projectInfo.config.parser && cmd.verbose) {\n logger.info('All Code Connect files are templates; skipping the native parser.')\n }\n } else if (projectInfo.config.parser === 'react') {\n codeConnectObjects = await getReactCodeConnectObjects(\n projectInfo as ProjectInfo<CodeConnectReactConfig>,\n cmd,\n silent,\n isForMigration,\n )\n } else if (projectInfo.config.parser === 'html') {\n codeConnectObjects = await getCodeConnectObjectsFromParseFn({\n parseFn: parseHtmlDoc,\n fileExtension: 'ts',\n projectInfo,\n cmd,\n silent,\n isForMigration,\n })\n } else if (projectInfo.config.parser) {\n const payload: ParseRequestPayload = {\n mode: 'PARSE',\n paths: projectInfo.files,\n config: { ...projectInfo.config, skipTemplateHelpers: isForMigration },\n verbose: cmd.verbose,\n }\n\n try {\n const stdout = await callParser(\n // We use `as` because the React parser makes the types difficult\n // TODO remove once React is an executable parser\n projectInfo.config as CodeConnectExecutableParserConfig,\n payload,\n projectInfo.absPath,\n )\n\n const parsed = ParseResponsePayload.parse(stdout)\n\n const { hasErrors } = handleMessages(parsed.messages)\n\n if (hasErrors) {\n exitWithError('Errors encountered calling parser, exiting')\n }\n\n codeConnectObjects = parsed.docs.map((doc) => ({\n ...transformDocFromParser(doc, projectInfo.remoteUrl, projectInfo.config),\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }))\n } catch (e) {\n if (cmd.verbose) {\n console.trace(e)\n\n // Don't say to enable verbose if the user has already enabled it.\n exitWithError(`Error calling parser: ${e}.`)\n } else {\n exitWithError(\n `Error returned from parser: ${fromError(e)}. Try re-running the command with --verbose for more information.`,\n )\n }\n }\n }\n\n if (rawTemplateFiles.length > 0) {\n // Resolve the label before parsing so language inference works correctly\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n const rawTemplateDocs: CodeConnectJSON[] = []\n for (const file of rawTemplateFiles) {\n try {\n const doc = parseRawFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n // Store the Code Connect file path for migration purposes\n doc._codeConnectFilePath = file\n\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n rawTemplateDocs.push(doc)\n } catch (e) {\n // A url-less file containing `codeProperties` is not Code Connect (e.g.\n // Make's code component property definitions). Log and skip it instead\n // of failing — never exit, not even with --exit-on-unreadable-files.\n if (e instanceof CodePropertiesError) {\n if (!silent || cmd.verbose) {\n logger.info(e.message)\n }\n continue\n }\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e instanceof Error ? e.message : String(e))\n }\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n }\n }\n\n codeConnectObjects = codeConnectObjects.concat(rawTemplateDocs)\n }\n\n // Process batch files (.figma.batch.json)\n const batchFiles = projectInfo.files.filter((f: string) => f.endsWith('.figma.batch.json'))\n\n if (batchFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n for (const file of batchFiles) {\n try {\n const docs = parseBatchFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n docs.forEach((doc) => {\n doc._codeConnectFilePath = file\n })\n codeConnectObjects = codeConnectObjects.concat(docs)\n if (!silent || cmd.verbose) {\n logger.info(success(`${file} (${docs.length} components)`))\n }\n } catch (e) {\n logger.error(`${file}: ${e}`)\n if (cmd.exitOnUnreadableFiles) {\n process.exit(1)\n }\n }\n }\n }\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label \"${cmd.label || projectInfo.config.label}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.label = cmd.label || projectInfo.config.label || doc.label\n })\n }\n\n if (projectInfo.config.language) {\n logger.info(`Using language \"${projectInfo.config.language}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.language = projectInfo.config.language || doc.language\n })\n }\n\n return codeConnectObjects\n}\n\ntype GetCodeConnectObjectsArgs = {\n parseFn: ParseFn\n resolveImportsFn?: ResolveImportsFn\n fileExtension: string | string[]\n projectInfo: ProjectInfo<CodeConnectConfig>\n cmd: BaseCommand\n silent?: boolean\n isForMigration?: boolean\n}\n\n// React/Storybook and HTML parsers are handled as special cases for now, they\n// do not use the parser executable model but instead directly call a function\n// in the code base. We may want to transition them to that model in future.\nasync function getCodeConnectObjectsFromParseFn({\n /** The function used to parse a source file into a Code Connect object */\n parseFn,\n /** Optional function used to resolve imports in a source file */\n resolveImportsFn,\n /** The file extension to filter for when checking if files should be parsed */\n fileExtension,\n /** Project info */\n projectInfo,\n /** The commander command object */\n cmd,\n /** Silences console output */\n silent = false,\n /** Whether this parse is for the migrate command */\n isForMigration = false,\n}: GetCodeConnectObjectsArgs) {\n const codeConnectObjects: CodeConnectJSON[] = []\n\n const tsProgram = getTsProgram(projectInfo)\n const { files, remoteUrl, config, absPath } = projectInfo\n\n for (const file of files.filter((f: string) => isFigmaConnectFile(tsProgram, f, fileExtension))) {\n try {\n const docs = await parseCodeConnect({\n program: tsProgram,\n file,\n config,\n parseFn,\n resolveImportsFn,\n absPath,\n parseOptions: {\n repoUrl: remoteUrl,\n debug: cmd.verbose,\n silent,\n isForMigration,\n },\n })\n\n codeConnectObjects.push(...docs)\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n } catch (e) {\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (e instanceof ParserError) {\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e.toString())\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n } else {\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(new InternalError(String(e)).toString())\n }\n }\n }\n }\n }\n\n return codeConnectObjects\n}\n\nasync function getReactCodeConnectObjects(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n cmd: BaseCommand,\n silent = false,\n isForMigration = false,\n) {\n const codeConnectObjects = await getCodeConnectObjectsFromParseFn({\n parseFn: parseReactDoc,\n resolveImportsFn: findAndResolveImports,\n fileExtension: ['tsx', 'jsx'],\n projectInfo,\n cmd,\n silent,\n isForMigration,\n })\n\n const storybookCodeConnectObjects = await convertStorybookFiles({\n projectInfo: getReactProjectInfo(projectInfo),\n isForMigration,\n })\n\n const allCodeConnectObjects = codeConnectObjects.concat(storybookCodeConnectObjects)\n\n return allCodeConnectObjects\n}\n\nasync function handlePublish(\n cmd: BaseCommand & {\n skipValidation: boolean\n label: string\n batchSize: string\n includeTemplateFiles?: boolean\n force?: boolean\n },\n) {\n setupHandler(cmd)\n\n // Show deprecation warning if the flag is used\n if (cmd.includeTemplateFiles !== undefined) {\n logger.warn(\n '[Deprecated] The --include-template-files flag is no longer needed because template files are now included by default. ' +\n \"Please don't use this flag - it will be removed in a future version.\",\n )\n }\n\n let dir = getDir(cmd)\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (codeConnectObjects.length === 0) {\n logger.warn(\n `No Code Connect files found in ${dir} - Make sure you have configured \\`include\\` and \\`exclude\\` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.`,\n )\n process.exit(0)\n }\n\n if (cmd.dryRun) {\n logger.info(`Files that would be published:`)\n logger.info(codeConnectObjects.map((o) => `- ${o.component} (${o.figmaNode})`).join('\\n'))\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n if (cmd.skipValidation) {\n logger.info('Validation skipped')\n } else {\n logger.info('Validating Code Connect files...')\n var start = new Date().getTime()\n const valid = await validateDocs(\n cmd,\n accessToken,\n codeConnectObjects,\n cmd.apiUrl || projectInfo.config.apiUrl,\n )\n if (!valid) {\n exitWithFeedbackMessage(1)\n } else {\n var end = new Date().getTime()\n var time = end - start\n logger.info(`All Code Connect files are valid (${time}ms)`)\n }\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n let batchSize\n if (cmd.batchSize) {\n batchSize = parseInt(cmd.batchSize, 10)\n if (isNaN(batchSize)) {\n logger.error('Error: failed to parse batch-size. batch-size passed must be a number')\n exitWithFeedbackMessage(1)\n }\n }\n\n upload({\n accessToken,\n docs: codeConnectObjects,\n batchSize: batchSize,\n verbose: cmd.verbose,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n force: cmd.force,\n })\n}\n\nasync function handleUnpublish(cmd: BaseCommand & { node: string; label: string }) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n\n if (cmd.dryRun) {\n logger.info(`Files that would be unpublished:`)\n }\n\n let nodesToDeleteRelevantInfo\n\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n if (cmd.node) {\n if (!cmd.label) {\n exitWithError('Label is required when specifying a node')\n }\n nodesToDeleteRelevantInfo = [{ figmaNode: cmd.node, label: cmd.label }]\n } else {\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n nodesToDeleteRelevantInfo = codeConnectObjects.map((doc) => ({\n figmaNode: doc.figmaNode,\n label: cmd.label || projectInfo.config.label || doc.label,\n }))\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label ${cmd.label || projectInfo.config.label}`)\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n delete_docs({\n accessToken,\n docs: nodesToDeleteRelevantInfo,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n })\n}\n\nasync function handleParse(cmd: BaseCommand & { label: string; includeTemplateFiles?: boolean }) {\n setupHandler(cmd)\n\n // Show deprecation warning if the flag is used\n if (cmd.includeTemplateFiles !== undefined) {\n logger.warn(\n '[Deprecated] The --include-template-files flag is no longer needed because template files are now included by default. ' +\n \"Please don't use this flag - it will be removed in a future version.\",\n )\n }\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n if (cmd.outFile) {\n fs.writeFileSync(cmd.outFile, JSON.stringify(codeConnectObjects, null, 2))\n logger.info(`Wrote Code Connect JSON to ${highlight(cmd.outFile)}`)\n } else {\n // don't format the output, so it can be piped to other commands\n console.log(JSON.stringify(codeConnectObjects, undefined, 2))\n }\n}\n\nasync function handleCreate(nodeUrl: string, cmd: BaseCommand) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n\n if (cmd.dryRun) {\n process.exit(0)\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n return createCodeConnectFromUrl({\n accessToken,\n // We remove \\s to allow users to paste URLs inside quotes - the terminal\n // paste will add backslashes, which the quotes preserve, but expected user\n // behaviour would be to strip the quotes\n figmaNodeUrl: nodeUrl.replace(/\\\\/g, ''),\n outFile: cmd.outFile,\n outDir: cmd.outDir,\n projectInfo,\n cmd,\n })\n}\n/**\n * Migrate native parser Code Connect files to parserless. For each found doc:\n * - Replace helpers with figma.* versions\n * - Migrate v1 syntax to v2 (equivalent but more readable)\n * - Format as valid parserless file w/ url=\"\" comment\n * - Name collisions are skipped, unless file is from migration (in which case add \"_1\")\n */\nasync function handleMigrate(cmd: BaseCommand & { javascript?: boolean }) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n let projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n const documentUrlSubstitutions = projectInfo.config.documentUrlSubstitutions\n\n // Clear documentUrlSubstitutions so we preserve original URLs in migrated templates\n projectInfo = {\n ...projectInfo,\n config: {\n ...projectInfo.config,\n documentUrlSubstitutions: {},\n },\n }\n\n // Parse the files to get Code Connect objects\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, false, true)\n\n const allCodeConnectObjectsByFigmaUrl = groupCodeConnectObjectsByFigmaUrl(allCodeConnectObjects)\n const groupCount = Object.keys(allCodeConnectObjectsByFigmaUrl).length\n if (groupCount === 0) {\n exitWithError('No Code Connect objects found to migrate')\n }\n\n logger.info(`Found ${groupCount} component(s) to migrate`)\n let migratedCount = 0\n let batchMigratedCount = 0\n let skippedCount = 0\n const errors: string[] = []\n const batchMigrationWarnings: Array<{\n path: string\n connectionCount: number\n reason: string\n }> = []\n\n const filePathsCreated = new Set<string>()\n const gitRootPath = getGitRepoAbsolutePath(dir)\n const useTypeScript = !cmd.javascript\n const batchMigratedDocs = new Set<CodeConnectJSON>()\n const batchDocsByPath = getBatchMigrationGroups(allCodeConnectObjects, {\n batchAll: cmd.batch === 'all',\n disabled: cmd.batch === 'none',\n })\n\n for (const [batchPath, docs] of batchDocsByPath) {\n const result = writeBatchTemplateFiles(docs, cmd.outDir, dir, {\n localSourcePath: batchPath,\n filePathsCreated,\n includeProps: cmd.includeProps,\n useTypeScript,\n })\n\n if (result.skipped) {\n batchMigrationWarnings.push({\n path: batchPath,\n connectionCount: docs.length,\n reason: result.reason || 'unable to create batch files',\n })\n } else {\n logger.info(\n `${success('✓')} Migrated ${result.componentCount} component(s) to batch ${highlight(result.batchPath || batchPath)}`,\n )\n migratedCount += result.componentCount\n batchMigratedCount += result.componentCount\n docs.forEach((doc) => batchMigratedDocs.add(doc))\n }\n }\n\n const regularCodeConnectObjects = allCodeConnectObjects.filter(\n (doc) => !batchMigratedDocs.has(doc),\n )\n const codeConnectObjectsByFigmaUrl = groupCodeConnectObjectsByFigmaUrl(regularCodeConnectObjects)\n\n for (const [figmaUrl, group] of Object.entries(codeConnectObjectsByFigmaUrl)) {\n try {\n const hasVariants = group.variants.length > 0\n const representativeDoc = group.main ?? group.variants[0]\n if (!representativeDoc?.template) {\n logger.warn(`Skipping ${figmaUrl}: no template found`)\n skippedCount++\n continue\n }\n\n // Determine local source path for output location\n let localSourcePath: string | undefined\n\n if (representativeDoc._codeConnectFilePath) {\n // Use the Code Connect file path directly (preferred)\n localSourcePath = representativeDoc._codeConnectFilePath\n } else if (representativeDoc?.source && gitRootPath) {\n // Fallback: Convert remote file URL to local path\n const relativePath = convertRemoteFileUrlToRelativePath({\n remoteFileUrl: representativeDoc.source,\n gitRootPath,\n dir,\n })\n if (relativePath) {\n localSourcePath = path.resolve(dir, relativePath)\n }\n }\n\n const { outputPath, skipped } = hasVariants\n ? writeVariantTemplateFile(group, figmaUrl, cmd.outDir, dir, {\n localSourcePath,\n filePathsCreated,\n useTypeScript,\n includeProps: cmd.includeProps,\n })\n : writeTemplateFile(representativeDoc, cmd.outDir, dir, {\n localSourcePath,\n filePathsCreated,\n includeProps: cmd.includeProps,\n useTypeScript,\n })\n\n if (skipped) {\n logger.warn(`Skipping ${outputPath}: file already exists`)\n skippedCount++\n } else {\n logger.info(\n `${success('✓')} Migrated${hasVariants ? ' (with variants)' : ''} to ${highlight(outputPath)}`,\n )\n migratedCount++\n }\n } catch (error) {\n const errorMsg = `Failed to migrate ${figmaUrl}: ${error}`\n logger.error(errorMsg)\n errors.push(errorMsg)\n }\n }\n\n if (migratedCount > 0) {\n if (cmd.outDir) {\n const configFilePath = path.join(cmd.outDir, 'figma.config.json')\n if (fs.existsSync(configFilePath)) {\n logger.warn(`Config file already exists at ${highlight(configFilePath)}`)\n } else {\n const { language: docLanguage, label } = allCodeConnectObjects[0]\n\n const language = getInferredLanguageForRaw(label, docLanguage)\n const config: CodeConnectParserlessConfig = {\n parser: undefined,\n include: [\n useTypeScript ? '**/*.figma.ts' : '**/*.figma.js',\n ...(batchMigratedCount > 0 ? ['**/*.figma.batch.json'] : []),\n ],\n language,\n label,\n ...(documentUrlSubstitutions && Object.keys(documentUrlSubstitutions).length > 0\n ? { documentUrlSubstitutions }\n : {}),\n }\n fs.writeFileSync(configFilePath, JSON.stringify({ codeConnect: config }, null, 2))\n logger.info(`${success('✓')} Wrote Figma config to ${highlight(configFilePath)}`)\n }\n }\n }\n\n if (batchMigrationWarnings.length > 0) {\n console.log('')\n logger.warn('Unable to migrate the following files to batch files:')\n batchMigrationWarnings.forEach((warning) => {\n logger.warn(\n `- ${highlight(warning.path)} (${warning.connectionCount} connections): ${formatBatchMigrationWarningReason(warning.reason)}`,\n )\n })\n console.log('')\n logger.warn(\n \"If you'd like to create batch files for these, we recommend using a coding agent. See example prompt: https://developers.figma.com/docs/code-connect/template-files/#migration-script\",\n )\n }\n\n // Summary\n console.log('')\n logger.info(\n `Migration complete: ${success(`${migratedCount} migrated`)}, ${skippedCount} skipped`,\n )\n\n if (errors.length > 0) {\n console.log('')\n logger.error(`Encountered ${errors.length} error(s):`)\n errors.forEach((err) => logger.error(` ${err}`))\n process.exit(1)\n }\n\n if (migratedCount === 0) {\n exitWithError('No files were migrated')\n }\n}\n\nfunction formatBatchMigrationWarningReason(reason: string) {\n const strippedReason = reason.replace(/^Cannot batch:\\s*/i, '')\n return strippedReason.replace(/^(\\s*)(\\S)/, (_match, prefix: string, firstChar: string) => {\n return `${prefix}${firstChar.toUpperCase()}`\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,gEA0HC;AAED,wCAEC;AAED,oDAUC;AAED,wBAEC;AAED,oCAIC;AAkCD,sDA0NC;AA3fD,qDAAsC;AACtC,4CAAmB;AACnB,mDAA+C;AAC/C,8CAA0C;AAC1C,sDAAoD;AACpD,8CAA4D;AAC5D,gDAU2B;AAC3B,+CAA8F;AAE9F,kDAA4D;AAC5D,wDAAoD;AACpD,6DAAwD;AACxD,sEAA0E;AAC1E,+DAAgD;AAChD,gFAA8F;AAE9F,gDAAuB;AACvB,+CAAmF;AACnF,gDAA2F;AAC3F,+DAA+D;AAC/D,2CAA6C;AAC7C,4DAOiC;AACjC,4CAAsE;AACtE,8EAA6E;AAC7E,oEAIqC;AACrC,gFAG2C;AAC3C,4DAA2F;AAC3F,gEAA2D;AAC3D,6DAAiF;AACjF,gDAA2D;AA0B3D,SAAS,cAAc,CAAC,OAA0B,EAAE,IAAY,EAAE,WAAmB;IACnF,OAAO,OAAO;SACX,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CAAC,WAAW,CAAC;SACxB,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;SAC9C,MAAM,CACL,qBAAqB,EACrB,sEAAsE,CACvE;SACA,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;SAClD,MAAM,CAAC,cAAc,EAAE,sCAAsC,CAAC;SAC9D,MAAM,CAAC,qBAAqB,EAAE,iDAAiD,CAAC;SAChF,MAAM,CAAC,mBAAmB,EAAE,sDAAsD,CAAC;SACnF,MAAM,CAAC,oBAAoB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I,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACxB,IAAA,uBAAa,EAAC,wBAAwB,CAAC,CAAA;IACzC,CAAC;AACH,CAAC;AAED,SAAS,iCAAiC,CAAC,MAAc;IACvD,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;IAC/D,OAAO,cAAc,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAc,EAAE,SAAiB,EAAE,EAAE;QACxF,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import * as commander from 'commander'\nimport fs from 'fs'\nimport { handlePreview } from './preview_utils'\nimport { upload } from '../connect/upload'\nimport { validateDocs } from '../connect/validation'\nimport { createCodeConnectFromUrl } from '../connect/create'\nimport {\n CodeConnectConfig,\n CodeConnectExecutableParserConfig,\n CodeConnectParserlessConfig,\n CodeConnectReactConfig,\n ProjectInfo,\n getProjectInfo,\n getReactProjectInfo,\n getRemoteFileUrl,\n getTsProgram,\n} from '../connect/project'\nimport { LogLevel, error, exitWithError, highlight, logger, success } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { convertStorybookFiles } from '../storybook/convert'\nimport { delete_docs } from '../connect/delete_docs'\nimport { runWizard } from '../connect/wizard/run_wizard'\nimport { callParser, handleMessages } from '../connect/parser_executables'\nimport { fromError } from 'zod-validation-error'\nimport { ParseRequestPayload, ParseResponsePayload } from '../connect/parser_executable_types'\nimport z from 'zod'\nimport path from 'path'\nimport { flagParserBasedCodeConnect, withVersionWarnings } from '../common/updates'\nimport { applyDocumentUrlSubstitutions, exitWithFeedbackMessage } from '../connect/helpers'\nimport { filterProjectInfoByFile } from './filter_project_info'\nimport { parseHtmlDoc } from '../html/parser'\nimport {\n InternalError,\n isFigmaConnectFile,\n parseCodeConnect,\n ParseFn,\n ParserError,\n ResolveImportsFn,\n} from '../connect/parser_common'\nimport { findAndResolveImports, parseReactDoc } from '../react/parser'\nimport { getInferredLanguageForRaw } from '../connect/label_language_mapping'\nimport {\n groupCodeConnectObjectsByFigmaUrl,\n writeTemplateFile,\n writeVariantTemplateFile,\n} from '../connect/migration_helpers'\nimport {\n getBatchMigrationGroups,\n writeBatchTemplateFiles,\n} from '../connect/migration_batch_helpers'\nimport { CodePropertiesError, isRawTemplate, parseRawFile } from '../connect/raw_templates'\nimport { parseBatchFile } from '../connect/batch_templates'\nimport { convertRemoteFileUrlToRelativePath } from '../connect/wizard/run_wizard'\nimport { getGitRepoAbsolutePath } from '../connect/project'\n\nexport type BaseCommand = commander.Command & {\n token: string\n verbose: boolean\n outFile: string\n outDir: string\n config: string\n dryRun: boolean\n dir: string\n file: string[]\n jsonFile: string\n skipUpdateCheck: boolean\n exitOnUnreadableFiles: boolean\n apiUrl?: string\n includeProps?: boolean\n batch?: BatchMigrationMode\n delete?: boolean\n all?: boolean\n maxCombinations?: string\n props?: string[]\n inspect?: boolean\n}\n\ntype BatchMigrationMode = 'auto' | 'all' | 'none'\n\nfunction addBaseCommand(command: commander.Command, name: string, description: string) {\n return command\n .command(name)\n .description(description)\n .usage('[options]')\n .option('-r --dir <dir>', 'directory to parse')\n .option(\n '-f --file <file...>',\n 'paths to one or more Code Connect files to process (space-separated)',\n )\n .option('-t --token <token>', 'figma access token')\n .option('-v --verbose', 'enable verbose logging for debugging')\n .option('-o --outFile <file>', 'specify a file to output generated Code Connect')\n .option('-o --outDir <dir>', 'specify a directory to output generated Code Connect')\n .option('-c --config <path>', 'path to a figma config file')\n .option('-a --api-url <url>', 'custom Figma API URL to use instead of https://api.figma.com/v1')\n .option('--skip-update-check', 'skips checking for an updated version of the Figma CLI')\n .option(\n '--exit-on-unreadable-files',\n 'exit if any Code Connect files cannot be parsed. We recommend using this option for CI/CD.',\n )\n .option('--dry-run', 'tests publishing without actually publishing')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n}\n\nexport function addConnectCommandToProgram(program: commander.Command) {\n // Main command, invoked with `figma connect`\n const connectCommand = addBaseCommand(program, 'connect', 'Figma Code Connect').action(\n withVersionWarnings(runWizard, { hideDeprecationWarning: true }),\n )\n\n // Make shared base flags work on either side of the subcommand name —\n // `figma connect -v publish` and `figma connect publish -v` both honour -v.\n connectCommand.hook('preAction', (_thisCommand, actionCommand) => {\n Object.assign(actionCommand.opts(), actionCommand.optsWithGlobals())\n })\n\n // Sub-commands, invoked with e.g. `figma connect publish`\n addBaseCommand(\n connectCommand,\n 'publish',\n 'Run Code Connect locally to find any files that have figma connections and publish them to Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse.',\n )\n .option('--skip-validation', 'skip validation of Code Connect docs')\n .option('-l --label <label>', 'label to apply to the published files')\n .option(\n '-b --batch-size <batch_size>',\n 'optional batch size (in number of documents) to use when uploading. Use this if you hit \"request too large\" errors. See README for more information.',\n )\n .option(\n '--include-template-files',\n '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.',\n )\n .option(\n '--force',\n 'overwrite existing UI-created Code Connect mappings if they conflict with the files being published',\n )\n .action(withVersionWarnings(handlePublish))\n\n addBaseCommand(\n connectCommand,\n 'unpublish',\n 'Run to find any files that have figma connections and unpublish them from Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse. ' +\n 'Alternatively, use `--node` and `--label` to unpublish a specific component.',\n )\n .option(\n '--node <link_to_node>',\n 'specify the node to unpublish. This will unpublish for the specified label.',\n )\n .option('-l --label <label>', 'label to unpublish for')\n .action(withVersionWarnings(handleUnpublish))\n\n addBaseCommand(\n connectCommand,\n 'parse',\n 'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.',\n )\n .option('-l --label <label>', 'label to apply to the parsed files')\n .option(\n '--include-template-files',\n '(Deprecated) No longer needed - template files are included by default. Will be removed in a future version.',\n )\n .action(withVersionWarnings(handleParse))\n\n addBaseCommand(\n connectCommand,\n 'create',\n 'Generate a Code Connect file with boilerplate in the current directory for a Figma node URL',\n )\n .argument('<figma-node-url>', 'Figma node URL to create the Code Connect file from')\n .action(withVersionWarnings(handleCreate))\n\n addBaseCommand(\n connectCommand,\n 'migrate',\n 'Parse Code Connect files and migrate their templates into .figma.ts or .figma.js files that can be published directly without parsing.',\n )\n .option(\n '--include-props',\n 'preserve __props metadata blocks in migrated templates (removed by default). Use if your templates use the React .getProps() or .render() modifiers, or read executeTemplate().metadata.__props from the migrated components',\n )\n .option(\n '--javascript',\n 'output migrated templates as JavaScript (.figma.js) instead of TypeScript (.figma.ts)',\n )\n .option('--delete', 'delete source Code Connect files after they are successfully migrated')\n .addOption(\n new commander.Option(\n '--batch <mode>',\n 'batch migration mode: auto attempts files with 10 or more Code Connect docs; all attempts every source file; none disables batch migration',\n )\n .choices(['auto', 'all', 'none'])\n .default('auto'),\n )\n .action(withVersionWarnings(handleMigrate, { hideDeprecationWarning: true }))\n\n addBaseCommand(\n connectCommand,\n 'preview',\n 'Preview how Code Connect snippets will render in the Figma inspect panel',\n )\n .argument(\n '[files...]',\n 'Code Connect files to preview (e.g., Button.figma.tsx). Leave empty to preview all files.',\n )\n .option('--output <format>', 'Output format: table (default) or json', 'table')\n .option(\n '--all',\n \"Render the snippet for every possible combination of the component's boolean and variant properties. Requires a single component file argument.\",\n )\n .option(\n '--max-combinations <number>',\n 'Maximum number of property combinations to render with --all. Defaults to 500 and cannot exceed 500.',\n )\n .option(\n '--props <pairs...>',\n 'Render a single property combination with the given property values, e.g. --props Variant=Primary \"Has Icon Start=true\". Each pair is a separate space-separated argument (quote a pair only if its name or value contains spaces). Prefix a pair with a type (BOOLEAN/TEXT/VARIANT/INSTANCE_SWAP) to disambiguate properties that share a name but differ in type, e.g. \"BOOLEAN:textMsg=false\" \"TEXT:textMsg=Hello\". Unspecified properties use their defaults. Cannot be combined with --all.',\n )\n .option(\n '--inspect',\n \"List the component's properties/variants (name, type, options, default) without rendering. Respects --output.\",\n )\n .action(withVersionWarnings(handlePreview))\n}\n\nexport function getAccessToken(cmd: BaseCommand) {\n return cmd.token ?? process.env.FIGMA_ACCESS_TOKEN\n}\n\nexport function getAccessTokenOrExit(cmd: BaseCommand) {\n const token = getAccessToken(cmd)\n\n if (!token) {\n exitWithError(\n `Couldn't find a Figma access token. Please provide one with \\`--token <access_token>\\` or set the FIGMA_ACCESS_TOKEN environment variable`,\n )\n }\n\n return token\n}\n\nexport function getDir(cmd: BaseCommand) {\n return cmd.dir ?? process.cwd()\n}\n\nexport function setupHandler(cmd: BaseCommand) {\n if (cmd.verbose) {\n logger.setLogLevel(LogLevel.Debug)\n }\n}\n\ntype ParserDoc = z.infer<typeof ParseResponsePayload>['docs'][0]\n\nfunction transformDocFromParser(\n doc: ParserDoc,\n remoteUrl: string,\n config: CodeConnectConfig,\n): ParserDoc {\n let source = doc.source\n if (source) {\n try {\n const url = new URL(source)\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error('Invalid URL scheme')\n }\n } catch (e) {\n source = getRemoteFileUrl(source, remoteUrl, config.defaultBranch)\n }\n }\n\n // TODO This logic is duplicated in parser.ts parseDoc due to some type issues\n let figmaNode = doc.figmaNode\n if (config.documentUrlSubstitutions) {\n figmaNode = applyDocumentUrlSubstitutions(figmaNode, config.documentUrlSubstitutions)\n }\n\n return {\n ...doc,\n source,\n figmaNode,\n }\n}\n\nexport async function getCodeConnectObjects(\n cmd: BaseCommand & { label?: string },\n projectInfo: ProjectInfo,\n silent = false,\n isForMigration = false,\n): Promise<CodeConnectJSON[]> {\n if (cmd.jsonFile) {\n try {\n const docsFromJson = JSON.parse(fs.readFileSync(cmd.jsonFile, 'utf8'))\n // Strip internal fields from JSON input\n return docsFromJson.map((doc: CodeConnectJSON) => {\n const { _codeConnectFilePath, ...cleanDoc } = doc\n return cleanDoc as CodeConnectJSON\n })\n } catch (e) {\n logger.error('Failed to parse JSON file:', e)\n }\n }\n\n let codeConnectObjects: CodeConnectJSON[] = []\n\n // Parserless template files (.figma.ts/.figma.js with a leading url/component/source\n // directive) are handled directly below by parseRawFile and never need a native parser.\n // Identify them up front so we can decide whether the native parser is needed at all.\n const rawTemplateFiles = projectInfo.files.filter((f: string) => {\n // Suffix may be used by HTML / custom parsers\n const isPotentialRawTemplate =\n f.endsWith('.figma.js') ||\n f.endsWith('.figma.template.js') ||\n f.endsWith('.figma.ts') ||\n f.endsWith('.figma.template.ts')\n if (!isPotentialRawTemplate) return false\n try {\n return isRawTemplate(fs.readFileSync(f, 'utf-8'))\n } catch {\n return false\n }\n })\n\n // A project is \"template-only\" when it has at least one matched file and every\n // matched file is a parserless template. Such projects never need the native\n // parser, so skip invoking it. This avoids spawning a native build (e.g.\n // `swift run figma-swift`) that does no useful work and can fail outright — for\n // example a Swift package on macOS 12 whose `Figma` dependency requires macOS 13.\n // The native parser only ever produces docs from native source files\n // (.swift/.kt/.tsx etc.), which are disjoint from raw templates, so skipping it\n // here drops no docs.\n //\n // An empty file set is deliberately NOT treated as template-only: we leave the\n // existing behavior intact (the configured parser still runs), so e.g. a Swift\n // config that matches no files surfaces the same parser output as before.\n const rawTemplateFileSet = new Set(rawTemplateFiles)\n const isTemplateOnlyProject =\n rawTemplateFiles.length > 0 && projectInfo.files.every((f) => rawTemplateFileSet.has(f))\n\n if (isTemplateOnlyProject) {\n // Verbose-only: this is a diagnostic detail and must not alter normal output.\n if (projectInfo.config.parser && cmd.verbose) {\n logger.info('All Code Connect files are templates; skipping the native parser.')\n }\n } else if (projectInfo.config.parser === 'react') {\n codeConnectObjects = await getReactCodeConnectObjects(\n projectInfo as ProjectInfo<CodeConnectReactConfig>,\n cmd,\n silent,\n isForMigration,\n )\n } else if (projectInfo.config.parser === 'html') {\n codeConnectObjects = await getCodeConnectObjectsFromParseFn({\n parseFn: parseHtmlDoc,\n fileExtension: 'ts',\n projectInfo,\n cmd,\n silent,\n isForMigration,\n })\n } else if (projectInfo.config.parser) {\n const payload: ParseRequestPayload = {\n mode: 'PARSE',\n paths: projectInfo.files,\n config: { ...projectInfo.config, skipTemplateHelpers: isForMigration },\n verbose: cmd.verbose,\n }\n\n try {\n const stdout = await callParser(\n // We use `as` because the React parser makes the types difficult\n // TODO remove once React is an executable parser\n projectInfo.config as CodeConnectExecutableParserConfig,\n payload,\n projectInfo.absPath,\n )\n\n const parsed = ParseResponsePayload.parse(stdout)\n\n const { hasErrors } = handleMessages(parsed.messages)\n\n if (hasErrors) {\n exitWithError('Errors encountered calling parser, exiting')\n }\n\n codeConnectObjects = parsed.docs.map((doc) => ({\n ...transformDocFromParser(doc, projectInfo.remoteUrl, projectInfo.config),\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }))\n } catch (e) {\n if (cmd.verbose) {\n console.trace(e)\n\n // Don't say to enable verbose if the user has already enabled it.\n exitWithError(`Error calling parser: ${e}.`)\n } else {\n exitWithError(\n `Error returned from parser: ${fromError(\n e,\n )}. Try re-running the command with --verbose for more information.`,\n )\n }\n }\n }\n\n // At this point `codeConnectObjects` holds only docs produced by a native\n // parser (raw templates and batch files are appended below), so a non-empty\n // list is proof the project still relies on the deprecated parsers.\n if (codeConnectObjects.length > 0) {\n flagParserBasedCodeConnect()\n }\n\n if (rawTemplateFiles.length > 0) {\n // Resolve the label before parsing so language inference works correctly\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n const rawTemplateDocs: CodeConnectJSON[] = []\n for (const file of rawTemplateFiles) {\n try {\n const doc = await parseRawFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n // Store the Code Connect file path for migration purposes\n doc._codeConnectFilePath = file\n\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n rawTemplateDocs.push(doc)\n } catch (e) {\n // A url-less file containing `codeProperties` is not Code Connect (e.g.\n // Make's code component property definitions). Log and skip it instead\n // of failing — never exit, not even with --exit-on-unreadable-files.\n if (e instanceof CodePropertiesError) {\n if (!silent || cmd.verbose) {\n logger.info(e.message)\n }\n continue\n }\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e instanceof Error ? e.message : String(e))\n }\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n }\n }\n\n codeConnectObjects = codeConnectObjects.concat(rawTemplateDocs)\n }\n\n // Process batch files (.figma.batch.json)\n const batchFiles = projectInfo.files.filter((f: string) => f.endsWith('.figma.batch.json'))\n\n if (batchFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n for (const file of batchFiles) {\n try {\n const docs = await parseBatchFile(\n file,\n resolvedLabel,\n projectInfo.config,\n projectInfo.absPath,\n )\n docs.forEach((doc) => {\n doc._codeConnectFilePath = file\n })\n codeConnectObjects = codeConnectObjects.concat(docs)\n if (!silent || cmd.verbose) {\n logger.info(success(`${file} (${docs.length} components)`))\n }\n } catch (e) {\n logger.error(`${file}: ${e}`)\n if (cmd.exitOnUnreadableFiles) {\n process.exit(1)\n }\n }\n }\n }\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label \"${cmd.label || projectInfo.config.label}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.label = cmd.label || projectInfo.config.label || doc.label\n })\n }\n\n if (projectInfo.config.language) {\n logger.info(`Using language \"${projectInfo.config.language}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.language = projectInfo.config.language || doc.language\n })\n }\n\n return codeConnectObjects\n}\n\ntype GetCodeConnectObjectsArgs = {\n parseFn: ParseFn\n resolveImportsFn?: ResolveImportsFn\n fileExtension: string | string[]\n projectInfo: ProjectInfo<CodeConnectConfig>\n cmd: BaseCommand\n silent?: boolean\n isForMigration?: boolean\n}\n\n// React/Storybook and HTML parsers are handled as special cases for now, they\n// do not use the parser executable model but instead directly call a function\n// in the code base. We may want to transition them to that model in future.\nasync function getCodeConnectObjectsFromParseFn({\n /** The function used to parse a source file into a Code Connect object */\n parseFn,\n /** Optional function used to resolve imports in a source file */\n resolveImportsFn,\n /** The file extension to filter for when checking if files should be parsed */\n fileExtension,\n /** Project info */\n projectInfo,\n /** The commander command object */\n cmd,\n /** Silences console output */\n silent = false,\n /** Whether this parse is for the migrate command */\n isForMigration = false,\n}: GetCodeConnectObjectsArgs) {\n const codeConnectObjects: CodeConnectJSON[] = []\n\n const tsProgram = getTsProgram(projectInfo)\n const { files, remoteUrl, config, absPath } = projectInfo\n\n for (const file of files.filter((f: string) => isFigmaConnectFile(tsProgram, f, fileExtension))) {\n try {\n const docs = await parseCodeConnect({\n program: tsProgram,\n file,\n config,\n parseFn,\n resolveImportsFn,\n absPath,\n parseOptions: {\n repoUrl: remoteUrl,\n debug: cmd.verbose,\n silent,\n isForMigration,\n },\n })\n\n codeConnectObjects.push(...docs)\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n } catch (e) {\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (e instanceof ParserError) {\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e.toString())\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n } else {\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(new InternalError(String(e)).toString())\n }\n }\n }\n }\n }\n\n return codeConnectObjects\n}\n\nasync function getReactCodeConnectObjects(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n cmd: BaseCommand,\n silent = false,\n isForMigration = false,\n) {\n const codeConnectObjects = await getCodeConnectObjectsFromParseFn({\n parseFn: parseReactDoc,\n resolveImportsFn: findAndResolveImports,\n fileExtension: ['tsx', 'jsx'],\n projectInfo,\n cmd,\n silent,\n isForMigration,\n })\n\n const storybookCodeConnectObjects = await convertStorybookFiles({\n projectInfo: getReactProjectInfo(projectInfo),\n isForMigration,\n })\n\n const allCodeConnectObjects = codeConnectObjects.concat(storybookCodeConnectObjects)\n\n return allCodeConnectObjects\n}\n\nasync function handlePublish(\n cmd: BaseCommand & {\n skipValidation: boolean\n label: string\n batchSize: string\n includeTemplateFiles?: boolean\n force?: boolean\n },\n) {\n setupHandler(cmd)\n\n // Show deprecation warning if the flag is used\n if (cmd.includeTemplateFiles !== undefined) {\n logger.warn(\n '[Deprecated] The --include-template-files flag is no longer needed because template files are now included by default. ' +\n \"Please don't use this flag - it will be removed in a future version.\",\n )\n }\n\n let dir = getDir(cmd)\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (codeConnectObjects.length === 0) {\n logger.warn(\n `No Code Connect files found in ${dir} - Make sure you have configured \\`include\\` and \\`exclude\\` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.`,\n )\n process.exit(0)\n }\n\n if (cmd.dryRun) {\n logger.info(`Files that would be published:`)\n logger.info(codeConnectObjects.map((o) => `- ${o.component} (${o.figmaNode})`).join('\\n'))\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n if (cmd.skipValidation) {\n logger.info('Validation skipped')\n } else {\n logger.info('Validating Code Connect files...')\n var start = new Date().getTime()\n const valid = await validateDocs(\n cmd,\n accessToken,\n codeConnectObjects,\n cmd.apiUrl || projectInfo.config.apiUrl,\n )\n if (!valid) {\n exitWithFeedbackMessage(1)\n } else {\n var end = new Date().getTime()\n var time = end - start\n logger.info(`All Code Connect files are valid (${time}ms)`)\n }\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n let batchSize\n if (cmd.batchSize) {\n batchSize = parseInt(cmd.batchSize, 10)\n if (isNaN(batchSize)) {\n logger.error('Error: failed to parse batch-size. batch-size passed must be a number')\n exitWithFeedbackMessage(1)\n }\n }\n\n upload({\n accessToken,\n docs: codeConnectObjects,\n batchSize: batchSize,\n verbose: cmd.verbose,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n force: cmd.force,\n })\n}\n\nasync function handleUnpublish(cmd: BaseCommand & { node: string; label: string }) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n\n if (cmd.dryRun) {\n logger.info(`Files that would be unpublished:`)\n }\n\n let nodesToDeleteRelevantInfo\n\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n if (cmd.node) {\n if (!cmd.label) {\n exitWithError('Label is required when specifying a node')\n }\n nodesToDeleteRelevantInfo = [{ figmaNode: cmd.node, label: cmd.label }]\n } else {\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n nodesToDeleteRelevantInfo = codeConnectObjects.map((doc) => ({\n figmaNode: doc.figmaNode,\n label: cmd.label || projectInfo.config.label || doc.label,\n }))\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label ${cmd.label || projectInfo.config.label}`)\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n delete_docs({\n accessToken,\n docs: nodesToDeleteRelevantInfo,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n })\n}\n\nasync function handleParse(cmd: BaseCommand & { label: string; includeTemplateFiles?: boolean }) {\n setupHandler(cmd)\n\n // Show deprecation warning if the flag is used\n if (cmd.includeTemplateFiles !== undefined) {\n logger.warn(\n '[Deprecated] The --include-template-files flag is no longer needed because template files are now included by default. ' +\n \"Please don't use this flag - it will be removed in a future version.\",\n )\n }\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n if (cmd.outFile) {\n fs.writeFileSync(cmd.outFile, JSON.stringify(codeConnectObjects, null, 2))\n logger.info(`Wrote Code Connect JSON to ${highlight(cmd.outFile)}`)\n } else {\n // don't format the output, so it can be piped to other commands\n console.log(JSON.stringify(codeConnectObjects, undefined, 2))\n }\n}\n\nasync function handleCreate(nodeUrl: string, cmd: BaseCommand) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n\n if (cmd.dryRun) {\n process.exit(0)\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n return createCodeConnectFromUrl({\n accessToken,\n // We remove \\s to allow users to paste URLs inside quotes - the terminal\n // paste will add backslashes, which the quotes preserve, but expected user\n // behaviour would be to strip the quotes\n figmaNodeUrl: nodeUrl.replace(/\\\\/g, ''),\n outFile: cmd.outFile,\n outDir: cmd.outDir,\n projectInfo,\n cmd,\n })\n}\n/**\n * Migrate native parser Code Connect files to parserless. For each found doc:\n * - Replace helpers with figma.* versions\n * - Migrate v1 syntax to v2 (equivalent but more readable)\n * - Format as valid parserless file w/ url=\"\" comment\n * - Name collisions are skipped, unless file is from migration (in which case add \"_1\")\n */\nasync function handleMigrate(cmd: BaseCommand & { javascript?: boolean }) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n let projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config), cmd.file)\n const documentUrlSubstitutions = projectInfo.config.documentUrlSubstitutions\n\n // Clear documentUrlSubstitutions so we preserve original URLs in migrated templates\n projectInfo = {\n ...projectInfo,\n config: {\n ...projectInfo.config,\n documentUrlSubstitutions: {},\n },\n }\n\n // Parse the files to get Code Connect objects\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, false, true)\n\n const allCodeConnectObjectsByFigmaUrl = groupCodeConnectObjectsByFigmaUrl(allCodeConnectObjects)\n const groupCount = Object.keys(allCodeConnectObjectsByFigmaUrl).length\n if (groupCount === 0) {\n exitWithError('No Code Connect objects found to migrate')\n }\n\n logger.info(`Found ${groupCount} component(s) to migrate`)\n let migratedCount = 0\n let batchMigratedCount = 0\n let skippedCount = 0\n const errors: string[] = []\n const batchMigrationWarnings: Array<{\n path: string\n connectionCount: number\n reason: string\n }> = []\n\n const filePathsCreated = new Set<string>()\n const gitRootPath = getGitRepoAbsolutePath(dir)\n const useTypeScript = !cmd.javascript\n const batchMigratedDocs = new Set<CodeConnectJSON>()\n const migratedDocs = new Set<CodeConnectJSON>()\n const batchDocsByPath = getBatchMigrationGroups(allCodeConnectObjects, {\n batchAll: cmd.batch === 'all',\n disabled: cmd.batch === 'none',\n })\n\n for (const [batchPath, docs] of batchDocsByPath) {\n const result = writeBatchTemplateFiles(docs, cmd.outDir, dir, {\n localSourcePath: batchPath,\n filePathsCreated,\n includeProps: cmd.includeProps,\n useTypeScript,\n })\n\n if (result.skipped) {\n batchMigrationWarnings.push({\n path: batchPath,\n connectionCount: docs.length,\n reason: result.reason || 'unable to create batch files',\n })\n } else {\n logger.info(\n `${success('✓')} Migrated ${result.componentCount} component(s) to batch ${highlight(\n result.batchPath || batchPath,\n )}`,\n )\n migratedCount += result.componentCount\n batchMigratedCount += result.componentCount\n docs.forEach((doc) => {\n batchMigratedDocs.add(doc)\n migratedDocs.add(doc)\n })\n }\n }\n\n const regularCodeConnectObjects = allCodeConnectObjects.filter(\n (doc) => !batchMigratedDocs.has(doc),\n )\n const codeConnectObjectsByFigmaUrl = groupCodeConnectObjectsByFigmaUrl(regularCodeConnectObjects)\n\n for (const [figmaUrl, group] of Object.entries(codeConnectObjectsByFigmaUrl)) {\n try {\n const hasVariants = group.variants.length > 0\n const representativeDoc = group.main ?? group.variants[0]\n if (!representativeDoc?.template) {\n logger.warn(`Skipping ${figmaUrl}: no template found`)\n skippedCount++\n continue\n }\n\n // Determine local source path for output location\n let localSourcePath: string | undefined\n\n if (representativeDoc._codeConnectFilePath) {\n // Use the Code Connect file path directly (preferred)\n localSourcePath = representativeDoc._codeConnectFilePath\n } else if (representativeDoc?.source && gitRootPath) {\n // Fallback: Convert remote file URL to local path\n const relativePath = convertRemoteFileUrlToRelativePath({\n remoteFileUrl: representativeDoc.source,\n gitRootPath,\n dir,\n })\n if (relativePath) {\n localSourcePath = path.resolve(dir, relativePath)\n }\n }\n\n const { outputPath, skipped } = hasVariants\n ? writeVariantTemplateFile(group, figmaUrl, cmd.outDir, dir, {\n localSourcePath,\n filePathsCreated,\n useTypeScript,\n includeProps: cmd.includeProps,\n })\n : writeTemplateFile(representativeDoc, cmd.outDir, dir, {\n localSourcePath,\n filePathsCreated,\n includeProps: cmd.includeProps,\n useTypeScript,\n })\n\n if (skipped) {\n logger.warn(`Skipping ${outputPath}: file already exists`)\n skippedCount++\n } else {\n logger.info(\n `${success('✓')} Migrated${hasVariants ? ' (with variants)' : ''} to ${highlight(\n outputPath,\n )}`,\n )\n migratedCount++\n if (group.main) migratedDocs.add(group.main)\n group.variants.forEach((doc) => migratedDocs.add(doc))\n }\n } catch (error) {\n const errorMsg = `Failed to migrate ${figmaUrl}: ${error}`\n logger.error(errorMsg)\n errors.push(errorMsg)\n }\n }\n\n if (migratedCount > 0) {\n if (cmd.outDir) {\n const configFilePath = path.join(cmd.outDir, 'figma.config.json')\n if (fs.existsSync(configFilePath)) {\n logger.warn(`Config file already exists at ${highlight(configFilePath)}`)\n } else {\n const { language: docLanguage, label } = allCodeConnectObjects[0]\n\n const language = getInferredLanguageForRaw(label, docLanguage)\n const config: CodeConnectParserlessConfig = {\n parser: undefined,\n include: [\n useTypeScript ? '**/*.figma.ts' : '**/*.figma.js',\n ...(batchMigratedCount > 0 ? ['**/*.figma.batch.json'] : []),\n ],\n language,\n label,\n ...(documentUrlSubstitutions && Object.keys(documentUrlSubstitutions).length > 0\n ? { documentUrlSubstitutions }\n : {}),\n }\n fs.writeFileSync(configFilePath, JSON.stringify({ codeConnect: config }, null, 2))\n logger.info(`${success('✓')} Wrote Figma config to ${highlight(configFilePath)}`)\n }\n }\n }\n\n if (batchMigrationWarnings.length > 0) {\n console.log('')\n logger.warn('Unable to migrate the following files to batch files:')\n batchMigrationWarnings.forEach((warning) => {\n logger.warn(\n `- ${highlight(warning.path)} (${\n warning.connectionCount\n } connections): ${formatBatchMigrationWarningReason(warning.reason)}`,\n )\n })\n console.log('')\n logger.warn(\n \"If you'd like to create batch files for these, we recommend using a coding agent. See example prompt: https://developers.figma.com/docs/code-connect/template-files/#migration-script\",\n )\n }\n\n if (cmd.delete) {\n const projectFilePaths = new Set(projectInfo.files.map((file) => path.resolve(file)))\n const docsBySourcePath = new Map<string, CodeConnectJSON[]>()\n\n for (const doc of allCodeConnectObjects) {\n if (!doc._codeConnectFilePath) continue\n\n const sourcePath = path.resolve(doc._codeConnectFilePath)\n if (!projectFilePaths.has(sourcePath)) continue\n\n const sourceDocs = docsBySourcePath.get(sourcePath) ?? []\n sourceDocs.push(doc)\n docsBySourcePath.set(sourcePath, sourceDocs)\n }\n\n for (const [sourcePath, sourceDocs] of docsBySourcePath) {\n if (!sourceDocs.every((doc) => migratedDocs.has(doc))) continue\n\n try {\n fs.unlinkSync(sourcePath)\n logger.info(`${success('✓')} Deleted ${highlight(sourcePath)}`)\n } catch (error) {\n const errorMsg = `Failed to delete ${sourcePath}: ${error}`\n logger.error(errorMsg)\n errors.push(errorMsg)\n }\n }\n }\n\n // Summary\n console.log('')\n logger.info(\n `Migration complete: ${success(`${migratedCount} migrated`)}, ${skippedCount} skipped`,\n )\n\n if (errors.length > 0) {\n console.log('')\n logger.error(`Encountered ${errors.length} error(s):`)\n errors.forEach((err) => logger.error(` ${err}`))\n process.exit(1)\n }\n\n if (migratedCount === 0) {\n exitWithError('No files were migrated')\n }\n}\n\nfunction formatBatchMigrationWarningReason(reason: string) {\n const strippedReason = reason.replace(/^Cannot batch:\\s*/i, '')\n return strippedReason.replace(/^(\\s*)(\\S)/, (_match, prefix: string, firstChar: string) => {\n return `${prefix}${firstChar.toUpperCase()}`\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect_template.d.ts","sourceRoot":"","sources":["../../src/commands/connect_template.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AActC,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,OAAO,CAAA;IACxB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;
|
|
1
|
+
{"version":3,"file":"connect_template.d.ts","sourceRoot":"","sources":["../../src/commands/connect_template.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAA;AActC,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,OAAO,CAAA;IACxB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAqSD,UAAU,cAAc;IACtB,qGAAqG;IACrG,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,SAAS,CAAC,OAAO,EAC1B,cAAc,GAAE,cAAmB,QAuHpC"}
|
|
@@ -58,7 +58,7 @@ async function getCodeConnectObjects(cmd, projectInfo, silent = false) {
|
|
|
58
58
|
const rawTemplateDocs = [];
|
|
59
59
|
for (const file of rawTemplateFiles) {
|
|
60
60
|
try {
|
|
61
|
-
const doc = (0, raw_templates_1.parseRawFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
61
|
+
const doc = await (0, raw_templates_1.parseRawFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
62
62
|
doc._codeConnectFilePath = file;
|
|
63
63
|
if (!silent || cmd.verbose) {
|
|
64
64
|
logging_1.logger.info((0, logging_1.success)(file));
|
|
@@ -98,7 +98,7 @@ async function getCodeConnectObjects(cmd, projectInfo, silent = false) {
|
|
|
98
98
|
const resolvedLabel = cmd.label || projectInfo.config.label;
|
|
99
99
|
for (const file of batchFiles) {
|
|
100
100
|
try {
|
|
101
|
-
const docs = (0, batch_templates_1.parseBatchFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
101
|
+
const docs = await (0, batch_templates_1.parseBatchFile)(file, resolvedLabel, projectInfo.config, projectInfo.absPath);
|
|
102
102
|
docs.forEach((doc) => {
|
|
103
103
|
doc._codeConnectFilePath = file;
|
|
104
104
|
});
|