@plasmicapp/cli 0.1.162

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 (162) hide show
  1. package/.eslintrc.js +61 -0
  2. package/.idea/cli.iml +11 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/README +16 -0
  7. package/README.internal +46 -0
  8. package/README.md +17 -0
  9. package/build.sh +8 -0
  10. package/dist/__mocks__/api.d.ts +16 -0
  11. package/dist/__mocks__/api.js +297 -0
  12. package/dist/__tests__/code-utils-spec.d.ts +1 -0
  13. package/dist/__tests__/code-utils-spec.js +838 -0
  14. package/dist/__tests__/ftue-spec.d.ts +1 -0
  15. package/dist/__tests__/ftue-spec.js +39 -0
  16. package/dist/__tests__/project-api-token-spec.d.ts +1 -0
  17. package/dist/__tests__/project-api-token-spec.js +147 -0
  18. package/dist/__tests__/versioned-sync-spec.d.ts +1 -0
  19. package/dist/__tests__/versioned-sync-spec.js +145 -0
  20. package/dist/actions/auth.d.ts +8 -0
  21. package/dist/actions/auth.js +47 -0
  22. package/dist/actions/fix-imports.d.ts +4 -0
  23. package/dist/actions/fix-imports.js +25 -0
  24. package/dist/actions/init.d.ts +62 -0
  25. package/dist/actions/init.js +460 -0
  26. package/dist/actions/project-token.d.ts +6 -0
  27. package/dist/actions/project-token.js +42 -0
  28. package/dist/actions/sync-components.d.ts +10 -0
  29. package/dist/actions/sync-components.js +242 -0
  30. package/dist/actions/sync-global-variants.d.ts +3 -0
  31. package/dist/actions/sync-global-variants.js +89 -0
  32. package/dist/actions/sync-icons.d.ts +7 -0
  33. package/dist/actions/sync-icons.js +92 -0
  34. package/dist/actions/sync-images.d.ts +6 -0
  35. package/dist/actions/sync-images.js +137 -0
  36. package/dist/actions/sync-styles.d.ts +3 -0
  37. package/dist/actions/sync-styles.js +58 -0
  38. package/dist/actions/sync.d.ts +25 -0
  39. package/dist/actions/sync.js +417 -0
  40. package/dist/actions/upload-bundle.d.ts +15 -0
  41. package/dist/actions/upload-bundle.js +28 -0
  42. package/dist/actions/watch.d.ts +14 -0
  43. package/dist/actions/watch.js +90 -0
  44. package/dist/api.d.ts +182 -0
  45. package/dist/api.js +202 -0
  46. package/dist/deps.d.ts +2 -0
  47. package/dist/deps.js +20 -0
  48. package/dist/index.d.ts +7 -0
  49. package/dist/index.js +247 -0
  50. package/dist/lib.d.ts +10 -0
  51. package/dist/lib.js +23 -0
  52. package/dist/migrations/0.1.110-fileLocks.d.ts +2 -0
  53. package/dist/migrations/0.1.110-fileLocks.js +15 -0
  54. package/dist/migrations/0.1.143-ensureImportModuleType.d.ts +2 -0
  55. package/dist/migrations/0.1.143-ensureImportModuleType.js +12 -0
  56. package/dist/migrations/0.1.146-addReactRuntime.d.ts +2 -0
  57. package/dist/migrations/0.1.146-addReactRuntime.js +10 -0
  58. package/dist/migrations/0.1.27-migrateInit.d.ts +1 -0
  59. package/dist/migrations/0.1.27-migrateInit.js +8 -0
  60. package/dist/migrations/0.1.28-tsToTsx.d.ts +3 -0
  61. package/dist/migrations/0.1.28-tsToTsx.js +33 -0
  62. package/dist/migrations/0.1.31-ensureProjectIcons.d.ts +2 -0
  63. package/dist/migrations/0.1.31-ensureProjectIcons.js +12 -0
  64. package/dist/migrations/0.1.42-ensureVersion.d.ts +2 -0
  65. package/dist/migrations/0.1.42-ensureVersion.js +12 -0
  66. package/dist/migrations/0.1.57-ensureJsBundleThemes.d.ts +2 -0
  67. package/dist/migrations/0.1.57-ensureJsBundleThemes.js +12 -0
  68. package/dist/migrations/0.1.64-imageFiles.d.ts +2 -0
  69. package/dist/migrations/0.1.64-imageFiles.js +17 -0
  70. package/dist/migrations/0.1.95-componentType.d.ts +2 -0
  71. package/dist/migrations/0.1.95-componentType.js +16 -0
  72. package/dist/migrations/migrations.d.ts +10 -0
  73. package/dist/migrations/migrations.js +119 -0
  74. package/dist/plasmic.schema.json +463 -0
  75. package/dist/test-common/fixtures.d.ts +13 -0
  76. package/dist/test-common/fixtures.js +165 -0
  77. package/dist/tsconfig-transform.json +68 -0
  78. package/dist/utils/auth-utils.d.ts +31 -0
  79. package/dist/utils/auth-utils.js +236 -0
  80. package/dist/utils/checksum.d.ts +4 -0
  81. package/dist/utils/checksum.js +63 -0
  82. package/dist/utils/code-utils.d.ts +46 -0
  83. package/dist/utils/code-utils.js +457 -0
  84. package/dist/utils/config-utils.d.ts +271 -0
  85. package/dist/utils/config-utils.js +178 -0
  86. package/dist/utils/envdetect.d.ts +4 -0
  87. package/dist/utils/envdetect.js +42 -0
  88. package/dist/utils/error.d.ts +14 -0
  89. package/dist/utils/error.js +42 -0
  90. package/dist/utils/file-utils.d.ts +71 -0
  91. package/dist/utils/file-utils.js +433 -0
  92. package/dist/utils/get-context.d.ts +40 -0
  93. package/dist/utils/get-context.js +339 -0
  94. package/dist/utils/help.d.ts +2 -0
  95. package/dist/utils/help.js +56 -0
  96. package/dist/utils/lang-utils.d.ts +10 -0
  97. package/dist/utils/lang-utils.js +52 -0
  98. package/dist/utils/npm-utils.d.ts +28 -0
  99. package/dist/utils/npm-utils.js +215 -0
  100. package/dist/utils/prompts.d.ts +6 -0
  101. package/dist/utils/prompts.js +23 -0
  102. package/dist/utils/resolve-utils.d.ts +13 -0
  103. package/dist/utils/resolve-utils.js +198 -0
  104. package/dist/utils/semver.d.ts +34 -0
  105. package/dist/utils/semver.js +61 -0
  106. package/dist/utils/test-utils.d.ts +22 -0
  107. package/dist/utils/test-utils.js +106 -0
  108. package/dist/utils/user-utils.d.ts +7 -0
  109. package/dist/utils/user-utils.js +48 -0
  110. package/jest.config.js +6 -0
  111. package/package.json +80 -0
  112. package/src/__mocks__/api.ts +394 -0
  113. package/src/__tests__/code-utils-spec.ts +881 -0
  114. package/src/__tests__/ftue-spec.ts +43 -0
  115. package/src/__tests__/project-api-token-spec.ts +208 -0
  116. package/src/__tests__/versioned-sync-spec.ts +176 -0
  117. package/src/actions/auth.ts +43 -0
  118. package/src/actions/fix-imports.ts +13 -0
  119. package/src/actions/init.ts +638 -0
  120. package/src/actions/project-token.ts +36 -0
  121. package/src/actions/sync-components.ts +405 -0
  122. package/src/actions/sync-global-variants.ts +129 -0
  123. package/src/actions/sync-icons.ts +135 -0
  124. package/src/actions/sync-images.ts +191 -0
  125. package/src/actions/sync-styles.ts +71 -0
  126. package/src/actions/sync.ts +747 -0
  127. package/src/actions/upload-bundle.ts +38 -0
  128. package/src/actions/watch.ts +95 -0
  129. package/src/api.ts +407 -0
  130. package/src/deps.ts +18 -0
  131. package/src/index.ts +300 -0
  132. package/src/lib.ts +10 -0
  133. package/src/migrations/0.1.110-fileLocks.ts +16 -0
  134. package/src/migrations/0.1.146-addReactRuntime.ts +8 -0
  135. package/src/migrations/0.1.27-migrateInit.ts +4 -0
  136. package/src/migrations/0.1.28-tsToTsx.ts +37 -0
  137. package/src/migrations/0.1.31-ensureProjectIcons.ts +10 -0
  138. package/src/migrations/0.1.42-ensureVersion.ts +10 -0
  139. package/src/migrations/0.1.57-ensureJsBundleThemes.ts +10 -0
  140. package/src/migrations/0.1.64-imageFiles.ts +15 -0
  141. package/src/migrations/0.1.95-componentType.ts +14 -0
  142. package/src/migrations/migrations.ts +147 -0
  143. package/src/test-common/fixtures.ts +178 -0
  144. package/src/utils/auth-utils.ts +276 -0
  145. package/src/utils/checksum.ts +106 -0
  146. package/src/utils/code-utils.ts +656 -0
  147. package/src/utils/config-utils.ts +551 -0
  148. package/src/utils/envdetect.ts +39 -0
  149. package/src/utils/error.ts +36 -0
  150. package/src/utils/file-utils.ts +526 -0
  151. package/src/utils/get-context.ts +451 -0
  152. package/src/utils/help.ts +75 -0
  153. package/src/utils/lang-utils.ts +52 -0
  154. package/src/utils/npm-utils.ts +223 -0
  155. package/src/utils/prompts.ts +22 -0
  156. package/src/utils/resolve-utils.ts +245 -0
  157. package/src/utils/semver.ts +67 -0
  158. package/src/utils/test-utils.ts +116 -0
  159. package/src/utils/user-utils.ts +37 -0
  160. package/testData/fixImports_plasmic.json +66 -0
  161. package/tsconfig-transform.json +68 -0
  162. package/tsconfig.json +67 -0
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.syncProjectComponents = void 0;
16
+ const code_merger_1 = require("@plasmicapp/code-merger");
17
+ const lodash_1 = __importDefault(require("lodash"));
18
+ const upath_1 = __importDefault(require("upath"));
19
+ const api_1 = require("../api");
20
+ const deps_1 = require("../deps");
21
+ const code_utils_1 = require("../utils/code-utils");
22
+ const config_utils_1 = require("../utils/config-utils");
23
+ const error_1 = require("../utils/error");
24
+ const file_utils_1 = require("../utils/file-utils");
25
+ const lang_utils_1 = require("../utils/lang-utils");
26
+ const user_utils_1 = require("../utils/user-utils");
27
+ const updateDirectSkeleton = (newFileContent, editedFileContent, context, compConfig, forceOverwrite, nameInIdToUuid, appendJsxOnMissingBase) => __awaiter(void 0, void 0, void 0, function* () {
28
+ // merge code!
29
+ const componentByUuid = new Map();
30
+ componentByUuid.set(compConfig.id, {
31
+ editedFile: editedFileContent,
32
+ newFile: newFileContent,
33
+ newNameInIdToUuid: new Map(nameInIdToUuid),
34
+ });
35
+ const mergedFiles = yield code_merger_1.mergeFiles(componentByUuid, compConfig.projectId, code_merger_1.makeCachedProjectSyncDataProvider((projectId, revision) => __awaiter(void 0, void 0, void 0, function* () {
36
+ try {
37
+ return yield context.api.projectSyncMetadata(projectId, revision, true);
38
+ }
39
+ catch (e) {
40
+ if (e instanceof api_1.AppServerError &&
41
+ /revision \d+ not found/.test(e.message)) {
42
+ throw e;
43
+ }
44
+ else {
45
+ throw new error_1.HandledError(e.messag);
46
+ }
47
+ }
48
+ })), () => { }, appendJsxOnMissingBase);
49
+ const merged = mergedFiles === null || mergedFiles === void 0 ? void 0 : mergedFiles.get(compConfig.id);
50
+ if (merged) {
51
+ yield file_utils_1.writeFileContent(context, compConfig.importSpec.modulePath, merged, {
52
+ force: true,
53
+ });
54
+ }
55
+ else {
56
+ if (!forceOverwrite) {
57
+ throw new error_1.HandledError(`Cannot merge ${compConfig.importSpec.modulePath}. If you just switched the code scheme for the component from blackbox to direct, use --force-overwrite option to force the switch.`);
58
+ }
59
+ else {
60
+ deps_1.logger.warn(`Overwrite ${compConfig.importSpec.modulePath} despite merge failure`);
61
+ yield file_utils_1.writeFileContent(context, compConfig.importSpec.modulePath, newFileContent, {
62
+ force: true,
63
+ });
64
+ }
65
+ }
66
+ });
67
+ function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, appendJsxOnMissingBase, summary, pendingMerge, projectLock, checksums, baseDir) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ const componentsFromChecksums = new Set([
70
+ ...checksums.cssRulesChecksums.map(([id, _]) => id),
71
+ checksums.renderModuleChecksums.map(([id, _]) => id),
72
+ ]);
73
+ const allCompConfigs = lodash_1.default.keyBy(project.components, (c) => c.id);
74
+ const componentBundleIds = lodash_1.default.keyBy(componentBundles, (i) => i.id);
75
+ const deletedComponents = lodash_1.default.filter(allCompConfigs, (i) => !componentBundleIds[i.id] && !componentsFromChecksums.has(i.id));
76
+ const renderModuleFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "renderModule"), (fl) => fl.assetId);
77
+ const cssRulesFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "cssRules"), (fl) => fl.assetId);
78
+ const id2RenderModuleChecksum = new Map(checksums.renderModuleChecksums);
79
+ const id2CssRulesChecksum = new Map(checksums.cssRulesChecksums);
80
+ const deletedComponentFiles = new Set();
81
+ for (const deletedComponent of deletedComponents) {
82
+ const componentConfig = allCompConfigs[deletedComponent.id];
83
+ if (file_utils_1.fileExists(context, componentConfig.renderModuleFilePath) &&
84
+ file_utils_1.fileExists(context, componentConfig.cssFilePath)) {
85
+ deps_1.logger.info(`Deleting component: ${componentConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${componentConfig.id} ${project.version}]`);
86
+ file_utils_1.deleteFile(context, componentConfig.renderModuleFilePath);
87
+ file_utils_1.deleteFile(context, componentConfig.cssFilePath);
88
+ deletedComponentFiles.add(deletedComponent.id);
89
+ const skeletonPath = componentConfig.importSpec.modulePath;
90
+ if (file_utils_1.fileExists(context, skeletonPath)) {
91
+ const deleteSkeleton = yield user_utils_1.confirmWithUser(`Do you want to delete ${skeletonPath}?`, context.cliArgs.yes);
92
+ if (deleteSkeleton) {
93
+ file_utils_1.deleteFile(context, skeletonPath);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ project.components = project.components.filter((c) => !deletedComponentFiles.has(c.id));
99
+ const deletedComponentIds = new Set(deletedComponents.map((i) => i.id));
100
+ projectLock.fileLocks = projectLock.fileLocks.filter((fileLock) => (fileLock.type !== "renderModule" && fileLock.type !== "cssRules") ||
101
+ !deletedComponentIds.has(fileLock.assetId));
102
+ for (const bundle of componentBundles) {
103
+ const { renderModule, skeletonModule, cssRules, renderModuleFileName, skeletonModuleFileName, cssFileName, componentName, id, scheme, nameInIdToUuid, isPage, plumeType, } = bundle;
104
+ if (context.cliArgs.quiet !== true) {
105
+ deps_1.logger.info(`Syncing component: ${componentName}@${version}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
106
+ }
107
+ let compConfig = allCompConfigs[id];
108
+ // A component should be regenerated if it is new or path-related information (like the name)
109
+ // changed.
110
+ const shouldRegenerate = (compConfig === null || compConfig === void 0 ? void 0 : compConfig.name) !== componentName;
111
+ let skeletonModuleModified = shouldRegenerate;
112
+ const skeletonPath = isPage
113
+ ? file_utils_1.defaultPagePath(context, skeletonModuleFileName)
114
+ : skeletonModuleFileName;
115
+ const defaultRenderModuleFilePath = file_utils_1.defaultResourcePath(context, project, renderModuleFileName);
116
+ const defaultCssFilePath = file_utils_1.defaultResourcePath(context, project, cssFileName);
117
+ if (shouldRegenerate) {
118
+ project.components = project.components.filter((existingComponent) => existingComponent.id !== id);
119
+ compConfig = {
120
+ id,
121
+ name: componentName,
122
+ type: "managed",
123
+ projectId: project.projectId,
124
+ renderModuleFilePath: defaultRenderModuleFilePath,
125
+ importSpec: { modulePath: skeletonPath },
126
+ cssFilePath: defaultCssFilePath,
127
+ scheme: scheme,
128
+ componentType: isPage ? "page" : "component",
129
+ plumeType,
130
+ };
131
+ allCompConfigs[id] = compConfig;
132
+ project.components.push(allCompConfigs[id]);
133
+ // Because it's the first time, we also generate the skeleton file.
134
+ yield file_utils_1.writeFileContent(context, skeletonPath, skeletonModule, {
135
+ force: false,
136
+ });
137
+ }
138
+ else if (compConfig.type === "mapped") {
139
+ }
140
+ else if (compConfig.type === "managed") {
141
+ // This is an existing component.
142
+ // We only bother touching files on disk if this component is managed.
143
+ compConfig.componentType = isPage ? "page" : "component";
144
+ // Read in the existing file
145
+ let editedFile;
146
+ try {
147
+ editedFile = file_utils_1.readFileContent(context, compConfig.importSpec.modulePath);
148
+ }
149
+ catch (e) {
150
+ deps_1.logger.warn(`${compConfig.importSpec.modulePath} is missing. If you deleted this component, remember to remove the component from ${config_utils_1.CONFIG_FILE_NAME}`);
151
+ throw e;
152
+ }
153
+ const renderModuleFilePath = upath_1.default.join(upath_1.default.dirname(compConfig.renderModuleFilePath), upath_1.default.basename(defaultRenderModuleFilePath));
154
+ if (compConfig.renderModuleFilePath !== renderModuleFilePath &&
155
+ file_utils_1.fileExists(context, compConfig.renderModuleFilePath)) {
156
+ if (context.cliArgs.quiet !== true) {
157
+ deps_1.logger.info(`Renaming component file: ${compConfig.renderModuleFilePath}@${version}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
158
+ }
159
+ file_utils_1.renameFile(context, compConfig.renderModuleFilePath, renderModuleFilePath);
160
+ compConfig.renderModuleFilePath = renderModuleFilePath;
161
+ }
162
+ const cssFilePath = upath_1.default.join(upath_1.default.dirname(compConfig.cssFilePath), upath_1.default.basename(defaultCssFilePath));
163
+ if (compConfig.cssFilePath !== cssFilePath &&
164
+ file_utils_1.fileExists(context, compConfig.cssFilePath)) {
165
+ if (context.cliArgs.quiet !== true) {
166
+ deps_1.logger.info(`Renaming component css file: ${compConfig.cssFilePath}@${version}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
167
+ }
168
+ file_utils_1.renameFile(context, compConfig.cssFilePath, cssFilePath);
169
+ compConfig.cssFilePath = cssFilePath;
170
+ }
171
+ if (isPage &&
172
+ config_utils_1.isPageAwarePlatform(context.config.platform) &&
173
+ skeletonPath !== compConfig.importSpec.modulePath &&
174
+ file_utils_1.fileExists(context, compConfig.importSpec.modulePath)) {
175
+ if (context.cliArgs.quiet !== true) {
176
+ deps_1.logger.info(`Renaming page file: ${compConfig.importSpec.modulePath} -> ${skeletonPath}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
177
+ }
178
+ file_utils_1.renameFile(context, compConfig.importSpec.modulePath, skeletonPath);
179
+ compConfig.importSpec.modulePath = skeletonPath;
180
+ }
181
+ compConfig.plumeType = plumeType;
182
+ if (scheme === "direct") {
183
+ // We cannot merge right now, but wait until all the imports are resolved
184
+ pendingMerge.push({
185
+ skeletonModulePath: compConfig.importSpec.modulePath,
186
+ editedSkeletonFile: editedFile,
187
+ newSkeletonFile: skeletonModule,
188
+ merge: (resolvedNewFile, resolvedEditedFile) => __awaiter(this, void 0, void 0, function* () {
189
+ return updateDirectSkeleton(resolvedNewFile, resolvedEditedFile, context, compConfig, forceOverwrite, nameInIdToUuid, appendJsxOnMissingBase);
190
+ }),
191
+ });
192
+ skeletonModuleModified = true;
193
+ }
194
+ else if (/\/\/\s*plasmic-managed-jsx\/\d+/.test(editedFile)) {
195
+ if (forceOverwrite) {
196
+ skeletonModuleModified = true;
197
+ yield file_utils_1.writeFileContent(context, compConfig.importSpec.modulePath, skeletonModule, {
198
+ force: true,
199
+ });
200
+ }
201
+ else {
202
+ deps_1.logger.warn(`file ${compConfig.importSpec.modulePath} is likely in "direct" scheme. If you intend to switch the code scheme from direct to blackbox, use --force-overwrite option to force the switch.`);
203
+ }
204
+ }
205
+ }
206
+ lang_utils_1.assert(lodash_1.default.isArray(projectLock.fileLocks));
207
+ // Update FileLocks
208
+ if (renderModuleFileLocks[id]) {
209
+ renderModuleFileLocks[id].checksum = lang_utils_1.ensure(id2RenderModuleChecksum.get(id));
210
+ }
211
+ else {
212
+ projectLock.fileLocks.push({
213
+ type: "renderModule",
214
+ assetId: id,
215
+ checksum: lang_utils_1.ensure(id2RenderModuleChecksum.get(id)),
216
+ });
217
+ }
218
+ if (cssRulesFileLocks[id]) {
219
+ cssRulesFileLocks[id].checksum = lang_utils_1.ensure(id2CssRulesChecksum.get(id));
220
+ }
221
+ else {
222
+ projectLock.fileLocks.push({
223
+ type: "cssRules",
224
+ assetId: id,
225
+ checksum: lang_utils_1.ensure(id2CssRulesChecksum.get(id)),
226
+ });
227
+ }
228
+ if (compConfig.type === "managed") {
229
+ // Again, only need to touch files on disk if managed
230
+ yield file_utils_1.writeFileContent(context, compConfig.renderModuleFilePath, renderModule, {
231
+ force: !shouldRegenerate,
232
+ });
233
+ const formattedCssRules = code_utils_1.formatAsLocal(cssRules, compConfig.cssFilePath, baseDir);
234
+ yield file_utils_1.writeFileContent(context, compConfig.cssFilePath, formattedCssRules, {
235
+ force: !shouldRegenerate,
236
+ });
237
+ }
238
+ summary.set(id, { skeletonModuleModified });
239
+ }
240
+ });
241
+ }
242
+ exports.syncProjectComponents = syncProjectComponents;
@@ -0,0 +1,3 @@
1
+ import { ChecksumBundle, GlobalVariantBundle, ProjectMetaBundle } from "../api";
2
+ import { PlasmicContext } from "../utils/config-utils";
3
+ export declare function syncGlobalVariants(context: PlasmicContext, projectMeta: ProjectMetaBundle, bundles: GlobalVariantBundle[], checksums: ChecksumBundle, baseDir: string): Promise<void>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.syncGlobalVariants = void 0;
16
+ const lodash_1 = __importDefault(require("lodash"));
17
+ const upath_1 = __importDefault(require("upath"));
18
+ const deps_1 = require("../deps");
19
+ const code_utils_1 = require("../utils/code-utils");
20
+ const config_utils_1 = require("../utils/config-utils");
21
+ const file_utils_1 = require("../utils/file-utils");
22
+ const lang_utils_1 = require("../utils/lang-utils");
23
+ function syncGlobalVariants(context, projectMeta, bundles, checksums, baseDir) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const projectId = projectMeta.projectId;
26
+ const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
27
+ const existingVariantConfigs = lodash_1.default.keyBy(context.config.globalVariants.variantGroups.filter((group) => group.projectId === projectId), (c) => c.id);
28
+ const globalVariantFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "globalVariant"), (fl) => fl.assetId);
29
+ const id2VariantChecksum = new Map(checksums.globalVariantChecksums);
30
+ const variantBundleIds = lodash_1.default.keyBy(bundles, (i) => i.id);
31
+ const deletedGlobalVariants = lodash_1.default.filter(existingVariantConfigs, (i) => !variantBundleIds[i.id] && !id2VariantChecksum.has(i.id));
32
+ for (const bundle of bundles) {
33
+ if (context.cliArgs.quiet !== true) {
34
+ deps_1.logger.info(`Syncing global variant ${bundle.name} [${projectId}/${bundle.id}]`);
35
+ }
36
+ let variantConfig = existingVariantConfigs[bundle.id];
37
+ const isNew = !variantConfig;
38
+ const defaultContextFilePath = file_utils_1.defaultResourcePath(context, projectMeta, bundle.contextFileName);
39
+ if (isNew) {
40
+ variantConfig = {
41
+ id: bundle.id,
42
+ name: bundle.name,
43
+ projectId,
44
+ contextFilePath: defaultContextFilePath,
45
+ };
46
+ existingVariantConfigs[bundle.id] = variantConfig;
47
+ context.config.globalVariants.variantGroups.push(variantConfig);
48
+ }
49
+ else {
50
+ const contextFilePath = upath_1.default.join(upath_1.default.dirname(variantConfig.contextFilePath), upath_1.default.basename(defaultContextFilePath));
51
+ if (variantConfig.contextFilePath !== contextFilePath &&
52
+ file_utils_1.fileExists(context, variantConfig.contextFilePath)) {
53
+ if (context.cliArgs.quiet !== true) {
54
+ deps_1.logger.info(`Renaming global variant: ${variantConfig.name} [${projectId}/${bundle.id}]`);
55
+ }
56
+ file_utils_1.renameFile(context, variantConfig.contextFilePath, contextFilePath);
57
+ variantConfig.contextFilePath = contextFilePath;
58
+ }
59
+ variantConfig.name = bundle.name;
60
+ }
61
+ // Update FileLocks
62
+ if (globalVariantFileLocks[bundle.id]) {
63
+ globalVariantFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2VariantChecksum.get(bundle.id));
64
+ }
65
+ else {
66
+ projectLock.fileLocks.push({
67
+ type: "globalVariant",
68
+ assetId: bundle.id,
69
+ checksum: lang_utils_1.ensure(id2VariantChecksum.get(bundle.id)),
70
+ });
71
+ }
72
+ yield file_utils_1.writeFileContent(context, variantConfig.contextFilePath, code_utils_1.formatAsLocal(bundle.contextModule, variantConfig.contextFilePath, baseDir), { force: !isNew });
73
+ }
74
+ const deletedVariantsFiles = new Set();
75
+ for (const deletedGlobalVariant of deletedGlobalVariants) {
76
+ const variantConfig = existingVariantConfigs[deletedGlobalVariant.id];
77
+ if (file_utils_1.fileExists(context, variantConfig.contextFilePath)) {
78
+ deps_1.logger.info(`Deleting global variant: ${variantConfig.name} [${projectId}/${deletedGlobalVariant.id}]`);
79
+ file_utils_1.deleteFile(context, variantConfig.contextFilePath);
80
+ deletedVariantsFiles.add(deletedGlobalVariant.id);
81
+ }
82
+ }
83
+ context.config.globalVariants.variantGroups = context.config.globalVariants.variantGroups.filter((v) => !deletedVariantsFiles.has(v.id));
84
+ const deletedVariantIds = new Set(deletedGlobalVariants.map((i) => i.id));
85
+ projectLock.fileLocks = projectLock.fileLocks.filter((fileLock) => fileLock.type !== "globalVariant" ||
86
+ !deletedVariantIds.has(fileLock.assetId));
87
+ });
88
+ }
89
+ exports.syncGlobalVariants = syncGlobalVariants;
@@ -0,0 +1,7 @@
1
+ import { CommonArgs } from "..";
2
+ import { ChecksumBundle, IconBundle } from "../api";
3
+ import { PlasmicContext } from "../utils/config-utils";
4
+ export interface SyncIconsArgs extends CommonArgs {
5
+ projects: readonly string[];
6
+ }
7
+ export declare function syncProjectIconAssets(context: PlasmicContext, projectId: string, version: string, iconBundles: IconBundle[], checksums: ChecksumBundle, baseDir: string): Promise<void>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.syncProjectIconAssets = void 0;
16
+ const lodash_1 = __importDefault(require("lodash"));
17
+ const upath_1 = __importDefault(require("upath"));
18
+ const deps_1 = require("../deps");
19
+ const code_utils_1 = require("../utils/code-utils");
20
+ const config_utils_1 = require("../utils/config-utils");
21
+ const file_utils_1 = require("../utils/file-utils");
22
+ const lang_utils_1 = require("../utils/lang-utils");
23
+ function syncProjectIconAssets(context, projectId, version, iconBundles, checksums, baseDir) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const project = config_utils_1.getOrAddProjectConfig(context, projectId);
26
+ if (!project.icons) {
27
+ project.icons = [];
28
+ }
29
+ const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
30
+ const knownIconConfigs = lodash_1.default.keyBy(project.icons, (i) => i.id);
31
+ const iconFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "icon"), (fl) => fl.assetId);
32
+ const id2IconChecksum = new Map(checksums.iconChecksums);
33
+ const iconBundleIds = lodash_1.default.keyBy(iconBundles, (i) => i.id);
34
+ const deletedIcons = lodash_1.default.filter(knownIconConfigs, (i) => !iconBundleIds[i.id] && !id2IconChecksum.has(i.id));
35
+ for (const bundle of iconBundles) {
36
+ if (context.cliArgs.quiet !== true) {
37
+ deps_1.logger.info(`Syncing icon: ${bundle.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
38
+ }
39
+ let iconConfig = knownIconConfigs[bundle.id];
40
+ const isNew = !iconConfig;
41
+ const defaultModuleFilePath = file_utils_1.defaultResourcePath(context, project, "icons", bundle.fileName);
42
+ if (isNew) {
43
+ iconConfig = {
44
+ id: bundle.id,
45
+ name: bundle.name,
46
+ moduleFilePath: defaultModuleFilePath,
47
+ };
48
+ knownIconConfigs[bundle.id] = iconConfig;
49
+ project.icons.push(iconConfig);
50
+ }
51
+ else {
52
+ const moduleFilePath = upath_1.default.join(upath_1.default.dirname(iconConfig.moduleFilePath), upath_1.default.basename(defaultModuleFilePath));
53
+ if (iconConfig.moduleFilePath !== moduleFilePath &&
54
+ file_utils_1.fileExists(context, iconConfig.moduleFilePath)) {
55
+ if (context.cliArgs.quiet !== true) {
56
+ deps_1.logger.info(`Renaming icon: ${iconConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
57
+ }
58
+ file_utils_1.renameFile(context, iconConfig.moduleFilePath, moduleFilePath);
59
+ iconConfig.moduleFilePath = moduleFilePath;
60
+ }
61
+ iconConfig.name = bundle.name;
62
+ }
63
+ // Update FileLocks
64
+ if (iconFileLocks[bundle.id]) {
65
+ iconFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2IconChecksum.get(bundle.id));
66
+ }
67
+ else {
68
+ projectLock.fileLocks.push({
69
+ type: "icon",
70
+ assetId: bundle.id,
71
+ checksum: lang_utils_1.ensure(id2IconChecksum.get(bundle.id)),
72
+ });
73
+ }
74
+ yield file_utils_1.writeFileContent(context, iconConfig.moduleFilePath, code_utils_1.formatAsLocal(bundle.module, iconConfig.moduleFilePath, baseDir), {
75
+ force: !isNew,
76
+ });
77
+ }
78
+ const deletedIconFiles = new Set();
79
+ for (const deletedIcon of deletedIcons) {
80
+ const iconConfig = knownIconConfigs[deletedIcon.id];
81
+ if (file_utils_1.fileExists(context, iconConfig.moduleFilePath)) {
82
+ deps_1.logger.info(`Deleting icon: ${iconConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${deletedIcon.id} ${project.version}]`);
83
+ file_utils_1.deleteFile(context, iconConfig.moduleFilePath);
84
+ deletedIconFiles.add(deletedIcon.id);
85
+ }
86
+ }
87
+ project.icons = project.icons.filter((i) => !deletedIconFiles.has(i.id));
88
+ const deletedIconIds = new Set(deletedIcons.map((i) => i.id));
89
+ projectLock.fileLocks = projectLock.fileLocks.filter((fileLock) => fileLock.type !== "icon" || !deletedIconIds.has(fileLock.assetId));
90
+ });
91
+ }
92
+ exports.syncProjectIconAssets = syncProjectIconAssets;
@@ -0,0 +1,6 @@
1
+ import { ChecksumBundle, ImageBundle } from "../api";
2
+ import { FixImportContext } from "../utils/code-utils";
3
+ import { PlasmicContext } from "../utils/config-utils";
4
+ export declare function syncProjectImageAssets(context: PlasmicContext, projectId: string, version: string, imageBundles: ImageBundle[], checksums: ChecksumBundle): Promise<void>;
5
+ export declare function fixComponentCssReferences(context: PlasmicContext, fixImportContext: FixImportContext, cssFilePath: string): Promise<void>;
6
+ export declare function fixComponentImagesReferences(context: PlasmicContext, fixImportContext: FixImportContext, renderModuleFilePath: string): Promise<boolean>;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.fixComponentImagesReferences = exports.fixComponentCssReferences = exports.syncProjectImageAssets = void 0;
16
+ const lodash_1 = __importDefault(require("lodash"));
17
+ const upath_1 = __importDefault(require("upath"));
18
+ const deps_1 = require("../deps");
19
+ const config_utils_1 = require("../utils/config-utils");
20
+ const file_utils_1 = require("../utils/file-utils");
21
+ const lang_utils_1 = require("../utils/lang-utils");
22
+ function syncProjectImageAssets(context, projectId, version, imageBundles, checksums) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const project = config_utils_1.getOrAddProjectConfig(context, projectId);
25
+ const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
26
+ const knownImageConfigs = lodash_1.default.keyBy(project.images, (i) => i.id);
27
+ const imageBundleIds = lodash_1.default.keyBy(imageBundles, (i) => i.id);
28
+ const imageFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "image"), (fl) => fl.assetId);
29
+ const id2ImageChecksum = new Map(checksums.imageChecksums);
30
+ const deletedImages = lodash_1.default.filter(knownImageConfigs, (i) => !imageBundleIds[i.id] && !id2ImageChecksum.has(i.id));
31
+ for (const bundle of imageBundles) {
32
+ if (context.cliArgs.quiet !== true) {
33
+ deps_1.logger.info(`Syncing image: ${bundle.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
34
+ }
35
+ let imageConfig = knownImageConfigs[bundle.id];
36
+ const isNew = !imageConfig;
37
+ const defaultFilePath = context.config.images.scheme === "public-files"
38
+ ? file_utils_1.defaultPublicResourcePath(context, project, "images", bundle.fileName)
39
+ : file_utils_1.defaultResourcePath(context, project, "images", bundle.fileName);
40
+ if (isNew) {
41
+ imageConfig = {
42
+ id: bundle.id,
43
+ name: bundle.name,
44
+ filePath: defaultFilePath,
45
+ };
46
+ project.images.push(imageConfig);
47
+ }
48
+ else {
49
+ const filePath = upath_1.default.join(upath_1.default.dirname(imageConfig.filePath), upath_1.default.basename(defaultFilePath));
50
+ if (imageConfig.filePath !== filePath &&
51
+ file_utils_1.fileExists(context, imageConfig.filePath)) {
52
+ if (context.cliArgs.quiet !== true) {
53
+ deps_1.logger.info(`Renaming image: ${imageConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
54
+ }
55
+ file_utils_1.renameFile(context, imageConfig.filePath, filePath);
56
+ imageConfig.filePath = filePath;
57
+ }
58
+ imageConfig.name = bundle.name;
59
+ }
60
+ // Update FileLocks
61
+ if (imageFileLocks[bundle.id]) {
62
+ imageFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2ImageChecksum.get(bundle.id));
63
+ }
64
+ else {
65
+ projectLock.fileLocks.push({
66
+ type: "image",
67
+ assetId: bundle.id,
68
+ checksum: lang_utils_1.ensure(id2ImageChecksum.get(bundle.id)),
69
+ });
70
+ }
71
+ yield file_utils_1.writeFileContent(context, imageConfig.filePath, Buffer.from(bundle.blob, "base64"), {
72
+ force: !isNew,
73
+ });
74
+ }
75
+ const deletedImageFiles = new Set();
76
+ for (const deletedImage of deletedImages) {
77
+ const imageConfig = knownImageConfigs[deletedImage.id];
78
+ if (file_utils_1.fileExists(context, imageConfig.filePath)) {
79
+ deps_1.logger.info(`Deleting image: ${imageConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${deletedImage.id} ${project.version}]`);
80
+ file_utils_1.deleteFile(context, imageConfig.filePath);
81
+ deletedImageFiles.add(deletedImage.id);
82
+ }
83
+ }
84
+ project.images = project.images.filter((i) => !deletedImageFiles.has(i.id));
85
+ const deletedImageIds = new Set(deletedImages.map((i) => i.id));
86
+ projectLock.fileLocks = projectLock.fileLocks.filter((fileLock) => fileLock.type !== "image" || !deletedImageIds.has(fileLock.assetId));
87
+ });
88
+ }
89
+ exports.syncProjectImageAssets = syncProjectImageAssets;
90
+ const RE_ASSETCSSREF_ALL = /var\(--image-([^\)]+)\)/g;
91
+ function fixComponentCssReferences(context, fixImportContext, cssFilePath) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ if (!file_utils_1.fileExists(context, cssFilePath)) {
94
+ return;
95
+ }
96
+ const prevContent = file_utils_1.readFileContent(context, cssFilePath);
97
+ const newContent = prevContent.replace(RE_ASSETCSSREF_ALL, (sub, assetId) => {
98
+ const asset = fixImportContext.images[assetId];
99
+ if (asset) {
100
+ return context.config.images.scheme === "public-files"
101
+ ? `url("${upath_1.default.join("/", lang_utils_1.ensure(context.config.images.publicUrlPrefix), upath_1.default.relative(lang_utils_1.ensure(context.config.images.publicDir), asset.filePath))}")`
102
+ : `url("./${upath_1.default.relative(upath_1.default.dirname(cssFilePath), asset.filePath)}")`;
103
+ }
104
+ else {
105
+ return sub;
106
+ }
107
+ });
108
+ if (prevContent !== newContent) {
109
+ yield file_utils_1.writeFileContent(context, cssFilePath, newContent, { force: true });
110
+ }
111
+ });
112
+ }
113
+ exports.fixComponentCssReferences = fixComponentCssReferences;
114
+ const RE_ASSETTSXREF_ALL = /Plasmic_Image_([^\)\s]+)__Ref/g;
115
+ function fixComponentImagesReferences(context, fixImportContext, renderModuleFilePath) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const prevContent = file_utils_1.readFileContent(context, renderModuleFilePath);
118
+ const newContent = prevContent.replace(RE_ASSETTSXREF_ALL, (sub, assetId) => {
119
+ const asset = fixImportContext.images[assetId];
120
+ if (asset) {
121
+ return upath_1.default.join("/", lang_utils_1.ensure(context.config.images.publicUrlPrefix), upath_1.default.relative(lang_utils_1.ensure(context.config.images.publicDir), asset.filePath));
122
+ }
123
+ else {
124
+ return sub;
125
+ }
126
+ });
127
+ if (prevContent !== newContent) {
128
+ yield file_utils_1.writeFileContent(context, renderModuleFilePath, newContent, {
129
+ force: true,
130
+ });
131
+ // Returns true if the content changed
132
+ return true;
133
+ }
134
+ return false;
135
+ });
136
+ }
137
+ exports.fixComponentImagesReferences = fixComponentImagesReferences;
@@ -0,0 +1,3 @@
1
+ import { StyleTokensMap } from "../api";
2
+ import { PlasmicContext } from "../utils/config-utils";
3
+ export declare function upsertStyleTokens(context: PlasmicContext, newStyleMap: StyleTokensMap): Promise<void>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.upsertStyleTokens = void 0;
13
+ const error_1 = require("../utils/error");
14
+ const file_utils_1 = require("../utils/file-utils");
15
+ function upsertStyleTokens(context, newStyleMap) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const curStyleMap = yield readCurStyleMap(context);
18
+ for (const prop of newStyleMap.props) {
19
+ const index = curStyleMap.props.findIndex((p) => p.meta.id === prop.meta.id);
20
+ if (index >= 0) {
21
+ curStyleMap.props[index] = prop;
22
+ }
23
+ else {
24
+ curStyleMap.props.push(prop);
25
+ }
26
+ }
27
+ curStyleMap.props.sort((prop1, prop2) => prop1.name === prop2.name ? 0 : prop1.name < prop2.name ? -1 : 1);
28
+ yield file_utils_1.writeFileContent(context, context.config.tokens.tokensFilePath, JSON.stringify(curStyleMap, undefined, 2), { force: true });
29
+ });
30
+ }
31
+ exports.upsertStyleTokens = upsertStyleTokens;
32
+ function readCurStyleMap(context) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const filePath = context.config.tokens.tokensFilePath;
35
+ if (file_utils_1.fileExists(context, filePath)) {
36
+ try {
37
+ return JSON.parse(file_utils_1.readFileContent(context, context.config.tokens.tokensFilePath));
38
+ }
39
+ catch (e) {
40
+ throw new error_1.HandledError(`Error encountered reading ${context.config.tokens.tokensFilePath}: ${e}`);
41
+ }
42
+ }
43
+ else {
44
+ const defaultMap = {
45
+ props: [],
46
+ global: {
47
+ meta: {
48
+ source: "plasmic.app",
49
+ },
50
+ },
51
+ };
52
+ yield file_utils_1.writeFileContent(context, context.config.tokens.tokensFilePath, JSON.stringify(defaultMap, undefined, 2), {
53
+ force: false,
54
+ });
55
+ return defaultMap;
56
+ }
57
+ });
58
+ }