@plasmicapp/cli 0.1.186 → 0.1.188
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/dist/__mocks__/api.d.ts +2 -0
- package/dist/__mocks__/api.js +16 -11
- package/dist/__tests__/project-api-token-spec.js +2 -2
- package/dist/__tests__/versioned-sync-spec.js +4 -4
- package/dist/actions/localization-strings.d.ts +3 -1
- package/dist/actions/localization-strings.js +39 -8
- package/dist/actions/project-token.js +1 -1
- package/dist/actions/sync-components.js +1 -1
- package/dist/actions/sync-global-variants.d.ts +1 -1
- package/dist/actions/sync-global-variants.js +2 -2
- package/dist/actions/sync-icons.d.ts +1 -1
- package/dist/actions/sync-icons.js +2 -2
- package/dist/actions/sync-images.d.ts +1 -1
- package/dist/actions/sync-images.js +2 -2
- package/dist/actions/sync-styles.d.ts +1 -1
- package/dist/actions/sync-styles.js +14 -1
- package/dist/actions/sync.js +24 -19
- package/dist/api.d.ts +11 -8
- package/dist/api.js +19 -14
- package/dist/index.js +5 -0
- package/dist/plasmic.schema.json +4 -0
- package/dist/test-common/fixtures.js +3 -0
- package/dist/utils/auth-utils.js +2 -2
- package/dist/utils/config-utils.d.ts +4 -1
- package/dist/utils/config-utils.js +2 -1
- package/package.json +2 -3
- package/src/__mocks__/api.ts +28 -7
- package/src/__tests__/project-api-token-spec.ts +2 -2
- package/src/__tests__/versioned-sync-spec.ts +4 -4
- package/src/actions/localization-strings.ts +60 -12
- package/src/actions/project-token.ts +1 -1
- package/src/actions/sync-components.ts +6 -1
- package/src/actions/sync-global-variants.ts +8 -3
- package/src/actions/sync-icons.ts +3 -2
- package/src/actions/sync-images.ts +2 -1
- package/src/actions/sync-styles.ts +15 -1
- package/src/actions/sync.ts +43 -22
- package/src/api.ts +29 -12
- package/src/index.ts +6 -0
- package/src/test-common/fixtures.ts +3 -0
- package/src/utils/auth-utils.ts +3 -3
- package/src/utils/config-utils.ts +5 -0
package/dist/__mocks__/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface MockProject {
|
|
2
2
|
projectId: string;
|
|
3
|
+
branchName: string;
|
|
3
4
|
projectApiToken: string;
|
|
4
5
|
version: string;
|
|
5
6
|
projectName: string;
|
|
@@ -12,5 +13,6 @@ export interface MockComponent {
|
|
|
12
13
|
id: string;
|
|
13
14
|
name: string;
|
|
14
15
|
projectId?: string;
|
|
16
|
+
branchName?: string;
|
|
15
17
|
version?: string;
|
|
16
18
|
}
|
package/dist/__mocks__/api.js
CHANGED
|
@@ -59,14 +59,16 @@ function mockProjectToProjectVersionMeta(mock, componentIdOrNames) {
|
|
|
59
59
|
*/
|
|
60
60
|
function addMockProject(proj) {
|
|
61
61
|
const projectId = proj.projectId;
|
|
62
|
+
const branchName = proj.branchName;
|
|
62
63
|
const version = proj.version;
|
|
63
64
|
// Populate projectId and version into each component
|
|
64
65
|
// will be useful when reading / writing components to files
|
|
65
66
|
proj.components = proj.components.map((c) => {
|
|
66
67
|
return Object.assign(Object.assign({}, c), { projectId,
|
|
68
|
+
branchName,
|
|
67
69
|
version });
|
|
68
70
|
});
|
|
69
|
-
const existing = getMockProject(projectId, version);
|
|
71
|
+
const existing = getMockProject(projectId, branchName, version);
|
|
70
72
|
if (!existing) {
|
|
71
73
|
PROJECTS.push(proj);
|
|
72
74
|
}
|
|
@@ -96,18 +98,21 @@ function stringToMockComponent(data) {
|
|
|
96
98
|
function mockComponentToString(component) {
|
|
97
99
|
return "// " + JSON.stringify(component);
|
|
98
100
|
}
|
|
99
|
-
function getMockProject(projectId, version) {
|
|
100
|
-
return PROJECTS.find((m) => m.projectId === projectId &&
|
|
101
|
+
function getMockProject(projectId, branchName, version) {
|
|
102
|
+
return PROJECTS.find((m) => m.projectId === projectId &&
|
|
103
|
+
m.branchName === branchName &&
|
|
104
|
+
m.version === version);
|
|
101
105
|
}
|
|
102
106
|
/**
|
|
103
107
|
* Only fetch top-level components that match the projectId (optionally also componentIdOrNames + version)
|
|
104
108
|
* Does not crawl the dependency tree
|
|
105
109
|
* @param projectId
|
|
110
|
+
* @param branchName
|
|
106
111
|
* @param componentIdOrNames
|
|
107
112
|
* @param versionRange
|
|
108
113
|
*/
|
|
109
|
-
function getMockComponents(projectId, version, componentIdOrNames) {
|
|
110
|
-
const project = getMockProject(projectId, version);
|
|
114
|
+
function getMockComponents(projectId, branchName, version, componentIdOrNames) {
|
|
115
|
+
const project = getMockProject(projectId, branchName, version);
|
|
111
116
|
return !project
|
|
112
117
|
? []
|
|
113
118
|
: project.components.filter((c) => !componentIdOrNames ||
|
|
@@ -156,7 +161,7 @@ function* getDeps(projects) {
|
|
|
156
161
|
while (queue.length > 0) {
|
|
157
162
|
const curr = lang_utils_1.ensure(queue.shift());
|
|
158
163
|
for (const [projectId, version] of lodash_1.default.toPairs(curr.dependencies)) {
|
|
159
|
-
const mockProject = lang_utils_1.ensure(getMockProject(projectId, version));
|
|
164
|
+
const mockProject = lang_utils_1.ensure(getMockProject(projectId, "main", version));
|
|
160
165
|
const projectMeta = mockProjectToProjectVersionMeta(mockProject);
|
|
161
166
|
yield projectMeta;
|
|
162
167
|
queue.push(projectMeta);
|
|
@@ -194,7 +199,7 @@ class PlasmicApi {
|
|
|
194
199
|
const availableVersions = availableProjects.map((p) => p.version);
|
|
195
200
|
const version = semver.maxSatisfying(availableVersions, proj.versionRange);
|
|
196
201
|
if (version) {
|
|
197
|
-
const mockProject = lang_utils_1.ensure(getMockProject(proj.projectId, version));
|
|
202
|
+
const mockProject = lang_utils_1.ensure(getMockProject(proj.projectId, proj.branchName, version));
|
|
198
203
|
const projectMeta = mockProjectToProjectVersionMeta(mockProject, proj.componentIdOrNames);
|
|
199
204
|
results.projects.push(projectMeta);
|
|
200
205
|
}
|
|
@@ -212,7 +217,7 @@ class PlasmicApi {
|
|
|
212
217
|
return true;
|
|
213
218
|
});
|
|
214
219
|
}
|
|
215
|
-
projectComponents(projectId, opts) {
|
|
220
|
+
projectComponents(projectId, branchName, opts) {
|
|
216
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
217
222
|
const { componentIdOrNames, version } = opts;
|
|
218
223
|
if (PROJECTS.length <= 0) {
|
|
@@ -229,7 +234,7 @@ class PlasmicApi {
|
|
|
229
234
|
if (!deps.every((dep) => this.lastProjectIdsAndTokens.find((p) => p.projectId === dep.projectId))) {
|
|
230
235
|
throw new Error("No user+token and project API tokens don't match on a dependency");
|
|
231
236
|
}
|
|
232
|
-
const mockComponents = getMockComponents(projectId, version, componentIdOrNames);
|
|
237
|
+
const mockComponents = getMockComponents(projectId, branchName, version, componentIdOrNames);
|
|
233
238
|
if (mockComponents.length <= 0) {
|
|
234
239
|
throw new Error(`Code gen failed: no components match the parameters ${JSON.stringify({ projectId, version, componentIdOrNames }, undefined, 2)}`);
|
|
235
240
|
}
|
|
@@ -262,12 +267,12 @@ class PlasmicApi {
|
|
|
262
267
|
throw new Error("Unimplemented");
|
|
263
268
|
});
|
|
264
269
|
}
|
|
265
|
-
projectStyleTokens(projectId) {
|
|
270
|
+
projectStyleTokens(projectId, branchName) {
|
|
266
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
272
|
throw new Error("Unimplemented");
|
|
268
273
|
});
|
|
269
274
|
}
|
|
270
|
-
projectIcons(projectId) {
|
|
275
|
+
projectIcons(projectId, branchName) {
|
|
271
276
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
277
|
throw new Error("Unimplemented");
|
|
273
278
|
});
|
|
@@ -96,7 +96,7 @@ describe("Project API tokens", () => {
|
|
|
96
96
|
// We sync project1 which got updated, but the dependency is still same version.
|
|
97
97
|
fixtures_1.opts.force = false;
|
|
98
98
|
removeAuth();
|
|
99
|
-
fixtures_1.mockApi.getMockProject("projectId1", "1.2.3").version = "1.2.4";
|
|
99
|
+
fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3").version = "1.2.4";
|
|
100
100
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
101
101
|
}));
|
|
102
102
|
test("should prompt for auth if you have only irrelevant tokens", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -134,7 +134,7 @@ describe("Project API tokens", () => {
|
|
|
134
134
|
// We sync project1 which got updated, but the dependency is still same version.
|
|
135
135
|
fixtures_1.opts.force = false;
|
|
136
136
|
removeAuth();
|
|
137
|
-
fixtures_1.mockApi.getMockProject("projectId1", "1.2.3").version = "1.2.4";
|
|
137
|
+
fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3").version = "1.2.4";
|
|
138
138
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
139
139
|
}));
|
|
140
140
|
test("should fail in loader mode if not available", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -45,7 +45,7 @@ describe("versioned-sync", () => {
|
|
|
45
45
|
fixtures_1.opts.projects = ["projectId1"];
|
|
46
46
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
47
47
|
// Change component name server-side
|
|
48
|
-
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "1.2.3");
|
|
48
|
+
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
|
|
49
49
|
const buttonData = mockProject.components.find((c) => c.id === "buttonId");
|
|
50
50
|
buttonData.name = "NewButton";
|
|
51
51
|
mockProject.version = "2.0.0";
|
|
@@ -64,7 +64,7 @@ describe("versioned-sync", () => {
|
|
|
64
64
|
fixtures_1.opts.projects = ["projectId1"];
|
|
65
65
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
66
66
|
// Change component version server-side
|
|
67
|
-
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "1.2.3");
|
|
67
|
+
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
|
|
68
68
|
mockProject.version = "1.3.4";
|
|
69
69
|
fixtures_1.mockApi.addMockProject(mockProject);
|
|
70
70
|
// Try syncing again and see if things show up
|
|
@@ -79,7 +79,7 @@ describe("versioned-sync", () => {
|
|
|
79
79
|
fixtures_1.opts.nonRecursive = true;
|
|
80
80
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
81
81
|
// Change component version server-side
|
|
82
|
-
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "1.2.3");
|
|
82
|
+
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
|
|
83
83
|
mockProject.version = "2.0.0";
|
|
84
84
|
fixtures_1.mockApi.addMockProject(mockProject);
|
|
85
85
|
// Read in updated plasmic.json post-sync
|
|
@@ -104,7 +104,7 @@ describe("versioned-sync", () => {
|
|
|
104
104
|
fixtures_1.opts.nonRecursive = true;
|
|
105
105
|
yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
|
|
106
106
|
// Change component version server-side
|
|
107
|
-
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "1.2.3");
|
|
107
|
+
const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
|
|
108
108
|
mockProject.version = "1.10.1";
|
|
109
109
|
fixtures_1.mockApi.addMockProject(mockProject);
|
|
110
110
|
// Update plasmic.json to use semver
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { CommonArgs } from "..";
|
|
2
|
+
export interface LocalizationStringsArgs extends CommonArgs {
|
|
2
3
|
host: string;
|
|
3
4
|
projects: readonly string[];
|
|
5
|
+
projectTokens?: readonly string[];
|
|
4
6
|
format: "po" | "json" | "lingui";
|
|
5
7
|
output: string;
|
|
6
8
|
forceOverwrite: boolean;
|
|
@@ -14,31 +14,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.localizationStrings = void 0;
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
17
18
|
const api_1 = require("../api");
|
|
18
19
|
const deps_1 = require("../deps");
|
|
19
20
|
const lib_1 = require("../lib");
|
|
20
21
|
const auth_utils_1 = require("../utils/auth-utils");
|
|
21
22
|
const config_utils_1 = require("../utils/config-utils");
|
|
22
23
|
const file_utils_1 = require("../utils/file-utils");
|
|
24
|
+
const get_context_1 = require("../utils/get-context");
|
|
23
25
|
const user_utils_1 = require("../utils/user-utils");
|
|
24
26
|
function localizationStrings(opts) {
|
|
27
|
+
var _a;
|
|
25
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
29
|
if (!opts.projects || opts.projects.length === 0) {
|
|
27
30
|
throw new lib_1.HandledError(`Missing projects.`);
|
|
28
31
|
}
|
|
32
|
+
if (!opts.baseDir)
|
|
33
|
+
opts.baseDir = process.cwd();
|
|
34
|
+
const parsedProjectTokens = ((_a = opts.projectTokens) !== null && _a !== void 0 ? _a : []).map((val) => {
|
|
35
|
+
const [projectId, projectApiToken] = val.split(":");
|
|
36
|
+
if (!projectId || !projectApiToken) {
|
|
37
|
+
throw new Error(`Invalid value passed to '--project-tokens': ${val}\nPlease provide the API tokens with the format PROJECT_ID:PROJECT_API_TOKEN`);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
projectId: projectId.trim(),
|
|
41
|
+
projectApiToken: projectApiToken.trim(),
|
|
42
|
+
};
|
|
43
|
+
});
|
|
29
44
|
const output = !opts.output
|
|
30
45
|
? opts.format === "po"
|
|
31
46
|
? "data.po"
|
|
32
47
|
: "data.json"
|
|
33
48
|
: opts.output;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
const projectTokensFromConfig = [];
|
|
50
|
+
const auth = yield auth_utils_1.getCurrentAuth(opts.auth);
|
|
51
|
+
const maybeConfigFile = opts.config || config_utils_1.findConfigFile(opts.baseDir, { traverseParents: true });
|
|
52
|
+
if (maybeConfigFile) {
|
|
53
|
+
const context = yield get_context_1.getContext(opts, { enableSkipAuth: true });
|
|
54
|
+
context.config.projects.forEach((p) => {
|
|
55
|
+
projectTokensFromConfig.push(lodash_1.pick(p, "projectId", "projectApiToken"));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const projectIdsAndTokens = [
|
|
59
|
+
...parsedProjectTokens,
|
|
60
|
+
...projectTokensFromConfig,
|
|
61
|
+
].filter((v) => !!v && !!v.projectId && !!v.projectApiToken);
|
|
62
|
+
if (auth || projectIdsAndTokens.length > 0) {
|
|
63
|
+
const api = new api_1.PlasmicApi(auth !== null && auth !== void 0 ? auth : {
|
|
64
|
+
host: config_utils_1.DEFAULT_HOST,
|
|
65
|
+
user: "",
|
|
66
|
+
token: "",
|
|
67
|
+
});
|
|
40
68
|
deps_1.logger.info(`Generating localization strings for ${chalk_1.default.bold(opts.projects.join(", "))}...`);
|
|
41
|
-
const data = yield api.genLocalizationStrings(opts.projects, opts.format);
|
|
69
|
+
const data = yield api.genLocalizationStrings(opts.projects, opts.format, projectIdsAndTokens);
|
|
42
70
|
if (file_utils_1.existsBuffered(output)) {
|
|
43
71
|
const overwrite = yield user_utils_1.confirmWithUser(`File ${output} already exists. Do you want to overwrite?`, opts.forceOverwrite);
|
|
44
72
|
if (!overwrite) {
|
|
@@ -49,7 +77,10 @@ function localizationStrings(opts) {
|
|
|
49
77
|
deps_1.logger.info(`Localization strings have been written to ${output}`);
|
|
50
78
|
}
|
|
51
79
|
else {
|
|
52
|
-
deps_1.logger.error(
|
|
80
|
+
deps_1.logger.error(`Missing auth information. You can follow any of the steps below to fix it:
|
|
81
|
+
- Run 'plasmic auth'
|
|
82
|
+
- Provide the project API token to 'plasmic.json'
|
|
83
|
+
- Or provide the project API token through '--project-tokens' flag`);
|
|
53
84
|
}
|
|
54
85
|
});
|
|
55
86
|
}
|
|
@@ -27,7 +27,7 @@ exports.getProjectApiToken = (projectId, host) => __awaiter(void 0, void 0, void
|
|
|
27
27
|
if (auth) {
|
|
28
28
|
const api = new api_1.PlasmicApi(auth);
|
|
29
29
|
const versionResolution = yield api.resolveSync([
|
|
30
|
-
{ projectId, componentIdOrNames: undefined },
|
|
30
|
+
{ projectId, branchName: "main", componentIdOrNames: undefined },
|
|
31
31
|
]);
|
|
32
32
|
return (_a = versionResolution.projects[0]) === null || _a === void 0 ? void 0 : _a.projectApiToken;
|
|
33
33
|
}
|
|
@@ -34,7 +34,7 @@ const updateDirectSkeleton = (newFileContent, editedFileContent, context, compCo
|
|
|
34
34
|
});
|
|
35
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
36
|
try {
|
|
37
|
-
return yield context.api.projectSyncMetadata(projectId, revision, true);
|
|
37
|
+
return yield context.api.projectSyncMetadata(projectId, "main", revision, true);
|
|
38
38
|
}
|
|
39
39
|
catch (e) {
|
|
40
40
|
if (e instanceof api_1.AppServerError &&
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ChecksumBundle, GlobalVariantBundle, ProjectMetaBundle } from "../api";
|
|
2
2
|
import { PlasmicContext } from "../utils/config-utils";
|
|
3
|
-
export declare function syncGlobalVariants(context: PlasmicContext, projectMeta: ProjectMetaBundle, bundles: GlobalVariantBundle[], checksums: ChecksumBundle, baseDir: string): Promise<void>;
|
|
3
|
+
export declare function syncGlobalVariants(context: PlasmicContext, projectMeta: ProjectMetaBundle, bundles: GlobalVariantBundle[], checksums: ChecksumBundle, branchName: string, baseDir: string): Promise<void>;
|
|
@@ -20,10 +20,10 @@ const code_utils_1 = require("../utils/code-utils");
|
|
|
20
20
|
const config_utils_1 = require("../utils/config-utils");
|
|
21
21
|
const file_utils_1 = require("../utils/file-utils");
|
|
22
22
|
const lang_utils_1 = require("../utils/lang-utils");
|
|
23
|
-
function syncGlobalVariants(context, projectMeta, bundles, checksums, baseDir) {
|
|
23
|
+
function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName, baseDir) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const projectId = projectMeta.projectId;
|
|
26
|
-
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
|
|
26
|
+
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
|
|
27
27
|
const existingVariantConfigs = lodash_1.default.keyBy(context.config.globalVariants.variantGroups.filter((group) => group.projectId === projectId), (c) => c.id);
|
|
28
28
|
const globalVariantFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "globalVariant"), (fl) => fl.assetId);
|
|
29
29
|
const id2VariantChecksum = new Map(checksums.globalVariantChecksums);
|
|
@@ -4,4 +4,4 @@ import { PlasmicContext } from "../utils/config-utils";
|
|
|
4
4
|
export interface SyncIconsArgs extends CommonArgs {
|
|
5
5
|
projects: readonly string[];
|
|
6
6
|
}
|
|
7
|
-
export declare function syncProjectIconAssets(context: PlasmicContext, projectId: string, version: string, iconBundles: IconBundle[], checksums: ChecksumBundle, baseDir: string): Promise<void>;
|
|
7
|
+
export declare function syncProjectIconAssets(context: PlasmicContext, projectId: string, branchName: string, version: string, iconBundles: IconBundle[], checksums: ChecksumBundle, baseDir: string): Promise<void>;
|
|
@@ -20,13 +20,13 @@ const code_utils_1 = require("../utils/code-utils");
|
|
|
20
20
|
const config_utils_1 = require("../utils/config-utils");
|
|
21
21
|
const file_utils_1 = require("../utils/file-utils");
|
|
22
22
|
const lang_utils_1 = require("../utils/lang-utils");
|
|
23
|
-
function syncProjectIconAssets(context, projectId, version, iconBundles, checksums, baseDir) {
|
|
23
|
+
function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums, baseDir) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const project = config_utils_1.getOrAddProjectConfig(context, projectId);
|
|
26
26
|
if (!project.icons) {
|
|
27
27
|
project.icons = [];
|
|
28
28
|
}
|
|
29
|
-
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
|
|
29
|
+
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
|
|
30
30
|
const knownIconConfigs = lodash_1.default.keyBy(project.icons, (i) => i.id);
|
|
31
31
|
const iconFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "icon"), (fl) => fl.assetId);
|
|
32
32
|
const id2IconChecksum = new Map(checksums.iconChecksums);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChecksumBundle, ImageBundle } from "../api";
|
|
2
2
|
import { FixImportContext } from "../utils/code-utils";
|
|
3
3
|
import { PlasmicContext } from "../utils/config-utils";
|
|
4
|
-
export declare function syncProjectImageAssets(context: PlasmicContext, projectId: string, version: string, imageBundles: ImageBundle[], checksums: ChecksumBundle): Promise<void>;
|
|
4
|
+
export declare function syncProjectImageAssets(context: PlasmicContext, projectId: string, branchName: string, version: string, imageBundles: ImageBundle[], checksums: ChecksumBundle): Promise<void>;
|
|
5
5
|
export declare function fixComponentCssReferences(context: PlasmicContext, fixImportContext: FixImportContext, cssFilePath: string): Promise<void>;
|
|
6
6
|
export declare function fixComponentImagesReferences(context: PlasmicContext, fixImportContext: FixImportContext, renderModuleFilePath: string): Promise<boolean>;
|
|
@@ -19,10 +19,10 @@ const deps_1 = require("../deps");
|
|
|
19
19
|
const config_utils_1 = require("../utils/config-utils");
|
|
20
20
|
const file_utils_1 = require("../utils/file-utils");
|
|
21
21
|
const lang_utils_1 = require("../utils/lang-utils");
|
|
22
|
-
function syncProjectImageAssets(context, projectId, version, imageBundles, checksums) {
|
|
22
|
+
function syncProjectImageAssets(context, projectId, branchName, version, imageBundles, checksums) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
const project = config_utils_1.getOrAddProjectConfig(context, projectId);
|
|
25
|
-
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId);
|
|
25
|
+
const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
|
|
26
26
|
const knownImageConfigs = lodash_1.default.keyBy(project.images, (i) => i.id);
|
|
27
27
|
const imageBundleIds = lodash_1.default.keyBy(imageBundles, (i) => i.id);
|
|
28
28
|
const imageFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "image"), (fl) => fl.assetId);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StyleTokensMap } from "../api";
|
|
2
2
|
import { PlasmicContext } from "../utils/config-utils";
|
|
3
|
-
export declare function upsertStyleTokens(context: PlasmicContext, newStyleMap: StyleTokensMap): Promise<void>;
|
|
3
|
+
export declare function upsertStyleTokens(context: PlasmicContext, newStyleMap: StyleTokensMap, projectId: string): Promise<void>;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.upsertStyleTokens = void 0;
|
|
13
13
|
const error_1 = require("../utils/error");
|
|
14
14
|
const file_utils_1 = require("../utils/file-utils");
|
|
15
|
-
function upsertStyleTokens(context, newStyleMap) {
|
|
15
|
+
function upsertStyleTokens(context, newStyleMap, projectId) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const curStyleMap = yield readCurStyleMap(context);
|
|
18
18
|
for (const prop of newStyleMap.props) {
|
|
@@ -24,6 +24,19 @@ function upsertStyleTokens(context, newStyleMap) {
|
|
|
24
24
|
curStyleMap.props.push(prop);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
const allNewPropIds = new Set(newStyleMap.props.map((prop) => prop.meta.id));
|
|
28
|
+
curStyleMap.props = curStyleMap.props.filter((prop) => {
|
|
29
|
+
if (prop.meta.projectId !== projectId) {
|
|
30
|
+
// Keep all tokens from other projects
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (allNewPropIds.has(prop.meta.id)) {
|
|
34
|
+
// Keep the current tokens in this project
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
// Delete the tokens that have been removed from the project
|
|
38
|
+
return false;
|
|
39
|
+
});
|
|
27
40
|
curStyleMap.props.sort((prop1, prop2) => prop1.name === prop2.name ? 0 : prop1.name < prop2.name ? -1 : 1);
|
|
28
41
|
yield file_utils_1.writeFileContent(context, context.config.tokens.tokensFilePath, JSON.stringify(curStyleMap, undefined, 2), { force: true });
|
|
29
42
|
});
|
package/dist/actions/sync.js
CHANGED
|
@@ -150,12 +150,13 @@ function sync(opts, metadataDefaults) {
|
|
|
150
150
|
// Resolve what will be synced
|
|
151
151
|
const projectConfigMap = lodash_1.default.keyBy(context.config.projects, (p) => p.projectId);
|
|
152
152
|
const projectWithVersion = opts.projects.map((p) => {
|
|
153
|
-
var _a;
|
|
153
|
+
var _a, _b, _c;
|
|
154
154
|
const [projectIdToken, versionRange] = p.split("@");
|
|
155
155
|
const [projectId, projectApiToken] = projectIdToken.split(":");
|
|
156
156
|
return {
|
|
157
157
|
projectId,
|
|
158
|
-
|
|
158
|
+
branchName: (_b = (_a = projectConfigMap[projectId]) === null || _a === void 0 ? void 0 : _a.projectBranchName) !== null && _b !== void 0 ? _b : "main",
|
|
159
|
+
versionRange: versionRange || ((_c = projectConfigMap[projectId]) === null || _c === void 0 ? void 0 : _c.version) || "latest",
|
|
159
160
|
componentIdOrNames: undefined,
|
|
160
161
|
projectApiToken: projectApiToken || projectIdToToken.get(projectId),
|
|
161
162
|
indirect: false,
|
|
@@ -163,13 +164,17 @@ function sync(opts, metadataDefaults) {
|
|
|
163
164
|
});
|
|
164
165
|
const projectSyncParams = projectWithVersion.length
|
|
165
166
|
? projectWithVersion
|
|
166
|
-
: context.config.projects.map((p) =>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
: context.config.projects.map((p) => {
|
|
168
|
+
var _a;
|
|
169
|
+
return ({
|
|
170
|
+
projectId: p.projectId,
|
|
171
|
+
branchName: (_a = p.projectBranchName) !== null && _a !== void 0 ? _a : "main",
|
|
172
|
+
versionRange: p.version,
|
|
173
|
+
componentIdOrNames: undefined,
|
|
174
|
+
projectApiToken: p.projectApiToken,
|
|
175
|
+
indirect: !!p.indirect,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
173
178
|
// Short-circuit if nothing to sync
|
|
174
179
|
if (projectSyncParams.length === 0) {
|
|
175
180
|
throw new error_1.HandledError("Don't know which projects to sync. Please specify via --projects");
|
|
@@ -224,7 +229,7 @@ function sync(opts, metadataDefaults) {
|
|
|
224
229
|
// Sync in sequence (no parallelism)
|
|
225
230
|
// going in reverse to get leaves of the dependency tree first
|
|
226
231
|
for (const projectMeta of projectsToSync) {
|
|
227
|
-
yield syncProject(context, opts, projectIdsAndTokens, projectMeta.projectId, projectMeta.componentIds, projectMeta.version, projectMeta.dependencies, summary, pendingMerge, projectMeta.indirect, externalNpmPackages, externalCssImports, metadataDefaults);
|
|
232
|
+
yield syncProject(context, opts, projectIdsAndTokens, projectMeta.projectId, projectMeta.branchName, projectMeta.componentIds, projectMeta.version, projectMeta.dependencies, summary, pendingMerge, projectMeta.indirect, externalNpmPackages, externalCssImports, metadataDefaults);
|
|
228
233
|
}
|
|
229
234
|
// Materialize scheme into each component config.
|
|
230
235
|
context.config.projects.forEach((p) => p.components.forEach((c) => {
|
|
@@ -339,7 +344,7 @@ function fixFileExtension(context) {
|
|
|
339
344
|
});
|
|
340
345
|
});
|
|
341
346
|
}
|
|
342
|
-
function syncProject(context, opts, projectIdsAndTokens, projectId, componentIds, projectVersion, dependencies, summary, pendingMerge, indirect, externalNpmPackages, externalCssImports, metadataDefaults) {
|
|
347
|
+
function syncProject(context, opts, projectIdsAndTokens, projectId, branchName, componentIds, projectVersion, dependencies, summary, pendingMerge, indirect, externalNpmPackages, externalCssImports, metadataDefaults) {
|
|
343
348
|
var _a;
|
|
344
349
|
return __awaiter(this, void 0, void 0, function* () {
|
|
345
350
|
const newComponentScheme = opts.newComponentScheme || context.config.code.scheme;
|
|
@@ -348,7 +353,7 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, componentIds
|
|
|
348
353
|
const projectApiToken = lang_utils_1.ensure((_a = projectIdsAndTokens.find((p) => p.projectId === projectId)) === null || _a === void 0 ? void 0 : _a.projectApiToken, `Could not find the API token for project ${projectId} in list: ${JSON.stringify(projectIdsAndTokens)}`);
|
|
349
354
|
const existingChecksums = checksum_1.getChecksums(context, opts, projectId, componentIds);
|
|
350
355
|
// Server-side code-gen
|
|
351
|
-
const projectBundle = yield context.api.projectComponents(projectId, {
|
|
356
|
+
const projectBundle = yield context.api.projectComponents(projectId, branchName, {
|
|
352
357
|
platform: context.config.platform,
|
|
353
358
|
newCompScheme: newComponentScheme,
|
|
354
359
|
existingCompScheme,
|
|
@@ -378,12 +383,12 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, componentIds
|
|
|
378
383
|
[theme.themeFileName, theme.themeModule] = code_utils_1.maybeConvertTsxToJsx(theme.themeFileName, theme.themeModule, opts.baseDir);
|
|
379
384
|
});
|
|
380
385
|
}
|
|
381
|
-
yield sync_global_variants_1.syncGlobalVariants(context, projectBundle.projectConfig, projectBundle.globalVariants, projectBundle.checksums, opts.baseDir);
|
|
382
|
-
yield syncProjectConfig(context, projectBundle.projectConfig, projectApiToken, projectVersion, dependencies, projectBundle.components, opts.forceOverwrite, !!opts.appendJsxOnMissingBase, summary, pendingMerge, projectBundle.checksums, opts.baseDir, indirect);
|
|
386
|
+
yield sync_global_variants_1.syncGlobalVariants(context, projectBundle.projectConfig, projectBundle.globalVariants, projectBundle.checksums, branchName, opts.baseDir);
|
|
387
|
+
yield syncProjectConfig(context, projectBundle.projectConfig, projectApiToken, branchName, projectVersion, dependencies, projectBundle.components, opts.forceOverwrite, !!opts.appendJsxOnMissingBase, summary, pendingMerge, projectBundle.checksums, opts.baseDir, indirect);
|
|
383
388
|
syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
|
|
384
|
-
yield sync_styles_1.upsertStyleTokens(context, projectBundle.usedTokens);
|
|
385
|
-
yield sync_icons_1.syncProjectIconAssets(context, projectId, projectVersion, projectBundle.iconAssets, projectBundle.checksums, opts.baseDir);
|
|
386
|
-
yield sync_images_1.syncProjectImageAssets(context, projectId, projectVersion, projectBundle.imageAssets, projectBundle.checksums);
|
|
389
|
+
yield sync_styles_1.upsertStyleTokens(context, projectBundle.usedTokens, projectBundle.projectConfig.projectId);
|
|
390
|
+
yield sync_icons_1.syncProjectIconAssets(context, projectId, branchName, projectVersion, projectBundle.iconAssets, projectBundle.checksums, opts.baseDir);
|
|
391
|
+
yield sync_images_1.syncProjectImageAssets(context, projectId, branchName, projectVersion, projectBundle.imageAssets, projectBundle.checksums);
|
|
387
392
|
(projectBundle.usedNpmPackages || []).forEach((pkg) => externalNpmPackages.add(pkg));
|
|
388
393
|
(projectBundle.externalCssImports || []).forEach((css) => externalCssImports.add(css));
|
|
389
394
|
});
|
|
@@ -398,7 +403,7 @@ function syncStyleConfig(context, response) {
|
|
|
398
403
|
});
|
|
399
404
|
});
|
|
400
405
|
}
|
|
401
|
-
function syncProjectConfig(context, projectBundle, projectApiToken, version, dependencies, componentBundles, forceOverwrite, appendJsxOnMissingBase, summary, pendingMerge, checksums, baseDir, indirect) {
|
|
406
|
+
function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, appendJsxOnMissingBase, summary, pendingMerge, checksums, baseDir, indirect) {
|
|
402
407
|
return __awaiter(this, void 0, void 0, function* () {
|
|
403
408
|
const defaultCssFilePath = file_utils_1.defaultResourcePath(context, projectBundle.projectName, projectBundle.cssFileName);
|
|
404
409
|
const isNew = !context.config.projects.find((p) => p.projectId === projectBundle.projectId);
|
|
@@ -416,7 +421,7 @@ function syncProjectConfig(context, projectBundle, projectApiToken, version, dep
|
|
|
416
421
|
projectConfig.cssFilePath = defaultCssFilePath;
|
|
417
422
|
}
|
|
418
423
|
// plasmic.lock
|
|
419
|
-
const projectLock = config_utils_1.getOrAddProjectLock(context, projectConfig.projectId);
|
|
424
|
+
const projectLock = config_utils_1.getOrAddProjectLock(context, projectConfig.projectId, branchName);
|
|
420
425
|
projectLock.version = version;
|
|
421
426
|
projectLock.dependencies = dependencies;
|
|
422
427
|
projectLock.lang = context.config.code.lang;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="socket.io-client" />
|
|
2
1
|
import { ProjectSyncMetadataModel } from "@plasmicapp/code-merger";
|
|
2
|
+
import { Socket } from "socket.io-client";
|
|
3
3
|
import { AuthConfig, CodeConfig, ImagesConfig, StyleConfig } from "./utils/config-utils";
|
|
4
4
|
import { Metadata } from "./utils/get-context";
|
|
5
5
|
export declare class AppServerError extends Error {
|
|
@@ -56,6 +56,7 @@ export interface ImageBundle {
|
|
|
56
56
|
}
|
|
57
57
|
export interface ProjectVersionMeta {
|
|
58
58
|
projectId: string;
|
|
59
|
+
branchName: string;
|
|
59
60
|
projectApiToken: string;
|
|
60
61
|
version: string;
|
|
61
62
|
projectName: string;
|
|
@@ -155,6 +156,7 @@ export declare class PlasmicApi {
|
|
|
155
156
|
*/
|
|
156
157
|
resolveSync(projects: {
|
|
157
158
|
projectId: string;
|
|
159
|
+
branchName: string;
|
|
158
160
|
versionRange?: string;
|
|
159
161
|
componentIdOrNames: readonly string[] | undefined;
|
|
160
162
|
projectApiToken?: string;
|
|
@@ -164,9 +166,10 @@ export declare class PlasmicApi {
|
|
|
164
166
|
latestCodegenVersion(): Promise<string>;
|
|
165
167
|
/**
|
|
166
168
|
* Code-gen endpoint.
|
|
167
|
-
* This will fetch components at an exact specified version.
|
|
169
|
+
* This will fetch components from a given branch at an exact specified version.
|
|
168
170
|
* If you don't know what version should be used, call `resolveSync` first.
|
|
169
171
|
* @param projectId
|
|
172
|
+
* @param branchName
|
|
170
173
|
* @param cliVersion
|
|
171
174
|
* @param reactWebVersion
|
|
172
175
|
* @param newCompScheme
|
|
@@ -174,7 +177,7 @@ export declare class PlasmicApi {
|
|
|
174
177
|
* @param componentIdOrNames
|
|
175
178
|
* @param version
|
|
176
179
|
*/
|
|
177
|
-
projectComponents(projectId: string, opts: {
|
|
180
|
+
projectComponents(projectId: string, branchName: string, opts: {
|
|
178
181
|
platform: string;
|
|
179
182
|
newCompScheme: "blackbox" | "direct";
|
|
180
183
|
existingCompScheme: Array<[string, "blackbox" | "direct"]>;
|
|
@@ -189,12 +192,12 @@ export declare class PlasmicApi {
|
|
|
189
192
|
metadata?: Metadata;
|
|
190
193
|
}): Promise<ProjectBundle>;
|
|
191
194
|
projectMeta(projectId: string): Promise<ProjectMetaInfo>;
|
|
192
|
-
genLocalizationStrings(projects: readonly string[], format: "po" | "json" | "lingui"): Promise<string>;
|
|
195
|
+
genLocalizationStrings(projects: readonly string[], format: "po" | "json" | "lingui", projectIdsAndTokens: ProjectIdAndToken[]): Promise<string>;
|
|
193
196
|
uploadBundle(projectId: string, bundleName: string, bundleJs: string, css: string[], metaJson: string, genModulePath: string | undefined, genCssPaths: string[], pkgVersion: string | undefined, extraPropMetaJson: string | undefined, themeProviderWrapper: string | undefined, themeModule: string | undefined): Promise<StyleTokensMap>;
|
|
194
|
-
projectStyleTokens(projectId: string, versionRange?: string): Promise<StyleTokensMap>;
|
|
195
|
-
projectIcons(projectId: string, versionRange?: string, iconIds?: string[]): Promise<ProjectIconsResponse>;
|
|
196
|
-
projectSyncMetadata(projectId: string, revision: number, rethrowAppError: boolean): Promise<ProjectSyncMetadataModel>;
|
|
197
|
-
connectSocket():
|
|
197
|
+
projectStyleTokens(projectId: string, branchName: string, versionRange?: string): Promise<StyleTokensMap>;
|
|
198
|
+
projectIcons(projectId: string, branchName: string, versionRange?: string, iconIds?: string[]): Promise<ProjectIconsResponse>;
|
|
199
|
+
projectSyncMetadata(projectId: string, branchName: string, revision: number, rethrowAppError: boolean): Promise<ProjectSyncMetadataModel>;
|
|
200
|
+
connectSocket(): Socket;
|
|
198
201
|
private post;
|
|
199
202
|
private get;
|
|
200
203
|
private makeErrorMessage;
|
package/dist/api.js
CHANGED
|
@@ -77,9 +77,10 @@ class PlasmicApi {
|
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Code-gen endpoint.
|
|
80
|
-
* This will fetch components at an exact specified version.
|
|
80
|
+
* This will fetch components from a given branch at an exact specified version.
|
|
81
81
|
* If you don't know what version should be used, call `resolveSync` first.
|
|
82
82
|
* @param projectId
|
|
83
|
+
* @param branchName
|
|
83
84
|
* @param cliVersion
|
|
84
85
|
* @param reactWebVersion
|
|
85
86
|
* @param newCompScheme
|
|
@@ -87,9 +88,9 @@ class PlasmicApi {
|
|
|
87
88
|
* @param componentIdOrNames
|
|
88
89
|
* @param version
|
|
89
90
|
*/
|
|
90
|
-
projectComponents(projectId, opts) {
|
|
91
|
+
projectComponents(projectId, branchName, opts) {
|
|
91
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/components`, Object.assign({}, opts));
|
|
93
|
+
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/components?branchName=${branchName}`, Object.assign({}, opts));
|
|
93
94
|
return result.data;
|
|
94
95
|
});
|
|
95
96
|
}
|
|
@@ -99,11 +100,15 @@ class PlasmicApi {
|
|
|
99
100
|
return result.data;
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
|
-
genLocalizationStrings(projects, format) {
|
|
103
|
+
genLocalizationStrings(projects, format, projectIdsAndTokens) {
|
|
103
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
105
|
const result = yield this.get(`${this.codegenHost}/api/v1/localization/gen-texts?format=${format}&preview=true&${projects
|
|
105
106
|
.map((p) => `projectId=${p}`)
|
|
106
|
-
.join("&")}
|
|
107
|
+
.join("&")}`, undefined, {
|
|
108
|
+
"x-plasmic-api-project-tokens": projectIdsAndTokens
|
|
109
|
+
.map(({ projectId, projectApiToken }) => `${projectId}:${projectApiToken}`)
|
|
110
|
+
.join(","),
|
|
111
|
+
});
|
|
107
112
|
return result.data;
|
|
108
113
|
});
|
|
109
114
|
}
|
|
@@ -125,26 +130,26 @@ class PlasmicApi {
|
|
|
125
130
|
return result.data;
|
|
126
131
|
});
|
|
127
132
|
}
|
|
128
|
-
projectStyleTokens(projectId, versionRange) {
|
|
133
|
+
projectStyleTokens(projectId, branchName, versionRange) {
|
|
129
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/tokens`, { versionRange });
|
|
135
|
+
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/tokens?branchName=${branchName}`, { versionRange });
|
|
131
136
|
return result.data;
|
|
132
137
|
});
|
|
133
138
|
}
|
|
134
|
-
projectIcons(projectId, versionRange, iconIds) {
|
|
139
|
+
projectIcons(projectId, branchName, versionRange, iconIds) {
|
|
135
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/icons`, { versionRange, iconIds });
|
|
141
|
+
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/icons?branchName=${branchName}`, { versionRange, iconIds });
|
|
137
142
|
return result.data;
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
|
-
projectSyncMetadata(projectId, revision, rethrowAppError) {
|
|
145
|
+
projectSyncMetadata(projectId, branchName, revision, rethrowAppError) {
|
|
141
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/project-sync-metadata`, { revision }, rethrowAppError);
|
|
147
|
+
const result = yield this.post(`${this.codegenHost}/api/v1/projects/${projectId}/code/project-sync-metadata?branchName=${branchName}`, { revision }, rethrowAppError);
|
|
143
148
|
return code_merger_1.ProjectSyncMetadataModel.fromJson(result.data);
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
151
|
connectSocket() {
|
|
147
|
-
const socket = socket_io_client_1.default
|
|
152
|
+
const socket = socket_io_client_1.default(this.studioHost, {
|
|
148
153
|
path: `/api/v1/socket`,
|
|
149
154
|
transportOptions: {
|
|
150
155
|
polling: {
|
|
@@ -176,11 +181,11 @@ class PlasmicApi {
|
|
|
176
181
|
}
|
|
177
182
|
});
|
|
178
183
|
}
|
|
179
|
-
get(url, rethrowAppError) {
|
|
184
|
+
get(url, rethrowAppError, extraHeaders) {
|
|
180
185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
186
|
try {
|
|
182
187
|
return yield axios_1.default.get(url, {
|
|
183
|
-
headers: this.makeHeaders(),
|
|
188
|
+
headers: Object.assign(Object.assign({}, this.makeHeaders()), (extraHeaders !== null && extraHeaders !== void 0 ? extraHeaders : {})),
|
|
184
189
|
});
|
|
185
190
|
}
|
|
186
191
|
catch (e) {
|