@geekron/strapi 0.2.5 → 0.2.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.
@@ -20648,110 +20648,14 @@ var init_App = __esm(() => {
20648
20648
  // admin/src/index.ts
20649
20649
  var exports_src = {};
20650
20650
  __export(exports_src, {
20651
+ handlerBootstrap: () => handlerBootstrap,
20651
20652
  default: () => src_default
20652
20653
  });
20653
20654
  module.exports = __toCommonJS(exports_src);
20654
20655
 
20655
- // admin/src/boot/handle-missing-translations.ts
20656
- function extractTranslationInfo(logMessage) {
20657
- const regex = /Missing message: "([^"]+)"[^,]+, using default message \(([^)]+)\)/;
20658
- const match = logMessage.match(regex);
20659
- if (match) {
20660
- return {
20661
- messageId: match[1],
20662
- defaultMessage: match[2]
20663
- };
20664
- }
20665
- return null;
20666
- }
20667
- var missTranslations = {};
20668
- var handleMissingTranslations = (message) => {
20669
- const info = extractTranslationInfo(message);
20670
- if (info?.messageId)
20671
- missTranslations[info.messageId] = info.defaultMessage;
20672
- console.log(JSON.stringify(missTranslations));
20673
- };
20674
- var originalError = console.error;
20675
- var originalWarn = () => {};
20676
- console.warn = (..._args) => {
20677
- originalWarn();
20678
- };
20679
- console.error = (error) => {
20680
- try {
20681
- if (error?.message?.includes("MISSING_TRANSLATION")) {
20682
- handleMissingTranslations(error.message);
20683
- } else {
20684
- originalError(error);
20685
- }
20686
- } catch (error2) {
20687
- originalError(error2);
20688
- }
20689
- };
20690
-
20691
- // admin/src/boot/remove-links.ts
20692
- function waitForLi(href, callback) {
20693
- const findLi = () => {
20694
- const anchor = document.querySelector(`li a[href="${href}"]`);
20695
- if (anchor) {
20696
- const li = anchor.closest("li");
20697
- if (li)
20698
- return li;
20699
- }
20700
- return null;
20701
- };
20702
- setInterval(() => {
20703
- const initial = findLi();
20704
- if (initial) {
20705
- callback(initial);
20706
- return;
20707
- }
20708
- });
20709
- }
20710
- function waitForDD(href, callback) {
20711
- const findDD = () => {
20712
- const anchor = document.querySelector(`div a[href="${href}"]`);
20713
- if (anchor) {
20714
- const dd = anchor.closest("div");
20715
- if (dd)
20716
- return dd;
20717
- }
20718
- return null;
20719
- };
20720
- setInterval(() => {
20721
- const initial = findDD();
20722
- if (initial) {
20723
- callback(initial);
20724
- return;
20725
- }
20726
- });
20727
- }
20728
- var removeLinks = () => {
20729
- const hrefs = [
20730
- "/admin/settings/purchase-content-history",
20731
- "/admin/settings/plugins/purchase-content-releases",
20732
- "/admin/settings/purchase-review-workflows",
20733
- "/admin/settings/purchase-single-sign-on",
20734
- "/admin/settings/purchase-audit-logs"
20735
- ];
20736
- hrefs.forEach((href) => {
20737
- waitForLi(href, (li) => {
20738
- const parent = li.parentNode;
20739
- parent.removeChild(li);
20740
- });
20741
- });
20742
- const ddHrefs = ["https://strapi.io/pricing-self-hosted"];
20743
- ddHrefs.forEach((href) => {
20744
- waitForDD(href, (dd) => {
20745
- const parent = dd.parentNode;
20746
- parent.removeChild(dd);
20747
- });
20748
- });
20749
- };
20750
-
20751
20656
  // admin/src/bootstrap.ts
20752
20657
  var bootstrap = (_app) => {
20753
20658
  console.log("website admin plugin: bootstrap");
20754
- removeLinks();
20755
20659
  };
20756
20660
  var bootstrap_default = bootstrap;
20757
20661
 
@@ -46829,29 +46733,32 @@ function findItemDeep(items, itemId) {
46829
46733
  return;
46830
46734
  }
46831
46735
  function removeItem(items, id) {
46832
- const newItems = [];
46833
- for (const item of items) {
46834
- if (item.id === id) {
46835
- continue;
46836
- }
46736
+ return items.filter((item) => item.id !== id).map((item) => {
46837
46737
  if (item.children.length) {
46838
- item.children = removeItem(item.children, id);
46738
+ return {
46739
+ ...item,
46740
+ children: removeItem(item.children, id)
46741
+ };
46839
46742
  }
46840
- newItems.push(item);
46841
- }
46842
- return newItems;
46743
+ return item;
46744
+ });
46843
46745
  }
46844
46746
  function setProperty(items, id, property, setter) {
46845
- for (const item of items) {
46747
+ return items.map((item) => {
46846
46748
  if (item.id === id) {
46847
- item[property] = setter(item[property]);
46848
- continue;
46749
+ return {
46750
+ ...item,
46751
+ [property]: setter(item[property])
46752
+ };
46849
46753
  }
46850
46754
  if (item.children.length) {
46851
- item.children = setProperty(item.children, id, property, setter);
46755
+ return {
46756
+ ...item,
46757
+ children: setProperty(item.children, id, property, setter)
46758
+ };
46852
46759
  }
46853
- }
46854
- return [...items];
46760
+ return item;
46761
+ });
46855
46762
  }
46856
46763
  function countChildren(items, count = 0) {
46857
46764
  return items.reduce((acc, { children }) => {
@@ -50211,6 +50118,105 @@ var register = (app) => {
50211
50118
  };
50212
50119
  var register_default = register;
50213
50120
 
50121
+ // admin/src/boot/handle-missing-translations.ts
50122
+ function extractTranslationInfo(logMessage) {
50123
+ const regex2 = /Missing message: "([^"]+)"[^,]+, using default message \(([^)]+)\)/;
50124
+ const match = logMessage.match(regex2);
50125
+ if (match) {
50126
+ return {
50127
+ messageId: match[1],
50128
+ defaultMessage: match[2]
50129
+ };
50130
+ }
50131
+ return null;
50132
+ }
50133
+ var missTranslations = {};
50134
+ var handleMissingTranslations = () => {
50135
+ const originalError = console.error;
50136
+ const originalWarn = () => {};
50137
+ console.warn = (..._args) => {
50138
+ originalWarn();
50139
+ };
50140
+ console.error = (error) => {
50141
+ try {
50142
+ if (error?.message?.includes("MISSING_TRANSLATION")) {
50143
+ const info = extractTranslationInfo(error.message);
50144
+ if (info?.messageId)
50145
+ missTranslations[info.messageId] = info.defaultMessage;
50146
+ console.log(JSON.stringify(missTranslations));
50147
+ } else {
50148
+ originalError(error);
50149
+ }
50150
+ } catch (error2) {
50151
+ originalError(error2);
50152
+ }
50153
+ };
50154
+ };
50155
+ // admin/src/boot/remove-links.ts
50156
+ function waitForLi(href, callback) {
50157
+ const findLi = () => {
50158
+ const anchor = document.querySelector(`li a[href="${href}"]`);
50159
+ if (anchor) {
50160
+ const li = anchor.closest("li");
50161
+ if (li)
50162
+ return li;
50163
+ }
50164
+ return null;
50165
+ };
50166
+ setInterval(() => {
50167
+ const initial = findLi();
50168
+ if (initial) {
50169
+ callback(initial);
50170
+ return;
50171
+ }
50172
+ });
50173
+ }
50174
+ function waitForDD(href, callback) {
50175
+ const findDD = () => {
50176
+ const anchor = document.querySelector(`div a[href="${href}"]`);
50177
+ if (anchor) {
50178
+ const dd = anchor.closest("div");
50179
+ if (dd)
50180
+ return dd;
50181
+ }
50182
+ return null;
50183
+ };
50184
+ setInterval(() => {
50185
+ const initial = findDD();
50186
+ if (initial) {
50187
+ callback(initial);
50188
+ return;
50189
+ }
50190
+ });
50191
+ }
50192
+ var removeLinks = () => {
50193
+ const hrefs = [
50194
+ "/admin/settings/purchase-content-history",
50195
+ "/admin/settings/plugins/purchase-content-releases",
50196
+ "/admin/settings/purchase-review-workflows",
50197
+ "/admin/settings/purchase-single-sign-on",
50198
+ "/admin/settings/purchase-audit-logs"
50199
+ ];
50200
+ hrefs.forEach((href) => {
50201
+ waitForLi(href, (li) => {
50202
+ const parent = li.parentNode;
50203
+ parent.removeChild(li);
50204
+ });
50205
+ });
50206
+ const ddHrefs = ["https://strapi.io/pricing-self-hosted"];
50207
+ ddHrefs.forEach((href) => {
50208
+ waitForDD(href, (dd) => {
50209
+ const parent = dd.parentNode;
50210
+ parent.removeChild(dd);
50211
+ });
50212
+ });
50213
+ };
50214
+ // admin/src/handlers.ts
50215
+ var handlerBootstrap = async (_app) => {
50216
+ handleMissingTranslations();
50217
+ removeLinks();
50218
+ };
50219
+
50214
50220
  // admin/src/index.ts
50215
50221
  var plugin = {
50216
50222
  register: register_default,
@@ -20685,106 +20685,9 @@ var init_App = __esm(() => {
20685
20685
  App_default = App;
20686
20686
  });
20687
20687
 
20688
- // admin/src/boot/handle-missing-translations.ts
20689
- function extractTranslationInfo(logMessage) {
20690
- const regex = /Missing message: "([^"]+)"[^,]+, using default message \(([^)]+)\)/;
20691
- const match = logMessage.match(regex);
20692
- if (match) {
20693
- return {
20694
- messageId: match[1],
20695
- defaultMessage: match[2]
20696
- };
20697
- }
20698
- return null;
20699
- }
20700
- var missTranslations = {};
20701
- var handleMissingTranslations = (message) => {
20702
- const info = extractTranslationInfo(message);
20703
- if (info?.messageId)
20704
- missTranslations[info.messageId] = info.defaultMessage;
20705
- console.log(JSON.stringify(missTranslations));
20706
- };
20707
- var originalError = console.error;
20708
- var originalWarn = () => {};
20709
- console.warn = (..._args) => {
20710
- originalWarn();
20711
- };
20712
- console.error = (error) => {
20713
- try {
20714
- if (error?.message?.includes("MISSING_TRANSLATION")) {
20715
- handleMissingTranslations(error.message);
20716
- } else {
20717
- originalError(error);
20718
- }
20719
- } catch (error2) {
20720
- originalError(error2);
20721
- }
20722
- };
20723
-
20724
- // admin/src/boot/remove-links.ts
20725
- function waitForLi(href, callback) {
20726
- const findLi = () => {
20727
- const anchor = document.querySelector(`li a[href="${href}"]`);
20728
- if (anchor) {
20729
- const li = anchor.closest("li");
20730
- if (li)
20731
- return li;
20732
- }
20733
- return null;
20734
- };
20735
- setInterval(() => {
20736
- const initial = findLi();
20737
- if (initial) {
20738
- callback(initial);
20739
- return;
20740
- }
20741
- });
20742
- }
20743
- function waitForDD(href, callback) {
20744
- const findDD = () => {
20745
- const anchor = document.querySelector(`div a[href="${href}"]`);
20746
- if (anchor) {
20747
- const dd = anchor.closest("div");
20748
- if (dd)
20749
- return dd;
20750
- }
20751
- return null;
20752
- };
20753
- setInterval(() => {
20754
- const initial = findDD();
20755
- if (initial) {
20756
- callback(initial);
20757
- return;
20758
- }
20759
- });
20760
- }
20761
- var removeLinks = () => {
20762
- const hrefs = [
20763
- "/admin/settings/purchase-content-history",
20764
- "/admin/settings/plugins/purchase-content-releases",
20765
- "/admin/settings/purchase-review-workflows",
20766
- "/admin/settings/purchase-single-sign-on",
20767
- "/admin/settings/purchase-audit-logs"
20768
- ];
20769
- hrefs.forEach((href) => {
20770
- waitForLi(href, (li) => {
20771
- const parent = li.parentNode;
20772
- parent.removeChild(li);
20773
- });
20774
- });
20775
- const ddHrefs = ["https://strapi.io/pricing-self-hosted"];
20776
- ddHrefs.forEach((href) => {
20777
- waitForDD(href, (dd) => {
20778
- const parent = dd.parentNode;
20779
- parent.removeChild(dd);
20780
- });
20781
- });
20782
- };
20783
-
20784
20688
  // admin/src/bootstrap.ts
20785
20689
  var bootstrap = (_app) => {
20786
20690
  console.log("website admin plugin: bootstrap");
20787
- removeLinks();
20788
20691
  };
20789
20692
  var bootstrap_default = bootstrap;
20790
20693
 
@@ -46874,29 +46777,32 @@ function findItemDeep(items, itemId) {
46874
46777
  return;
46875
46778
  }
46876
46779
  function removeItem(items, id) {
46877
- const newItems = [];
46878
- for (const item of items) {
46879
- if (item.id === id) {
46880
- continue;
46881
- }
46780
+ return items.filter((item) => item.id !== id).map((item) => {
46882
46781
  if (item.children.length) {
46883
- item.children = removeItem(item.children, id);
46782
+ return {
46783
+ ...item,
46784
+ children: removeItem(item.children, id)
46785
+ };
46884
46786
  }
46885
- newItems.push(item);
46886
- }
46887
- return newItems;
46787
+ return item;
46788
+ });
46888
46789
  }
46889
46790
  function setProperty(items, id, property, setter) {
46890
- for (const item of items) {
46791
+ return items.map((item) => {
46891
46792
  if (item.id === id) {
46892
- item[property] = setter(item[property]);
46893
- continue;
46793
+ return {
46794
+ ...item,
46795
+ [property]: setter(item[property])
46796
+ };
46894
46797
  }
46895
46798
  if (item.children.length) {
46896
- item.children = setProperty(item.children, id, property, setter);
46799
+ return {
46800
+ ...item,
46801
+ children: setProperty(item.children, id, property, setter)
46802
+ };
46897
46803
  }
46898
- }
46899
- return [...items];
46804
+ return item;
46805
+ });
46900
46806
  }
46901
46807
  function countChildren(items, count = 0) {
46902
46808
  return items.reduce((acc, { children }) => {
@@ -50274,6 +50180,105 @@ var register = (app) => {
50274
50180
  };
50275
50181
  var register_default = register;
50276
50182
 
50183
+ // admin/src/boot/handle-missing-translations.ts
50184
+ function extractTranslationInfo(logMessage) {
50185
+ const regex2 = /Missing message: "([^"]+)"[^,]+, using default message \(([^)]+)\)/;
50186
+ const match = logMessage.match(regex2);
50187
+ if (match) {
50188
+ return {
50189
+ messageId: match[1],
50190
+ defaultMessage: match[2]
50191
+ };
50192
+ }
50193
+ return null;
50194
+ }
50195
+ var missTranslations = {};
50196
+ var handleMissingTranslations = () => {
50197
+ const originalError = console.error;
50198
+ const originalWarn = () => {};
50199
+ console.warn = (..._args) => {
50200
+ originalWarn();
50201
+ };
50202
+ console.error = (error) => {
50203
+ try {
50204
+ if (error?.message?.includes("MISSING_TRANSLATION")) {
50205
+ const info = extractTranslationInfo(error.message);
50206
+ if (info?.messageId)
50207
+ missTranslations[info.messageId] = info.defaultMessage;
50208
+ console.log(JSON.stringify(missTranslations));
50209
+ } else {
50210
+ originalError(error);
50211
+ }
50212
+ } catch (error2) {
50213
+ originalError(error2);
50214
+ }
50215
+ };
50216
+ };
50217
+ // admin/src/boot/remove-links.ts
50218
+ function waitForLi(href, callback) {
50219
+ const findLi = () => {
50220
+ const anchor = document.querySelector(`li a[href="${href}"]`);
50221
+ if (anchor) {
50222
+ const li = anchor.closest("li");
50223
+ if (li)
50224
+ return li;
50225
+ }
50226
+ return null;
50227
+ };
50228
+ setInterval(() => {
50229
+ const initial = findLi();
50230
+ if (initial) {
50231
+ callback(initial);
50232
+ return;
50233
+ }
50234
+ });
50235
+ }
50236
+ function waitForDD(href, callback) {
50237
+ const findDD = () => {
50238
+ const anchor = document.querySelector(`div a[href="${href}"]`);
50239
+ if (anchor) {
50240
+ const dd = anchor.closest("div");
50241
+ if (dd)
50242
+ return dd;
50243
+ }
50244
+ return null;
50245
+ };
50246
+ setInterval(() => {
50247
+ const initial = findDD();
50248
+ if (initial) {
50249
+ callback(initial);
50250
+ return;
50251
+ }
50252
+ });
50253
+ }
50254
+ var removeLinks = () => {
50255
+ const hrefs = [
50256
+ "/admin/settings/purchase-content-history",
50257
+ "/admin/settings/plugins/purchase-content-releases",
50258
+ "/admin/settings/purchase-review-workflows",
50259
+ "/admin/settings/purchase-single-sign-on",
50260
+ "/admin/settings/purchase-audit-logs"
50261
+ ];
50262
+ hrefs.forEach((href) => {
50263
+ waitForLi(href, (li) => {
50264
+ const parent = li.parentNode;
50265
+ parent.removeChild(li);
50266
+ });
50267
+ });
50268
+ const ddHrefs = ["https://strapi.io/pricing-self-hosted"];
50269
+ ddHrefs.forEach((href) => {
50270
+ waitForDD(href, (dd) => {
50271
+ const parent = dd.parentNode;
50272
+ parent.removeChild(dd);
50273
+ });
50274
+ });
50275
+ };
50276
+ // admin/src/handlers.ts
50277
+ var handlerBootstrap = async (_app) => {
50278
+ handleMissingTranslations();
50279
+ removeLinks();
50280
+ };
50281
+
50277
50282
  // admin/src/index.ts
50278
50283
  var plugin = {
50279
50284
  register: register_default,
@@ -50281,5 +50286,6 @@ var plugin = {
50281
50286
  };
50282
50287
  var src_default = plugin;
50283
50288
  export {
50289
+ handlerBootstrap,
50284
50290
  src_default as default
50285
50291
  };
@@ -96,6 +96,19 @@ var schema_default = {
96
96
  },
97
97
  component: "site.social",
98
98
  repeatable: true
99
+ },
100
+ footLinks: {
101
+ type: "customField",
102
+ pluginOptions: {
103
+ i18n: {
104
+ localized: true
105
+ }
106
+ },
107
+ customField: "plugin::website.dataNested",
108
+ required: false,
109
+ options: {
110
+ depth: 2
111
+ }
99
112
  }
100
113
  }
101
114
  };
@@ -312,6 +325,12 @@ var schema_default4 = {
312
325
  }
313
326
  },
314
327
  attributes: {
328
+ style: {
329
+ type: "enumeration",
330
+ enum: [
331
+ "default"
332
+ ]
333
+ },
315
334
  logo: {
316
335
  type: "component",
317
336
  pluginOptions: {
@@ -453,8 +472,45 @@ var api_default = {
453
472
  };
454
473
 
455
474
  // server/src/bootstrap.ts
456
- var bootstrap = ({ strapi: strapi2 }) => {
475
+ var import_node_fs = require("node:fs");
476
+ var import_node_path = require("node:path");
477
+ var __dirname = "/Users/imoyh/GithubProjects/geekron/strapi/server/src";
478
+ var initializeSingleTypeData = async (strapi2, pluginName, modelName, initialData) => {
479
+ try {
480
+ const uid = `plugin::${pluginName}.${modelName}`;
481
+ const service = strapi2.plugin(pluginName).service(modelName);
482
+ if (!service) {
483
+ strapi2.log.warn(`Service not found for ${uid}, skipping initialization`);
484
+ return;
485
+ }
486
+ const existingData = await service.find();
487
+ if (existingData && Object.keys(existingData).length > 0) {
488
+ strapi2.log.debug(`Data already exists for ${uid}, skipping initialization`);
489
+ return;
490
+ }
491
+ await service.createOrUpdate({ data: initialData });
492
+ strapi2.log.info(`Successfully initialized data for ${uid}`);
493
+ } catch (error) {
494
+ strapi2.log.error(`Failed to initialize data for plugin::${pluginName}.${modelName}:`, error.message);
495
+ }
496
+ };
497
+ var bootstrap = async ({ strapi: strapi2 }) => {
457
498
  strapi2.log.info("website server plugin: bootstrap");
499
+ try {
500
+ const dataPath = import_node_path.join(__dirname, "../data/data.json");
501
+ const dataContent = import_node_fs.readFileSync(dataPath, "utf-8");
502
+ const initialData = JSON.parse(dataContent);
503
+ strapi2.log.info("Loading initial data from data.json");
504
+ const modelNames = ["common", "menu", "site", "theme"];
505
+ for (const modelName of modelNames) {
506
+ if (initialData[modelName]) {
507
+ await initializeSingleTypeData(strapi2, "website", modelName, initialData[modelName]);
508
+ }
509
+ }
510
+ strapi2.log.info("Initial data loading completed");
511
+ } catch (error) {
512
+ strapi2.log.error("Failed to load initial data:", error.message);
513
+ }
458
514
  };
459
515
  var bootstrap_default = bootstrap;
460
516
 
@@ -61,6 +61,19 @@ var schema_default = {
61
61
  },
62
62
  component: "site.social",
63
63
  repeatable: true
64
+ },
65
+ footLinks: {
66
+ type: "customField",
67
+ pluginOptions: {
68
+ i18n: {
69
+ localized: true
70
+ }
71
+ },
72
+ customField: "plugin::website.dataNested",
73
+ required: false,
74
+ options: {
75
+ depth: 2
76
+ }
64
77
  }
65
78
  }
66
79
  };
@@ -277,6 +290,12 @@ var schema_default4 = {
277
290
  }
278
291
  },
279
292
  attributes: {
293
+ style: {
294
+ type: "enumeration",
295
+ enum: [
296
+ "default"
297
+ ]
298
+ },
280
299
  logo: {
281
300
  type: "component",
282
301
  pluginOptions: {
@@ -418,8 +437,45 @@ var api_default = {
418
437
  };
419
438
 
420
439
  // server/src/bootstrap.ts
421
- var bootstrap = ({ strapi: strapi2 }) => {
440
+ import { readFileSync } from "node:fs";
441
+ import { join } from "node:path";
442
+ var __dirname = "/Users/imoyh/GithubProjects/geekron/strapi/server/src";
443
+ var initializeSingleTypeData = async (strapi2, pluginName, modelName, initialData) => {
444
+ try {
445
+ const uid = `plugin::${pluginName}.${modelName}`;
446
+ const service = strapi2.plugin(pluginName).service(modelName);
447
+ if (!service) {
448
+ strapi2.log.warn(`Service not found for ${uid}, skipping initialization`);
449
+ return;
450
+ }
451
+ const existingData = await service.find();
452
+ if (existingData && Object.keys(existingData).length > 0) {
453
+ strapi2.log.debug(`Data already exists for ${uid}, skipping initialization`);
454
+ return;
455
+ }
456
+ await service.createOrUpdate({ data: initialData });
457
+ strapi2.log.info(`Successfully initialized data for ${uid}`);
458
+ } catch (error) {
459
+ strapi2.log.error(`Failed to initialize data for plugin::${pluginName}.${modelName}:`, error.message);
460
+ }
461
+ };
462
+ var bootstrap = async ({ strapi: strapi2 }) => {
422
463
  strapi2.log.info("website server plugin: bootstrap");
464
+ try {
465
+ const dataPath = join(__dirname, "../data/data.json");
466
+ const dataContent = readFileSync(dataPath, "utf-8");
467
+ const initialData = JSON.parse(dataContent);
468
+ strapi2.log.info("Loading initial data from data.json");
469
+ const modelNames = ["common", "menu", "site", "theme"];
470
+ for (const modelName of modelNames) {
471
+ if (initialData[modelName]) {
472
+ await initializeSingleTypeData(strapi2, "website", modelName, initialData[modelName]);
473
+ }
474
+ }
475
+ strapi2.log.info("Initial data loading completed");
476
+ } catch (error) {
477
+ strapi2.log.error("Failed to load initial data:", error.message);
478
+ }
423
479
  };
424
480
  var bootstrap_default = bootstrap;
425
481
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekron/strapi",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "极客领航网站管理插件",
5
5
  "type": "commonjs",
6
6
  "author": "Geekron",