@plasmicapp/cli 0.1.293 → 0.1.295

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 (55) hide show
  1. package/dist/__mocks__/api.js +10 -6
  2. package/dist/__tests__/code-utils-spec.js +12 -12
  3. package/dist/__tests__/file-utils.spec.js +11 -11
  4. package/dist/__tests__/ftue-spec.js +7 -7
  5. package/dist/__tests__/project-api-token-spec.js +33 -33
  6. package/dist/__tests__/versioned-sync-spec.js +20 -20
  7. package/dist/actions/auth.d.ts +1 -1
  8. package/dist/actions/auth.js +3 -3
  9. package/dist/actions/fix-imports.js +3 -3
  10. package/dist/actions/info.js +1 -1
  11. package/dist/actions/init.js +28 -28
  12. package/dist/actions/localization-strings.js +34 -26
  13. package/dist/actions/project-token.d.ts +1 -1
  14. package/dist/actions/project-token.js +6 -4
  15. package/dist/actions/sync-components.js +29 -29
  16. package/dist/actions/sync-global-contexts.js +5 -5
  17. package/dist/actions/sync-global-variants.js +9 -9
  18. package/dist/actions/sync-icons.js +10 -10
  19. package/dist/actions/sync-images.js +20 -20
  20. package/dist/actions/sync-styles.js +4 -4
  21. package/dist/actions/sync.js +52 -48
  22. package/dist/actions/upload-bundle.js +4 -4
  23. package/dist/actions/watch.js +10 -6
  24. package/dist/api.d.ts +1 -1
  25. package/dist/api.js +1 -1
  26. package/dist/deps.js +2 -0
  27. package/dist/index.js +28 -24
  28. package/dist/lib.js +1 -0
  29. package/dist/migrations/0.1.28-tsToTsx.js +3 -3
  30. package/dist/migrations/migrations.d.ts +2 -2
  31. package/dist/migrations/migrations.js +12 -12
  32. package/dist/plasmic.schema.json +3 -2
  33. package/dist/utils/auth-utils.d.ts +2 -2
  34. package/dist/utils/auth-utils.js +8 -8
  35. package/dist/utils/checksum.js +2 -2
  36. package/dist/utils/code-utils.js +40 -32
  37. package/dist/utils/config-utils.d.ts +3 -3
  38. package/dist/utils/config-utils.js +5 -5
  39. package/dist/utils/envdetect.js +8 -8
  40. package/dist/utils/error.js +3 -2
  41. package/dist/utils/file-utils.js +3 -3
  42. package/dist/utils/get-context.js +20 -16
  43. package/dist/utils/help.js +2 -2
  44. package/dist/utils/lang-utils.d.ts +1 -1
  45. package/dist/utils/lang-utils.js +2 -1
  46. package/dist/utils/npm-utils.js +18 -16
  47. package/dist/utils/resolve-utils.js +11 -7
  48. package/dist/utils/semver.d.ts +2 -2
  49. package/dist/utils/semver.js +64 -35
  50. package/dist/utils/test-utils.js +9 -5
  51. package/package.json +5 -5
  52. package/src/actions/init.ts +2 -2
  53. package/src/actions/localization-strings.ts +34 -21
  54. package/src/index.ts +1 -1
  55. package/src/utils/config-utils.ts +3 -3
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -159,9 +163,9 @@ function genProjectMetaBundle(projectId) {
159
163
  function* getDeps(projects) {
160
164
  const queue = [...projects];
161
165
  while (queue.length > 0) {
162
- const curr = lang_utils_1.ensure(queue.shift());
166
+ const curr = (0, lang_utils_1.ensure)(queue.shift());
163
167
  for (const [projectId, version] of lodash_1.default.toPairs(curr.dependencies)) {
164
- const mockProject = lang_utils_1.ensure(getMockProject(projectId, "main", version));
168
+ const mockProject = (0, lang_utils_1.ensure)(getMockProject(projectId, "main", version));
165
169
  const projectMeta = mockProjectToProjectVersionMeta(mockProject);
166
170
  yield projectMeta;
167
171
  queue.push(projectMeta);
@@ -199,7 +203,7 @@ class PlasmicApi {
199
203
  const availableVersions = availableProjects.map((p) => p.version);
200
204
  const version = semver.maxSatisfying(availableVersions, proj.versionRange);
201
205
  if (version) {
202
- const mockProject = lang_utils_1.ensure(getMockProject(proj.projectId, proj.branchName, version));
206
+ const mockProject = (0, lang_utils_1.ensure)(getMockProject(proj.projectId, proj.branchName, version));
203
207
  const projectMeta = mockProjectToProjectVersionMeta(mockProject, proj.componentIdOrNames);
204
208
  results.projects.push(projectMeta);
205
209
  }
@@ -224,7 +228,7 @@ class PlasmicApi {
224
228
  throw new Error("Remember to call __addMockProject first!");
225
229
  }
226
230
  const maybeTokenPair = this.lastProjectIdsAndTokens.find((pair) => pair.projectId === projectId);
227
- const project = lang_utils_1.ensure(PROJECTS.find((p) => p.projectId === projectId));
231
+ const project = (0, lang_utils_1.ensure)(PROJECTS.find((p) => p.projectId === projectId));
228
232
  if (!((this.auth.user && this.auth.token) ||
229
233
  project.projectApiToken === (maybeTokenPair === null || maybeTokenPair === void 0 ? void 0 : maybeTokenPair.projectApiToken))) {
230
234
  throw new Error("No user+token and project API tokens don't match");
@@ -264,7 +264,7 @@ export const CodeSandboxDialogContent = observer(
264
264
  CodeSandboxDialogContentProps
265
265
  >
266
266
  );`;
267
- expect(code_utils_1.formatScript(code_utils_1.tsxToJsx(code), process.cwd()).trim()).toEqual(`
267
+ expect((0, code_utils_1.formatScript)((0, code_utils_1.tsxToJsx)(code), process.cwd()).trim()).toEqual(`
268
268
  // This is a skeleton starter React component generated by Plasmic.
269
269
  // @jsx helper
270
270
  import React from "react";
@@ -520,14 +520,14 @@ function _CodeSandboxDialogContent(props) {
520
520
  return null;
521
521
  }
522
522
  `;
523
- const configJson = file_utils_1.readFileText("./testData/fixImports_plasmic.json").toString();
523
+ const configJson = (0, file_utils_1.readFileText)("./testData/fixImports_plasmic.json").toString();
524
524
  const config = JSON.parse(configJson);
525
525
  const context = {
526
526
  config,
527
527
  cliArgs: {},
528
528
  };
529
- const fixImportContext = code_utils_1.mkFixImportContext(config);
530
- const replaced = code_utils_1.replaceImports(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, false, process.cwd());
529
+ const fixImportContext = (0, code_utils_1.mkFixImportContext)(config);
530
+ const replaced = (0, code_utils_1.replaceImports)(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, false, process.cwd());
531
531
  const expectedCode = `// This is a skeleton starter React component generated by Plasmic.
532
532
  import React, { ReactNode } from "react";
533
533
  import {
@@ -589,14 +589,14 @@ function _CodeSandboxDialogContent(props) {
589
589
  return null;
590
590
  }
591
591
  `;
592
- const configJson = file_utils_1.readFileText("./testData/fixImports_plasmic.json").toString();
592
+ const configJson = (0, file_utils_1.readFileText)("./testData/fixImports_plasmic.json").toString();
593
593
  const config = JSON.parse(configJson);
594
- const fixImportContext = code_utils_1.mkFixImportContext(config);
594
+ const fixImportContext = (0, code_utils_1.mkFixImportContext)(config);
595
595
  const context = {
596
596
  config,
597
597
  cliArgs: {},
598
598
  };
599
- const replaced = code_utils_1.replaceImports(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, true, process.cwd());
599
+ const replaced = (0, code_utils_1.replaceImports)(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, true, process.cwd());
600
600
  const expectedCode = `// This is a skeleton starter React component generated by Plasmic.
601
601
  import React, { ReactNode } from "react";
602
602
  import {
@@ -658,14 +658,14 @@ function _CodeSandboxDialogContent(props) {
658
658
  return null
659
659
  }
660
660
  `;
661
- const configJson = file_utils_1.readFileText("./testData/fixImports_plasmic.json").toString();
661
+ const configJson = (0, file_utils_1.readFileText)("./testData/fixImports_plasmic.json").toString();
662
662
  const config = JSON.parse(configJson);
663
- const fixImportContext = code_utils_1.mkFixImportContext(config);
663
+ const fixImportContext = (0, code_utils_1.mkFixImportContext)(config);
664
664
  const context = {
665
665
  config,
666
666
  cliArgs: {},
667
667
  };
668
- const replaced = code_utils_1.replaceImports(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, false, process.cwd());
668
+ const replaced = (0, code_utils_1.replaceImports)(context, code, "/tmp/CodeSandbox.tsx", fixImportContext, false, process.cwd());
669
669
  const expectedCode = `// This is a skeleton starter React component generated by Plasmic.
670
670
  import React, { ReactNode } from "react";
671
671
  import {
@@ -768,7 +768,7 @@ function PlasmicButton2(props: {}): React.ReactNode {
768
768
  export default PlasmicButton;
769
769
  /* prettier-ignore-end */
770
770
  `;
771
- expect(code_utils_1.tsxToJsx(input).trim()).toEqual(`
771
+ expect((0, code_utils_1.tsxToJsx)(input).trim()).toEqual(`
772
772
  /* eslint-disable */
773
773
  /* tslint:disable */
774
774
  /* prettier-ignore-start */
@@ -813,7 +813,7 @@ export default PlasmicButton;
813
813
  {"2" : "2}]
814
814
  */
815
815
  `;
816
- expect(code_utils_1.formatScript(input, process.cwd())).toEqual(`import React, { ReactNode } from "react";
816
+ expect((0, code_utils_1.formatScript)(input, process.cwd())).toEqual(`import React, { ReactNode } from "react";
817
817
  import "@plasmicapp/react-web/lib/plasmic.css";
818
818
 
819
819
  function PlasmicButton(props: {}): React.ReactNode {
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const file_utils_1 = require("../utils/file-utils");
4
4
  describe("defaultPagePath", () => {
5
5
  it("does nothing for react", () => {
6
- expect(file_utils_1.defaultPagePath({ config: { platform: "react" } }, "/index.tsx")).toBe("/index.tsx");
7
- expect(file_utils_1.defaultPagePath({ config: { platform: "react" } }, "/nested/index.tsx")).toBe("/nested/index.tsx");
6
+ expect((0, file_utils_1.defaultPagePath)({ config: { platform: "react" } }, "/index.tsx")).toBe("/index.tsx");
7
+ expect((0, file_utils_1.defaultPagePath)({ config: { platform: "react" } }, "/nested/index.tsx")).toBe("/nested/index.tsx");
8
8
  });
9
9
  it("handles gatsby pagesDir", () => {
10
- expect(file_utils_1.defaultPagePath({
10
+ expect((0, file_utils_1.defaultPagePath)({
11
11
  config: {
12
12
  platform: "gatsby",
13
13
  gatsbyConfig: { pagesDir: "../pages" },
14
14
  },
15
15
  }, "/index.tsx")).toBe("../pages/index.tsx");
16
- expect(file_utils_1.defaultPagePath({
16
+ expect((0, file_utils_1.defaultPagePath)({
17
17
  config: {
18
18
  platform: "gatsby",
19
19
  gatsbyConfig: { pagesDir: "../pages" },
@@ -21,19 +21,19 @@ describe("defaultPagePath", () => {
21
21
  }, "/nested/index.tsx")).toBe("../pages/nested/index.tsx");
22
22
  });
23
23
  it("handles nextjs pagesDir", () => {
24
- expect(file_utils_1.defaultPagePath({
24
+ expect((0, file_utils_1.defaultPagePath)({
25
25
  config: {
26
26
  platform: "nextjs",
27
27
  nextjsConfig: { pagesDir: "../pages" },
28
28
  },
29
29
  }, "/index.jsx")).toBe("../pages/index.jsx");
30
- expect(file_utils_1.defaultPagePath({
30
+ expect((0, file_utils_1.defaultPagePath)({
31
31
  config: {
32
32
  platform: "nextjs",
33
33
  nextjsConfig: { pagesDir: "../pages" },
34
34
  },
35
35
  }, "/index.tsx")).toBe("../pages/index.tsx");
36
- expect(file_utils_1.defaultPagePath({
36
+ expect((0, file_utils_1.defaultPagePath)({
37
37
  config: {
38
38
  platform: "nextjs",
39
39
  nextjsConfig: { pagesDir: "../pages" },
@@ -41,16 +41,16 @@ describe("defaultPagePath", () => {
41
41
  }, "/nested/index.tsx")).toBe("../pages/nested/index.tsx");
42
42
  });
43
43
  it("handles nextjs pagesDir using app/ directory ", () => {
44
- expect(file_utils_1.defaultPagePath({
44
+ expect((0, file_utils_1.defaultPagePath)({
45
45
  config: { platform: "nextjs", nextjsConfig: { pagesDir: "../app" } },
46
46
  }, "/index.jsx")).toBe("../app/page.jsx");
47
- expect(file_utils_1.defaultPagePath({
47
+ expect((0, file_utils_1.defaultPagePath)({
48
48
  config: { platform: "nextjs", nextjsConfig: { pagesDir: "../app" } },
49
49
  }, "/index.tsx")).toBe("../app/page.tsx");
50
- expect(file_utils_1.defaultPagePath({
50
+ expect((0, file_utils_1.defaultPagePath)({
51
51
  config: { platform: "nextjs", nextjsConfig: { pagesDir: "../app" } },
52
52
  }, "/nested/index.tsx")).toBe("../app/nested/page.tsx");
53
- expect(file_utils_1.defaultPagePath({
53
+ expect((0, file_utils_1.defaultPagePath)({
54
54
  config: { platform: "nextjs", nextjsConfig: { pagesDir: "../app" } },
55
55
  }, "/not-index.tsx")).toBe("../app/not-index/page.tsx");
56
56
  });
@@ -14,26 +14,26 @@ const sync_1 = require("../actions/sync");
14
14
  const fixtures_1 = require("../test-common/fixtures");
15
15
  // Reset the test project directory
16
16
  beforeEach(() => {
17
- fixtures_1.standardTestSetup(false);
17
+ (0, fixtures_1.standardTestSetup)(false);
18
18
  });
19
19
  afterEach(() => {
20
- fixtures_1.standardTestTeardown();
20
+ (0, fixtures_1.standardTestTeardown)();
21
21
  });
22
22
  describe("first-time-user-experience", () => {
23
23
  test("missing auth", () => __awaiter(void 0, void 0, void 0, function* () {
24
24
  // Trying to sync is going to fail without a valid auth file
25
25
  fixtures_1.tmpRepo.deletePlasmicAuth();
26
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow();
26
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow();
27
27
  }));
28
28
  test("no args", () => __awaiter(void 0, void 0, void 0, function* () {
29
29
  // No projects or components specified
30
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow();
30
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow();
31
31
  }));
32
32
  test("specify project", () => __awaiter(void 0, void 0, void 0, function* () {
33
33
  fixtures_1.opts.projects = ["projectId1"];
34
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
35
- fixtures_1.expectProject1Components();
34
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
35
+ (0, fixtures_1.expectProject1Components)();
36
36
  expect(fixtures_1.tmpRepo.checkFile("./src/DepComponent.tsx")).toBeFalsy();
37
- fixtures_1.expectProject1PlasmicJson();
37
+ (0, fixtures_1.expectProject1PlasmicJson)();
38
38
  }));
39
39
  });
@@ -14,10 +14,10 @@ const fixtures_1 = require("../test-common/fixtures");
14
14
  jest.mock("../api");
15
15
  // Reset the test project directory
16
16
  beforeEach(() => {
17
- fixtures_1.standardTestSetup(false);
17
+ (0, fixtures_1.standardTestSetup)(false);
18
18
  });
19
19
  afterEach(() => {
20
- fixtures_1.standardTestTeardown();
20
+ (0, fixtures_1.standardTestTeardown)();
21
21
  });
22
22
  function removeAuth() {
23
23
  fixtures_1.opts.auth = undefined;
@@ -27,88 +27,88 @@ function removeAuth() {
27
27
  describe("Project API tokens", () => {
28
28
  test("is filled in by auth'd user so that a second run does not need auth", () => __awaiter(void 0, void 0, void 0, function* () {
29
29
  fixtures_1.opts.projects = ["projectId1"];
30
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
31
- fixtures_1.expectProject1Components();
32
- fixtures_1.expectProject1PlasmicJson();
30
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
31
+ (0, fixtures_1.expectProject1Components)();
32
+ (0, fixtures_1.expectProject1PlasmicJson)();
33
33
  // Re-run, this time with no auth.
34
34
  removeAuth();
35
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
35
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
36
36
  }));
37
37
  test("can be passed in from command-line args", () => __awaiter(void 0, void 0, void 0, function* () {
38
38
  removeAuth();
39
39
  // Without specifying version.
40
40
  fixtures_1.opts.projects = ["projectId1:abc"];
41
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
41
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
42
42
  // Specifying version.
43
43
  fixtures_1.opts.projects = ["projectId1:abc@1.2.3"];
44
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
44
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
45
45
  // Wrong token (should fail).
46
46
  fixtures_1.opts.projects = ["projectId1:123"];
47
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
47
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
48
48
  }));
49
49
  test("is corrected by auth'd user if token was initially incorrect", () => __awaiter(void 0, void 0, void 0, function* () {
50
50
  fixtures_1.opts.projects = ["projectId1"];
51
51
  fixtures_1.tmpRepo.writePlasmicJson(Object.assign(Object.assign({}, fixtures_1.defaultPlasmicJson), { projects: [Object.assign(Object.assign({}, fixtures_1.project1Config), { projectApiToken: "blah" })] }));
52
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
53
- fixtures_1.expectProject1Components();
54
- fixtures_1.expectProject1PlasmicJson({ projectApiToken: true });
52
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
53
+ (0, fixtures_1.expectProject1Components)();
54
+ (0, fixtures_1.expectProject1PlasmicJson)({ projectApiToken: true });
55
55
  // Re-run, this time with no auth.
56
56
  removeAuth();
57
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
57
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
58
58
  }));
59
59
  test("is filled in by auth'd user if project exists but token was initially missing", () => __awaiter(void 0, void 0, void 0, function* () {
60
60
  fixtures_1.opts.projects = ["projectId1"];
61
61
  fixtures_1.tmpRepo.writePlasmicJson(Object.assign(Object.assign({}, fixtures_1.defaultPlasmicJson), { projects: [fixtures_1.project1Config] }));
62
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
63
- fixtures_1.expectProject1Components();
64
- fixtures_1.expectProject1PlasmicJson({ projectApiToken: true });
62
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
63
+ (0, fixtures_1.expectProject1Components)();
64
+ (0, fixtures_1.expectProject1PlasmicJson)({ projectApiToken: true });
65
65
  // Re-run, this time with no auth.
66
66
  removeAuth();
67
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("Unable to authenticate Plasmic. Please run 'plasmic auth' or check the projectApiTokens in your plasmic.json, and try again.");
67
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("Unable to authenticate Plasmic. Please run 'plasmic auth' or check the projectApiTokens in your plasmic.json, and try again.");
68
68
  }));
69
69
  test("when not available, should prompt for auth", () => __awaiter(void 0, void 0, void 0, function* () {
70
70
  fixtures_1.opts.projects = ["projectId1"];
71
71
  removeAuth();
72
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("Unable to authenticate");
72
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("Unable to authenticate");
73
73
  }));
74
74
  // TODO: Would be nice to eventually make this not fail outright but to prompt for auth.
75
75
  test("when incorrect, should fail", () => __awaiter(void 0, void 0, void 0, function* () {
76
76
  fixtures_1.opts.projects = ["projectId1"];
77
77
  removeAuth();
78
78
  fixtures_1.tmpRepo.writePlasmicJson(Object.assign(Object.assign({}, fixtures_1.defaultPlasmicJson), { projects: [Object.assign(Object.assign({}, fixtures_1.project1Config), { projectApiToken: "blah" })] }));
79
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
79
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("No user+token, and project API tokens don't match");
80
80
  }));
81
81
  test("works even if you have tokens for base but not deps", () => __awaiter(void 0, void 0, void 0, function* () {
82
82
  // Make project1 have a dependency.
83
- fixtures_1.standardTestSetup();
83
+ (0, fixtures_1.standardTestSetup)();
84
84
  fixtures_1.opts.projects = ["projectId1"];
85
85
  removeAuth();
86
86
  fixtures_1.tmpRepo.writePlasmicJson(Object.assign(Object.assign({}, fixtures_1.defaultPlasmicJson), { projects: [Object.assign(Object.assign({}, fixtures_1.project1Config), { projectApiToken: "abc" })] }));
87
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
88
- fixtures_1.expectProject1Components();
89
- fixtures_1.expectProjectAndDepPlasmicJson();
87
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
88
+ (0, fixtures_1.expectProject1Components)();
89
+ (0, fixtures_1.expectProjectAndDepPlasmicJson)();
90
90
  }));
91
91
  test("works even if dependency was determined to not need an update", () => __awaiter(void 0, void 0, void 0, function* () {
92
92
  // Make project1 have a dependency.
93
- fixtures_1.standardTestSetup();
93
+ (0, fixtures_1.standardTestSetup)();
94
94
  fixtures_1.opts.projects = ["projectId1"];
95
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
95
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
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
99
  fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3").version = "1.2.4";
100
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
100
+ yield expect((0, 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* () {
103
103
  fixtures_1.opts.projects = ["dependencyId1"];
104
104
  removeAuth();
105
105
  fixtures_1.tmpRepo.writePlasmicJson(Object.assign(Object.assign({}, fixtures_1.defaultPlasmicJson), { projects: [Object.assign(Object.assign({}, fixtures_1.project1Config), { projectApiToken: "abc" })] }));
106
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow("Unable to authenticate");
106
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow("Unable to authenticate");
107
107
  }));
108
108
  test("should use plasmic-loader.json for API tokens in loader mode", () => __awaiter(void 0, void 0, void 0, function* () {
109
109
  process.env.PLASMIC_LOADER = "1";
110
110
  fixtures_1.opts.projects = ["projectId1"];
111
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
111
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
112
112
  const loaderConfig = fixtures_1.tmpRepo.readPlasmicLoaderJson();
113
113
  expect(loaderConfig).toEqual({
114
114
  projects: [
@@ -121,27 +121,27 @@ describe("Project API tokens", () => {
121
121
  // Re-run, this time with no auth and no tokens in plasmic.json, only in plasmic-loader.json.
122
122
  removeAuth();
123
123
  fixtures_1.tmpRepo.writePlasmicJson(fixtures_1.defaultPlasmicJson);
124
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
124
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
125
125
  delete process.env["PLASMIC_LOADER"];
126
126
  }));
127
127
  test("works in PlasmicLoader mode even if root project was determined to not need an update", () => __awaiter(void 0, void 0, void 0, function* () {
128
128
  process.env.PLASMIC_LOADER = "1";
129
129
  // Make project1 have a dependency.
130
- fixtures_1.standardTestSetup();
130
+ (0, fixtures_1.standardTestSetup)();
131
131
  // Explicitly sync both - we had a bug writing back the plasmic-loader.json in this case.
132
132
  fixtures_1.opts.projects = ["projectId1", "dependencyId1"];
133
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
133
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
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
137
  fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3").version = "1.2.4";
138
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
138
+ yield expect((0, 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* () {
141
141
  process.env.PLASMIC_LOADER = "1";
142
142
  fixtures_1.opts.projects = ["projectId1"];
143
143
  removeAuth();
144
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow();
144
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow();
145
145
  delete process.env["PLASMIC_LOADER"];
146
146
  }));
147
147
  });
@@ -14,22 +14,22 @@ const fixtures_1 = require("../test-common/fixtures");
14
14
  jest.mock("../api");
15
15
  // Reset the test project directory
16
16
  beforeEach(() => {
17
- fixtures_1.standardTestSetup();
17
+ (0, fixtures_1.standardTestSetup)();
18
18
  });
19
19
  afterEach(() => {
20
20
  // Remove the temporary directory
21
21
  // TODO: Comment out to keep files for debugging
22
- fixtures_1.standardTestTeardown();
22
+ (0, fixtures_1.standardTestTeardown)();
23
23
  });
24
24
  describe("versioned-sync", () => {
25
25
  test("syncs non-recursive case", () => __awaiter(void 0, void 0, void 0, function* () {
26
26
  fixtures_1.opts.projects = ["projectId1"];
27
27
  fixtures_1.opts.nonRecursive = true;
28
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
29
- fixtures_1.expectProject1Components();
28
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
29
+ (0, fixtures_1.expectProject1Components)();
30
30
  expect(fixtures_1.tmpRepo.checkFile("./src/DepComponent.tsx")).toBeFalsy();
31
31
  // Check plasmic.json
32
- fixtures_1.expectProject1PlasmicJson();
32
+ (0, fixtures_1.expectProject1PlasmicJson)();
33
33
  }));
34
34
  test("syncs missing components", () => __awaiter(void 0, void 0, void 0, function* () {
35
35
  fixtures_1.opts.projects = ["projectId1"];
@@ -39,11 +39,11 @@ describe("versioned-sync", () => {
39
39
  const plasmicJson = fixtures_1.tmpRepo.readPlasmicJson();
40
40
  plasmicJson.projects.push(fixtures_1.project1Config);
41
41
  fixtures_1.tmpRepo.writePlasmicJson(plasmicJson);
42
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
42
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
43
43
  }));
44
44
  test("syncs down new names", () => __awaiter(void 0, void 0, void 0, function* () {
45
45
  fixtures_1.opts.projects = ["projectId1"];
46
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
46
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
47
47
  // Change component name server-side
48
48
  const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
49
49
  const buttonData = mockProject.components.find((c) => c.id === "buttonId");
@@ -51,7 +51,7 @@ describe("versioned-sync", () => {
51
51
  mockProject.version = "2.0.0";
52
52
  fixtures_1.mockApi.addMockProject(mockProject);
53
53
  // Try syncing again and see if things show up
54
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
54
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
55
55
  const plasmicJson = fixtures_1.tmpRepo.readPlasmicJson();
56
56
  const projectInConfig = plasmicJson.projects.find((p) => p.projectId === "projectId1");
57
57
  const componentInConfig = !!projectInConfig
@@ -62,13 +62,13 @@ describe("versioned-sync", () => {
62
62
  }));
63
63
  test("syncs latest", () => __awaiter(void 0, void 0, void 0, function* () {
64
64
  fixtures_1.opts.projects = ["projectId1"];
65
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
65
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
66
66
  // Change component version server-side
67
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
71
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
71
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
72
72
  const button = fixtures_1.mockApi.stringToMockComponent(fixtures_1.tmpRepo.getComponentFileContents("projectId1", "buttonId"));
73
73
  expect(button).toBeTruthy();
74
74
  expect(button === null || button === void 0 ? void 0 : button.name).toEqual("Button");
@@ -77,7 +77,7 @@ describe("versioned-sync", () => {
77
77
  test("syncs exact version", () => __awaiter(void 0, void 0, void 0, function* () {
78
78
  fixtures_1.opts.projects = ["projectId1"];
79
79
  fixtures_1.opts.nonRecursive = true;
80
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
80
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
81
81
  // Change component version server-side
82
82
  const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
83
83
  mockProject.version = "2.0.0";
@@ -89,11 +89,11 @@ describe("versioned-sync", () => {
89
89
  // Try syncing non-existent version
90
90
  plasmicJson.projects[0].version = "1.2.10"; // Doesn't exist
91
91
  fixtures_1.tmpRepo.writePlasmicJson(plasmicJson);
92
- yield expect(sync_1.sync(fixtures_1.opts)).rejects.toThrow();
92
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).rejects.toThrow();
93
93
  // Try syncing existing version
94
94
  plasmicJson.projects[0].version = "2.0.0"; // Doesn't exist
95
95
  fixtures_1.tmpRepo.writePlasmicJson(plasmicJson);
96
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
96
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
97
97
  const button = fixtures_1.mockApi.stringToMockComponent(fixtures_1.tmpRepo.getComponentFileContents("projectId1", "buttonId"));
98
98
  expect(button).toBeTruthy();
99
99
  expect(button === null || button === void 0 ? void 0 : button.name).toEqual("Button");
@@ -102,7 +102,7 @@ describe("versioned-sync", () => {
102
102
  test("syncs according to semver", () => __awaiter(void 0, void 0, void 0, function* () {
103
103
  fixtures_1.opts.projects = ["projectId1"];
104
104
  fixtures_1.opts.nonRecursive = true;
105
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
105
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
106
106
  // Change component version server-side
107
107
  const mockProject = fixtures_1.mockApi.getMockProject("projectId1", "main", "1.2.3");
108
108
  mockProject.version = "1.10.1";
@@ -113,7 +113,7 @@ describe("versioned-sync", () => {
113
113
  expect(plasmicJson.projects[0].components.length).toEqual(2);
114
114
  plasmicJson.projects[0].version = "^1.2.3";
115
115
  // Try syncing again and see if things show up
116
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
116
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
117
117
  const button = fixtures_1.mockApi.stringToMockComponent(fixtures_1.tmpRepo.getComponentFileContents("projectId1", "buttonId"));
118
118
  expect(button).toBeTruthy();
119
119
  expect(button === null || button === void 0 ? void 0 : button.name).toEqual("Button");
@@ -125,14 +125,14 @@ describe("recursive-sync", () => {
125
125
  // Should sync both Button+Container because of the dependency
126
126
  fixtures_1.opts.projects = ["projectId1"];
127
127
  fixtures_1.opts.nonRecursive = true;
128
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
129
- fixtures_1.expectProject1Components();
128
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
129
+ (0, fixtures_1.expectProject1Components)();
130
130
  expect(fixtures_1.tmpRepo.checkFile("./src/DepComponent.tsx")).toBeFalsy();
131
- fixtures_1.expectProject1PlasmicJson();
131
+ (0, fixtures_1.expectProject1PlasmicJson)();
132
132
  }));
133
133
  test("dependencies base case", () => __awaiter(void 0, void 0, void 0, function* () {
134
134
  fixtures_1.opts.projects = ["projectId1"];
135
- yield expect(sync_1.sync(fixtures_1.opts)).resolves.toBeUndefined();
135
+ yield expect((0, sync_1.sync)(fixtures_1.opts)).resolves.toBeUndefined();
136
136
  expect(fixtures_1.tmpRepo.checkFile("./src/Button.tsx")).toBeTruthy();
137
137
  expect(fixtures_1.tmpRepo.checkFile("./src/Container.tsx")).toBeTruthy();
138
138
  const depComponent = fixtures_1.mockApi.stringToMockComponent(fixtures_1.tmpRepo.getComponentFileContents("dependencyId1", "depComponentId"));
@@ -140,6 +140,6 @@ describe("recursive-sync", () => {
140
140
  expect(depComponent === null || depComponent === void 0 ? void 0 : depComponent.name).toEqual("DepComponent");
141
141
  expect(depComponent === null || depComponent === void 0 ? void 0 : depComponent.version).toEqual("2.3.4");
142
142
  // Check plasmic.json
143
- fixtures_1.expectProjectAndDepPlasmicJson();
143
+ (0, fixtures_1.expectProjectAndDepPlasmicJson)();
144
144
  }));
145
145
  });
@@ -1,4 +1,4 @@
1
- export declare type AuthArgs = {
1
+ export type AuthArgs = {
2
2
  host: string;
3
3
  baseDir?: string;
4
4
  check?: boolean;
@@ -15,7 +15,7 @@ const auth_utils_1 = require("../utils/auth-utils");
15
15
  const error_1 = require("../utils/error");
16
16
  function checkCredentials() {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- if (yield auth_utils_1.getCurrentAuth()) {
18
+ if (yield (0, auth_utils_1.getCurrentAuth)()) {
19
19
  deps_1.logger.info("Plasmic credentials are ok.");
20
20
  return;
21
21
  }
@@ -25,7 +25,7 @@ function checkCredentials() {
25
25
  exports.checkCredentials = checkCredentials;
26
26
  function getEmail() {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- const authCreds = yield auth_utils_1.getCurrentAuth();
28
+ const authCreds = yield (0, auth_utils_1.getCurrentAuth)();
29
29
  if (authCreds) {
30
30
  deps_1.logger.info(authCreds.user);
31
31
  return authCreds.user;
@@ -41,7 +41,7 @@ function auth(args) {
41
41
  if (args.email) {
42
42
  return getEmail();
43
43
  }
44
- return auth_utils_1.startAuth(args);
44
+ return (0, auth_utils_1.startAuth)(args);
45
45
  });
46
46
  }
47
47
  exports.auth = auth;
@@ -17,9 +17,9 @@ function fixImports(opts) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  if (!opts.baseDir)
19
19
  opts.baseDir = process.cwd();
20
- const context = yield get_context_1.getContext(opts, { enableSkipAuth: true });
21
- yield config_utils_1.updateConfig(context, context.config, opts.baseDir);
22
- yield code_utils_1.fixAllImportStatements(context, opts.baseDir);
20
+ const context = yield (0, get_context_1.getContext)(opts, { enableSkipAuth: true });
21
+ yield (0, config_utils_1.updateConfig)(context, context.config, opts.baseDir);
22
+ yield (0, code_utils_1.fixAllImportStatements)(context, opts.baseDir);
23
23
  });
24
24
  }
25
25
  exports.fixImports = fixImports;
@@ -15,7 +15,7 @@ const get_context_1 = require("../utils/get-context");
15
15
  function printProjectInfo(opts) {
16
16
  var _a, _b;
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- let context = yield get_context_1.getContext(opts);
18
+ let context = yield (0, get_context_1.getContext)(opts);
19
19
  const results = yield Promise.all(opts.projects.map((p) => __awaiter(this, void 0, void 0, function* () { return yield context.api.projectMeta(p); })));
20
20
  for (const meta of results) {
21
21
  deps_1.logger.info(`Id: ${meta.id}`);