@plasmicapp/cli 0.1.306 → 0.1.308

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.306",
3
+ "version": "0.1.308",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -78,5 +78,5 @@
78
78
  "wrap-ansi": "^7.0.0",
79
79
  "yargs": "^15.4.1"
80
80
  },
81
- "gitHead": "cd709d627ae388ad77010119787ecef6d555362b"
81
+ "gitHead": "bf12f2268d3e2794698bee0996d4e2008b6827c5"
82
82
  }
@@ -1,6 +1,13 @@
1
+ import { promises as fs } from "fs";
1
2
  import { keyBy, snakeCase } from "lodash";
3
+ import path from "path";
2
4
  import { CommonArgs } from "..";
3
- import { ComponentBundle, PlasmicApi, ProjectBundle } from "../api";
5
+ import { PlasmicApi, ProjectBundle } from "../api";
6
+ import {
7
+ fixAllImportStatements,
8
+ formatAsLocal,
9
+ maybeConvertTsxToJsx,
10
+ } from "../utils/code-utils";
4
11
  import {
5
12
  CodeConfig,
6
13
  I18NConfig,
@@ -11,27 +18,17 @@ import {
11
18
  } from "../utils/config-utils";
12
19
  import { getContext, getCurrentOrDefaultAuth } from "../utils/get-context";
13
20
  import { tuple } from "../utils/lang-utils";
14
- import {
15
- fixAllImportStatements,
16
- formatAsLocal,
17
- maybeConvertTsxToJsx,
18
- } from "../utils/code-utils";
19
- import { promises as fs, write } from "fs";
20
- import path from "path";
21
21
  import { DEFAULT_GLOBAL_CONTEXTS_NAME } from "./sync-global-contexts";
22
22
  import { ensureImageAssetContents } from "./sync-images";
23
- import { logger } from "../deps";
24
23
 
25
24
  export interface ExportArgs extends CommonArgs {
26
25
  projects: readonly string[];
27
26
  platform: "" | "react" | "nextjs" | "gatsby";
28
27
  codeLang: "" | "ts" | "js";
29
28
  styleScheme: "" | "css" | "css-modules";
30
- imagesScheme: "" | "inlined" | "files" | "public-files";
31
- imagesPublicDir: string;
32
- imagesPublicUrlPrefix: string;
33
- i18nKeyScheme: "" | I18NConfig["keyScheme"];
34
- i18nTagPrefix: "" | I18NConfig["tagPrefix"];
29
+ imagesScheme: "" | "inlined" | "files";
30
+ i18NKeyScheme: "" | I18NConfig["keyScheme"];
31
+ i18NTagPrefix: "" | I18NConfig["tagPrefix"];
35
32
 
36
33
  skipFormatting?: boolean;
37
34
 
@@ -39,6 +36,9 @@ export interface ExportArgs extends CommonArgs {
39
36
  }
40
37
 
41
38
  export async function exportProjectsCli(opts: ExportArgs): Promise<void> {
39
+ if (!opts.outDir) {
40
+ opts.outDir = "./";
41
+ }
42
42
  if (!opts.baseDir) opts.baseDir = process.cwd();
43
43
  let configFile =
44
44
  opts.config || findConfigFile(opts.baseDir, { traverseParents: true });
@@ -81,8 +81,8 @@ export async function exportProjectsCli(opts: ExportArgs): Promise<void> {
81
81
  codeOpts: { lang: opts.codeLang || "ts" },
82
82
  stylesOpts: { scheme: opts.styleScheme || "css-modules" },
83
83
  imageOpts: { scheme: opts.imagesScheme || "files" },
84
- i18nOpts: opts.i18nKeyScheme
85
- ? { keyScheme: opts.i18nKeyScheme, tagPrefix: opts.i18nTagPrefix }
84
+ i18nOpts: opts.i18NKeyScheme
85
+ ? { keyScheme: opts.i18NKeyScheme, tagPrefix: opts.i18NTagPrefix }
86
86
  : undefined,
87
87
  });
88
88
 
@@ -152,8 +152,6 @@ export async function exportProjectsCli(opts: ExportArgs): Promise<void> {
152
152
  },
153
153
  images: {
154
154
  scheme: opts.imagesScheme || "files",
155
- publicDir: opts.imagesPublicDir,
156
- publicUrlPrefix: opts.imagesPublicUrlPrefix,
157
155
  },
158
156
  style: {
159
157
  scheme: opts.styleScheme || "css-modules",
package/src/index.ts CHANGED
@@ -314,12 +314,12 @@ yargs
314
314
  .option("code-lang", getYargsOption("codeLang"))
315
315
  .option("code-scheme", getYargsOption("codeScheme"))
316
316
  .option("style-scheme", getYargsOption("styleScheme"))
317
- .option("images-scheme", getYargsOption("imagesScheme"))
318
- .option("images-public-dir", getYargsOption("imagesPublicDir"))
319
- .option(
320
- "images-public-url-prefix",
321
- getYargsOption("imagesPublicUrlPrefix")
322
- )
317
+ .option("images-scheme", {
318
+ describe:
319
+ "How to reference used images in designs; either `inlined`, which puts base64-encoded images directly into the React component files, or `files`, which puts images on disk and imports them from component files.",
320
+ type: "string",
321
+ choices: ["inlined", "files"],
322
+ })
323
323
  .option("i18n-key-scheme", getLocalizationYargs("key-scheme"))
324
324
  .option("i18n-tag-prefix", getLocalizationYargs("tag-prefix")),
325
325
  (argv) => handleError(exportProjectsCli(argv))
package/src/lib.ts CHANGED
@@ -12,3 +12,7 @@ export {
12
12
  localizationStrings,
13
13
  LocalizationStringsArgs,
14
14
  } from "./actions/localization-strings";
15
+ export {
16
+ exportProjectsCli as exportProjects,
17
+ ExportArgs,
18
+ } from "./actions/export";
@@ -52,7 +52,7 @@ export const formatAsLocal = (
52
52
  // a better solution, like maybe letting user specify a prettier config
53
53
  // file in plasmic.json
54
54
  // const opts = resolveConfig.sync(baseDir) || defaultOpts;
55
- const opts = { ...defaultOpts };
55
+ const opts: Options = { ...defaultOpts, pluginSearchDirs: false };
56
56
  opts.filepath = filePath;
57
57
 
58
58
  // Running Prettier multiple times may actually yield different results!