browser-extension-manager 1.0.0 → 1.0.2

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/TODO.md CHANGED
@@ -0,0 +1,8 @@
1
+ TODO
2
+ - make a special part of WM that has default and custom classes to pass into that replace in the html, it should do txt and inputs
3
+
4
+ WM
5
+ - year (currently wm-year, but change it)
6
+
7
+ BXM
8
+ - extension version (currently bxm-version, but change it)
@@ -1,2 +1,3 @@
1
1
  // Import Font Awesome CSS
2
2
  // @import '~@fortawesome/fontawesome-free/css/all.min.css';
3
+ // @import '/node_modules/@fortawesome/fontawesome-free/css/all.min.css';
@@ -12,12 +12,12 @@ function Manager() {
12
12
 
13
13
  // Defaults
14
14
  self.config = {};
15
- self.version = '{ version }';
15
+ self.version = '%%% version %%%';
16
16
  self.brand = {
17
- name: '{ brand.name }',
17
+ name: '%%% brand.name %%%',
18
18
  };
19
- self.app = '{ app.id }';
20
- self.environment = '{ environment }';
19
+ self.app = '%%% app.id %%%';
20
+ self.environment = '%%% environment %%%';
21
21
  self.libraries = {
22
22
  firebase: false,
23
23
  messaging: false,
@@ -222,10 +222,10 @@ function setupListeners(self) {
222
222
  function importFirebase(self) {
223
223
  // Import Firebase libraries
224
224
  // importScripts(
225
- // 'https://www.gstatic.com/firebasejs/{ firebaseVersion }/firebase-app-compat.js',
226
- // 'https://www.gstatic.com/firebasejs/{ firebaseVersion }/firebase-messaging-compat.js',
227
- // 'https://www.gstatic.com/firebasejs/{ firebaseVersion }/firebase-database-compat.js',
228
- // 'https://www.gstatic.com/firebasejs/{ firebaseVersion }/firebase-firestore-compat.js',
225
+ // 'https://www.gstatic.com/firebasejs/%%% firebaseVersion %%%/firebase-app-compat.js',
226
+ // 'https://www.gstatic.com/firebasejs/%%% firebaseVersion %%%/firebase-messaging-compat.js',
227
+ // 'https://www.gstatic.com/firebasejs/%%% firebaseVersion %%%/firebase-database-compat.js',
228
+ // 'https://www.gstatic.com/firebasejs/%%% firebaseVersion %%%/firebase-firestore-compat.js',
229
229
  // );
230
230
  console.error('---0');
231
231
  console.error('---1', __dirname);
@@ -249,7 +249,7 @@ function setupLiveReload(self) {
249
249
  if (self.environment !== 'development') { return };
250
250
 
251
251
  // Setup livereload
252
- const address = `ws://localhost:{ liveReloadPort }/livereload`;
252
+ const address = `ws://localhost:%%% liveReloadPort %%%/livereload`;
253
253
  let connection;
254
254
  let isReconnecting = false; // Flag to track reconnections
255
255
 
@@ -1,21 +1,10 @@
1
+ // Libraries
2
+ const { template } = require('node-powertools');
3
+
1
4
  // Plugin
2
5
  class ReplacePlugin {
3
6
  constructor(replacements) {
4
- this.replacements = this.flatten(replacements)
5
- }
6
-
7
- flatten(obj, prefix = '') {
8
- let result = {}
9
- for (let key in obj) {
10
- let value = obj[key]
11
- let path = prefix ? `${prefix}.${key}` : key
12
- if (typeof value === 'object' && value !== null) {
13
- Object.assign(result, this.flatten(value, path))
14
- } else {
15
- result[`{ ${path} }`] = value
16
- }
17
- }
18
- return result
7
+ this.replacements = replacements
19
8
  }
20
9
 
21
10
  apply(compiler) {
@@ -27,20 +16,25 @@ class ReplacePlugin {
27
16
  },
28
17
  (assets) => {
29
18
  for (const filename in assets) {
30
- if (filename.endsWith('.js')) {
31
- let asset = assets[filename]
32
- let content = asset.source()
19
+ // Skip non-JS files
20
+ if (!filename.endsWith('.js')) {
21
+ continue
22
+ }
33
23
 
34
- for (const [placeholder, replacement] of Object.entries(this.replacements)) {
35
- const regex = new RegExp(placeholder.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g')
36
- content = content.replace(regex, replacement)
37
- }
24
+ // Get the asset
25
+ let asset = assets[filename]
26
+ let content = asset.source();
38
27
 
39
- compilation.updateAsset(
40
- filename,
41
- new compiler.webpack.sources.RawSource(content)
42
- )
43
- }
28
+ // Use template interpolation
29
+ content = template(content, this.replacements, {
30
+ brackets: ['%%%', '%%%'],
31
+ })
32
+
33
+ // Update the asset
34
+ compilation.updateAsset(
35
+ filename,
36
+ new compiler.webpack.sources.RawSource(content)
37
+ )
44
38
  }
45
39
  }
46
40
  )
@@ -0,0 +1,11 @@
1
+ // Libraries
2
+ const Manager = new (require('../../build.js'));
3
+ const logger = Manager.logger('themes');
4
+ const { src, dest, watch, series } = require('gulp');
5
+
6
+ // Load package
7
+ const package = Manager.getPackage('main');
8
+ const project = Manager.getPackage('project');
9
+ const manifest = Manager.getManifest();
10
+ const rootPathPackage = Manager.getRootPath('main');
11
+ const rootPathProject = Manager.getRootPath('project');
@@ -2,10 +2,6 @@
2
2
  const Manager = new (require('../../build.js'));
3
3
  const logger = Manager.logger('themes');
4
4
  const { src, dest, watch, series } = require('gulp');
5
- const through2 = require('through2');
6
- const jetpack = require('fs-jetpack');
7
- const path = require('path');
8
- const { execute } = require('node-powertools');
9
5
 
10
6
  // Load package
11
7
  const package = Manager.getPackage('main');
@@ -16,9 +16,6 @@ const config = Manager.getConfig();
16
16
  const rootPathPackage = Manager.getRootPath('main');
17
17
  const rootPathProject = Manager.getRootPath('project');
18
18
 
19
- // Load variables
20
- const firebaseVersion = version.clean(require('web-manager/package.json').dependencies.firebase);
21
-
22
19
  // Settings
23
20
  // const MINIFY = false;
24
21
  const MINIFY = Manager.getEnvironment() === 'production';
@@ -41,19 +38,7 @@ const settings = {
41
38
  mode: 'production',
42
39
  target: ['web', 'es5'],
43
40
  plugins: [
44
- new ReplacePlugin({
45
- // App & Project
46
- ...project,
47
- ...manifest,
48
- ...config,
49
-
50
- // Additional
51
- environment: Manager.getEnvironment(),
52
-
53
- // Specific
54
- firebaseVersion: firebaseVersion,
55
- liveReloadPort: Manager.getLiveReloadPort(),
56
- }),
41
+ new ReplacePlugin(getReplaceOptions()),
57
42
  ],
58
43
  entry: {
59
44
  // Entry is dynamically generated
@@ -185,5 +170,65 @@ function updateEntryPoints() {
185
170
  logger.log('Updated entry points:', settings.entry);
186
171
  }
187
172
 
173
+ function getReplaceOptions() {
174
+ // Setup options
175
+ const options = {
176
+ // App & Project
177
+ ...project,
178
+ ...manifest,
179
+ ...config,
180
+
181
+ // Additional
182
+ environment: Manager.getEnvironment(),
183
+
184
+ // Specific
185
+ firebaseVersion: version.clean(require('web-manager/package.json').dependencies.firebase),
186
+ liveReloadPort: Manager.getLiveReloadPort(),
187
+ }
188
+ const now = Math.round(new Date().getTime() / 1000);
189
+
190
+ // Set webManagerConfiguration
191
+ options.webManagerConfiguration = JSON.stringify({
192
+ global: {
193
+ app: options.app.id,
194
+ version: options.version,
195
+ url: options.brand.url,
196
+ buildTime: now,
197
+ cacheBreaker: now,
198
+ brand: options.brand.name,
199
+ contact: {
200
+ emailBusiness: options.brand.email,
201
+ emailSupport: options.brand.email,
202
+ },
203
+ download: {},
204
+ extension: {},
205
+ validRedirectHosts: ['itwcreativeworks.com'],
206
+ settings: {
207
+ libraries: {
208
+ firebase_app: {
209
+ enabled: !!options.firebaseConfig.apiKey,
210
+ config: options.firebaseConfig,
211
+ },
212
+ firebase_appCheck: {
213
+ enabled: false,
214
+ },
215
+ cookieconsent: {
216
+ enabled: false,
217
+ },
218
+ chatsy: {
219
+ enabled: false,
220
+ },
221
+ sentry: {
222
+ enabled: false,
223
+ },
224
+ }
225
+ }
226
+ }
227
+ });
228
+
229
+ // Return
230
+ return options;
231
+ }
232
+
188
233
  // Default Task
189
234
  module.exports = series(webpack, webpackWatcher);
package/dist/index.js CHANGED
@@ -9,19 +9,41 @@ function Manager() {
9
9
  return self;
10
10
  }
11
11
 
12
- // Initialize
13
12
  Manager.prototype.initialize = function (callback) {
14
13
  const self = this;
15
14
 
15
+ // Configuration
16
+ const configuration = JSON.parse('%%% webManagerConfiguration %%%');
17
+
16
18
  // Initiate the web manager
17
- self._manager = new WebManager();
19
+ self.manager = new WebManager();
20
+ self.extension = require('./lib/extension');
18
21
 
19
22
  // Initialize
20
- self._manager.init(window.Configuration, callback);
23
+ self.manager.init(configuration, callback);
21
24
 
22
25
  // Return
23
- return self._manager;
26
+ return self.manager;
24
27
  };
25
28
 
29
+ // Setup logger
30
+ ['log', 'error', 'warn', 'info', 'debug'].forEach(method => {
31
+ Manager.prototype[method] = function() {
32
+ // Get arguments
33
+ const time = new Date().toLocaleTimeString('en-US', {
34
+ hour12: false,
35
+ hour: '2-digit',
36
+ minute: '2-digit',
37
+ second: '2-digit'
38
+ });
39
+
40
+ // Add prefix
41
+ const args = [`[${time}] content:`, ...Array.from(arguments)];
42
+
43
+ // Call the original console method
44
+ console[method].apply(console, args);
45
+ };
46
+ });
47
+
26
48
  // Export
27
49
  module.exports = Manager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-manager",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Browser Extension Manager dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -56,7 +56,6 @@
56
56
  "@babel/preset-env": "^7.26.9",
57
57
  "@fortawesome/fontawesome-free": "^6.7.2",
58
58
  "babel-loader": "^9.2.1",
59
- "browser-sync": "^3.0.3",
60
59
  "chalk": "^4.1.2",
61
60
  "fs-jetpack": "^5.1.0",
62
61
  "glob": "^11.0.1",
@@ -68,9 +67,9 @@
68
67
  "json5": "^2.2.3",
69
68
  "lodash": "^4.17.21",
70
69
  "minimatch": "^10.0.1",
71
- "node-powertools": "^2.1.5",
70
+ "node-powertools": "^2.2.0",
72
71
  "npm-api": "^1.0.1",
73
- "sass": "^1.86.0",
72
+ "sass": "^1.86.3",
74
73
  "through2": "^4.0.2",
75
74
  "web-manager": "^3.2.73",
76
75
  "webpack": "^5.98.0",