@plasmicapp/cli 0.1.226 → 0.1.228

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.
@@ -87,6 +87,11 @@ function syncProjectImageAssets(context, projectId, branchName, version, imageBu
87
87
  });
88
88
  }
89
89
  exports.syncProjectImageAssets = syncProjectImageAssets;
90
+ function getImagePublicUrl(context, asset) {
91
+ return (lang_utils_1.ensure(context.config.images.publicUrlPrefix) +
92
+ (lang_utils_1.ensure(context.config.images.publicUrlPrefix).endsWith("/") ? "" : "/") +
93
+ upath_1.default.relative(lang_utils_1.ensure(context.config.images.publicDir), asset.filePath));
94
+ }
90
95
  const RE_ASSETCSSREF_ALL = /var\(--image-([^\)]+)\)/g;
91
96
  function fixComponentCssReferences(context, fixImportContext, cssFilePath) {
92
97
  return __awaiter(this, void 0, void 0, function* () {
@@ -98,11 +103,7 @@ function fixComponentCssReferences(context, fixImportContext, cssFilePath) {
98
103
  const asset = fixImportContext.images[assetId];
99
104
  if (asset) {
100
105
  return context.config.images.scheme === "public-files"
101
- ? `url("${lang_utils_1.ensure(context.config.images.publicUrlPrefix) +
102
- (lang_utils_1.ensure(context.config.images.publicUrlPrefix).endsWith("/")
103
- ? ""
104
- : "/") +
105
- upath_1.default.relative(lang_utils_1.ensure(context.config.images.publicDir), asset.filePath)}")`
106
+ ? `url("${getImagePublicUrl(context, asset)}")`
106
107
  : `url("./${upath_1.default.relative(upath_1.default.dirname(cssFilePath), asset.filePath)}")`;
107
108
  }
108
109
  else {
@@ -122,7 +123,7 @@ function fixComponentImagesReferences(context, fixImportContext, renderModuleFil
122
123
  const newContent = prevContent.replace(RE_ASSETTSXREF_ALL, (sub, assetId) => {
123
124
  const asset = fixImportContext.images[assetId];
124
125
  if (asset) {
125
- 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));
126
+ return getImagePublicUrl(context, asset);
126
127
  }
127
128
  else {
128
129
  return sub;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.226",
3
+ "version": "0.1.228",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@babel/preset-typescript": "^7.12.1",
23
- "@plasmicapp/react-web": "0.2.170",
23
+ "@plasmicapp/react-web": "0.2.171",
24
24
  "@types/findup-sync": "^2.0.2",
25
25
  "@types/glob": "^7.1.3",
26
26
  "@types/inquirer": "^6.5.0",
@@ -77,5 +77,5 @@
77
77
  "wrap-ansi": "^7.0.0",
78
78
  "yargs": "^15.4.1"
79
79
  },
80
- "gitHead": "53959d3877857b2ef233711e5d5ba60d14b0c7d8"
80
+ "gitHead": "d2c2fb1d1c72dfc8c852b9a3f624bf3cca2e35d5"
81
81
  }
@@ -6,6 +6,7 @@ import { FixImportContext } from "../utils/code-utils";
6
6
  import {
7
7
  getOrAddProjectConfig,
8
8
  getOrAddProjectLock,
9
+ ImageConfig,
9
10
  PlasmicContext,
10
11
  } from "../utils/config-utils";
11
12
  import {
@@ -124,6 +125,14 @@ export async function syncProjectImageAssets(
124
125
  );
125
126
  }
126
127
 
128
+ function getImagePublicUrl(context: PlasmicContext, asset: ImageConfig) {
129
+ return (
130
+ ensure(context.config.images.publicUrlPrefix) +
131
+ (ensure(context.config.images.publicUrlPrefix).endsWith("/") ? "" : "/") +
132
+ path.relative(ensure(context.config.images.publicDir), asset.filePath)
133
+ );
134
+ }
135
+
127
136
  const RE_ASSETCSSREF_ALL = /var\(--image-([^\)]+)\)/g;
128
137
  export async function fixComponentCssReferences(
129
138
  context: PlasmicContext,
@@ -139,16 +148,7 @@ export async function fixComponentCssReferences(
139
148
  const asset = fixImportContext.images[assetId];
140
149
  if (asset) {
141
150
  return context.config.images.scheme === "public-files"
142
- ? `url("${
143
- ensure(context.config.images.publicUrlPrefix) +
144
- (ensure(context.config.images.publicUrlPrefix).endsWith("/")
145
- ? ""
146
- : "/") +
147
- path.relative(
148
- ensure(context.config.images.publicDir),
149
- asset.filePath
150
- )
151
- }")`
151
+ ? `url("${getImagePublicUrl(context, asset)}")`
152
152
  : `url("./${path.relative(
153
153
  path.dirname(cssFilePath),
154
154
  asset.filePath
@@ -173,11 +173,7 @@ export async function fixComponentImagesReferences(
173
173
  const newContent = prevContent.replace(RE_ASSETTSXREF_ALL, (sub, assetId) => {
174
174
  const asset = fixImportContext.images[assetId];
175
175
  if (asset) {
176
- return path.join(
177
- "/",
178
- ensure(context.config.images.publicUrlPrefix),
179
- path.relative(ensure(context.config.images.publicDir), asset.filePath)
180
- );
176
+ return getImagePublicUrl(context, asset);
181
177
  } else {
182
178
  return sub;
183
179
  }