ember-tribe 2.6.5 → 2.6.7

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/README.md CHANGED
@@ -970,6 +970,21 @@ async uploadFile(file) {
970
970
 
971
971
  ---
972
972
 
973
+ ## Deploying to Junction (Self-Hosted)
974
+
975
+ After building your Ember app, run `php-dist` to prepare the `dist/` folder for PHP middleware:
976
+
977
+ ```bash
978
+ ember build -prod
979
+ node php-dist
980
+ ```
981
+
982
+ This reads `dist/index.html`, injects PHP includes (`_init.php`, `_head.php`, `_head_footer.php`, `_body_footer.php`), strips `<title>` and `<meta name="description">`, and writes `dist/index.php`.
983
+
984
+ You can then upload the `dist/` folder to [Junction (open source)](http://localhost:12002) and view your app at **http://localhost:12004**.
985
+
986
+ ---
987
+
973
988
  ## Best Practices
974
989
 
975
990
  1. **Module Access**: Remember to use `modules.field_name` for backend fields
@@ -109,7 +109,7 @@ function parseHbsFile(filePath) {
109
109
  const helpers = [...helpersSet];
110
110
 
111
111
  const modifiersSet = new Set(
112
- [...src.matchAll(/\{\{([\w-]+-modifier|autofocus|tooltip|play-when|[\w-]+)\s/g)]
112
+ [...src.matchAll(/\{\{([\w-]+-modifier|tooltip|[\w-]+)\s/g)]
113
113
  .map(([, name]) => name)
114
114
  .filter((n) => !helpers.includes(n) && !builtinHelpers.has(n))
115
115
  );
@@ -199,6 +199,65 @@ function buildTypes(routes, components) {
199
199
  return [...typeMap.entries()].map(([slug, used_in]) => ({ slug, used_in }));
200
200
  }
201
201
 
202
+ function compactJSON(value, indent = 2) {
203
+ function isLeafArray(arr) {
204
+ if (!Array.isArray(arr) || arr.length === 0) return false;
205
+ return arr.every((item) => {
206
+ if (typeof item === 'string') return true;
207
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
208
+ const keys = Object.keys(item);
209
+ return keys.length === 1 && typeof item[keys[0]] === 'string';
210
+ }
211
+ return false;
212
+ });
213
+ }
214
+
215
+ function serialize(val, depth) {
216
+ const pad = ' '.repeat(indent * depth);
217
+ const childPad = ' '.repeat(indent * (depth + 1));
218
+
219
+ if (val === null) return 'null';
220
+ if (typeof val !== 'object') return JSON.stringify(val);
221
+
222
+ if (Array.isArray(val)) {
223
+ if (val.length === 0) return '[]';
224
+ if (isLeafArray(val)) {
225
+ const items = val.map((item) => {
226
+ if (typeof item === 'string') return JSON.stringify(item);
227
+ const k = Object.keys(item)[0];
228
+ return `{ ${JSON.stringify(k)}: ${JSON.stringify(item[k])} }`;
229
+ });
230
+ return '[' + items.join(', ') + ']';
231
+ }
232
+ const items = val.map((item) => childPad + serialize(item, depth + 1));
233
+ return '[\n' + items.join(',\n') + '\n' + pad + ']';
234
+ }
235
+
236
+ const keys = Object.keys(val);
237
+ if (keys.length === 0) return '{}';
238
+ const entries = keys.map((k) => childPad + JSON.stringify(k) + ': ' + serialize(val[k], depth + 1));
239
+ return '{\n' + entries.join(',\n') + '\n' + pad + '}';
240
+ }
241
+
242
+ return serialize(value, 0);
243
+ }
244
+
245
+ function stripEmpty(obj) {
246
+ if (Array.isArray(obj)) {
247
+ return obj.map(stripEmpty);
248
+ }
249
+ if (obj !== null && typeof obj === 'object') {
250
+ const out = {};
251
+ for (const [k, v] of Object.entries(obj)) {
252
+ if (Array.isArray(v) && v.length === 0) continue;
253
+ if (v !== null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length === 0) continue;
254
+ out[k] = stripEmpty(v);
255
+ }
256
+ return out;
257
+ }
258
+ return obj;
259
+ }
260
+
202
261
  function mergeByKey(existing, scanned, key) {
203
262
  const existingMap = new Map(existing.map((e) => [e[key], e]));
204
263
  const scannedMap = new Map(scanned.map((s) => [s[key], s]));
@@ -217,11 +276,11 @@ function mergeByKey(existing, scanned, key) {
217
276
  const outputFile = path.join(configDir, 'storylang.json');
218
277
 
219
278
  if (!fs.existsSync(appDir)) {
220
- console.error(`Could not find app/ directory at ${appDir}. Make sure you are running from the root of your Ember project.`);
279
+ console.error(`Could not find app/ directory at ${appDir}. Make sure you are running from the folder of your Ember project.`);
221
280
  process.exit(1);
222
281
  }
223
282
 
224
- console.log('📖 storylang — scanning project files…\n');
283
+ console.log('Storylang — scanning project files…\n');
225
284
 
226
285
  const components = buildComponents(appDir);
227
286
  const routes = buildRoutes(appDir);
@@ -245,7 +304,7 @@ function mergeByKey(existing, scanned, key) {
245
304
  };
246
305
 
247
306
  if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
248
- fs.writeFileSync(outputFile, JSON.stringify(merged, null, 2) + '\n', 'utf8');
307
+ fs.writeFileSync(outputFile, compactJSON(stripEmpty(merged)) + '\n', 'utf8');
249
308
 
250
309
  console.log(`✅ config/storylang.json updated`);
251
310
  console.log(` routes: ${routes.length}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-tribe",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "description": "The default blueprint for using Tribe API and Junction within EmberJS.",
5
5
  "keywords": [
6
6
  "ember-addon"