@plasmicapp/cli 0.1.319 → 0.1.320

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.
@@ -6,7 +6,7 @@ export declare function getCliVersion(): string;
6
6
  */
7
7
  export declare function checkEngineStrict(): boolean;
8
8
  export declare function getParsedPackageJson(): any;
9
- export declare function findInstalledVersion(config: PlasmicConfig, baseDir: string, pkg: string): any;
9
+ export declare function findInstalledVersion(config: PlasmicConfig, baseDir: string, pkg: string): string | undefined;
10
10
  /**
11
11
  * Detects if the cli is globally installed. `rootDir` is the folder
12
12
  * where plasmic.json is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.319",
3
+ "version": "0.1.320",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -83,5 +83,5 @@
83
83
  "wrap-ansi": "^7.0.0",
84
84
  "yargs": "^15.4.1"
85
85
  },
86
- "gitHead": "6db50a6b3e9ffd747e4a6521b42fcc0a8f32e97c"
86
+ "gitHead": "ab6157931bff1d2a253ee36b408f79cf92b6af9c"
87
87
  }
@@ -210,14 +210,16 @@ export async function sync(
210
210
 
211
211
  const projectSyncParams = projectWithVersion.length
212
212
  ? projectWithVersion
213
- : context.config.projects.map((p) => ({
214
- projectId: p.projectId,
215
- branchName: p.projectBranchName ?? "main",
216
- versionRange: p.version,
217
- componentIdOrNames: undefined, // Get all components!
218
- projectApiToken: p.projectApiToken,
219
- indirect: !!p.indirect,
220
- }));
213
+ : context.config.projects
214
+ .filter((p) => !p.indirect)
215
+ .map((p) => ({
216
+ projectId: p.projectId,
217
+ branchName: p.projectBranchName ?? "main",
218
+ versionRange: p.version,
219
+ componentIdOrNames: undefined, // Get all components!
220
+ projectApiToken: p.projectApiToken,
221
+ indirect: !!p.indirect,
222
+ }));
221
223
 
222
224
  // Short-circuit if nothing to sync
223
225
  if (projectSyncParams.length === 0) {
@@ -401,13 +403,18 @@ async function checkExternalPkgs(
401
403
  opts: SyncArgs,
402
404
  pkgs: string[]
403
405
  ) {
404
- const missingPkgs = pkgs.filter((pkg) => {
405
- const installedPkg = findInstalledVersion(context.config, baseDir, pkg);
406
- return !installedPkg;
406
+ const missingPkgs = pkgs.filter((pkgSpec) => {
407
+ const [pkg, version] = pkgSpec.split("@");
408
+ const installedVersion = findInstalledVersion(context.config, baseDir, pkg);
409
+ if (version) {
410
+ return version !== installedVersion;
411
+ } else {
412
+ return !installedVersion;
413
+ }
407
414
  });
408
415
  if (missingPkgs.length > 0) {
409
416
  const upgrade = await confirmWithUser(
410
- `The following packages aren't installed but are required by some projects, would you like to install them? ${missingPkgs.join(
417
+ `The following packages aren't installed or are outdated, but are required by some projects; would you like to install them? ${missingPkgs.join(
411
418
  ", "
412
419
  )}`,
413
420
  opts.yes
@@ -215,7 +215,9 @@ export function createProjectConfig(base: {
215
215
  projectId: base.projectId,
216
216
  projectApiToken: base.projectApiToken,
217
217
  projectName: base.projectName,
218
- version: base.version,
218
+ // Indirect dependencies will have an explicit base.version but
219
+ // we don't actually want to pin to that version in plasmic.json
220
+ version: base.indirect ? ">0.0.0" : base.version,
219
221
  cssFilePath: base.cssFilePath,
220
222
  components: [],
221
223
  icons: [],
@@ -44,7 +44,7 @@ export function findInstalledVersion(
44
44
  config: PlasmicConfig,
45
45
  baseDir: string,
46
46
  pkg: string
47
- ) {
47
+ ): string | undefined {
48
48
  const pm = detectPackageManager(config, baseDir);
49
49
  try {
50
50
  if (pm === "yarn2") {
@@ -74,8 +74,10 @@ export function findInstalledVersion(
74
74
  } else if (pm === "pnpm") {
75
75
  const output = execSync(`pnpm list --json ${pkg}`).toString().trim();
76
76
  const info = JSON.parse(output);
77
- return info?.dependencies?.[pkg]?.version ||
78
- info?.[0]?.dependencies?.[pkg]?.version;
77
+ return (
78
+ info?.dependencies?.[pkg]?.version ||
79
+ info?.[0]?.dependencies?.[pkg]?.version
80
+ );
79
81
  } else {
80
82
  // Unknown package manager (e.g. pnpm).
81
83
  const output = execSync(`npm list --json ${pkg}`).toString().trim();