browser-extension-manager 0.0.1

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.
Files changed (55) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +20 -0
  3. package/LICENSE +21 -0
  4. package/README.md +56 -0
  5. package/TODO.md +0 -0
  6. package/bin/browser-extension-manager +7 -0
  7. package/dist/assets/css/fontawesome.scss +2 -0
  8. package/dist/assets/css/main.scss +3 -0
  9. package/dist/assets/js/main.js +4 -0
  10. package/dist/assets/js copy/base.js +7 -0
  11. package/dist/assets/js copy/core.js +81 -0
  12. package/dist/assets/js copy/main.js +10 -0
  13. package/dist/background.js +261 -0
  14. package/dist/build.js +92 -0
  15. package/dist/cli.js +70 -0
  16. package/dist/commands/clean.js +33 -0
  17. package/dist/commands/install.js +52 -0
  18. package/dist/commands/setup.js +484 -0
  19. package/dist/commands/version.js +12 -0
  20. package/dist/config/manifest.json +78 -0
  21. package/dist/content.js +52 -0
  22. package/dist/defaults/.nvmrc +1 -0
  23. package/dist/defaults/.vscode/settings.json +8 -0
  24. package/dist/defaults/_.gitignore +71 -0
  25. package/dist/defaults/hooks/build:post.js +8 -0
  26. package/dist/defaults/hooks/build:pre.js +8 -0
  27. package/dist/defaults/src/_locales/en/messages.json +14 -0
  28. package/dist/defaults/src/assets/css/content.scss +2 -0
  29. package/dist/defaults/src/assets/css/options.scss +2 -0
  30. package/dist/defaults/src/assets/css/popup.scss +2 -0
  31. package/dist/defaults/src/assets/images/_ +0 -0
  32. package/dist/defaults/src/assets/images/icons/icon.png +0 -0
  33. package/dist/defaults/src/assets/js/background.js +11 -0
  34. package/dist/defaults/src/assets/js/content.js +8 -0
  35. package/dist/defaults/src/assets/js/popup.js +7 -0
  36. package/dist/defaults/src/assets/vendor/_ +0 -0
  37. package/dist/defaults/src/manifest.json +86 -0
  38. package/dist/defaults/src/pages/options.html +21 -0
  39. package/dist/defaults/src/pages/popup.html +21 -0
  40. package/dist/gulp/main.js +50 -0
  41. package/dist/gulp/plugins/webpack/replace.js +52 -0
  42. package/dist/gulp/tasks/developmentRebuild.js +94 -0
  43. package/dist/gulp/tasks/distribute.js +163 -0
  44. package/dist/gulp/tasks/icons.js +149 -0
  45. package/dist/gulp/tasks/package.js +167 -0
  46. package/dist/gulp/tasks/sass.js +74 -0
  47. package/dist/gulp/tasks/serve.js +183 -0
  48. package/dist/gulp/tasks/test.js +16 -0
  49. package/dist/gulp/tasks/webpack.js +186 -0
  50. package/dist/index.js +27 -0
  51. package/dist/lib/affiliatizer.js +198 -0
  52. package/dist/lib/extension.js +104 -0
  53. package/dist/lib/logger.js +56 -0
  54. package/dist/lib/messaging.js +48 -0
  55. package/package.json +87 -0
@@ -0,0 +1,71 @@
1
+ .DS_Store
2
+ # Logs
3
+ logs
4
+ *.log
5
+ npm-debug.log*
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ firebase-debug.log*
9
+
10
+ # Firebase cache
11
+ .firebase/
12
+
13
+ # Firebase config
14
+
15
+ # Uncomment this if you'd like others to create their own Firebase project.
16
+ # For a team working on the same Firebase project(s), it is recommended to leave
17
+ # it commented so all members can deploy to the same project(s) in .firebaserc.
18
+ .firebaserc
19
+
20
+ # Runtime data
21
+ pids
22
+ *.pid
23
+ *.seed
24
+ *.pid.lock
25
+
26
+ # Directory for instrumented libs generated by jscoverage/JSCover
27
+ lib-cov
28
+
29
+ # Coverage directory used by tools like istanbul
30
+ coverage
31
+
32
+ # nyc test coverage
33
+ .nyc_output
34
+
35
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36
+ .grunt
37
+
38
+ # Bower dependency directory (https://bower.io/)
39
+ bower_components
40
+
41
+ # node-waf configuration
42
+ .lock-wscript
43
+
44
+ # Compiled binary addons (http://nodejs.org/api/addons.html)
45
+ build/Release
46
+
47
+ # Dependency directories
48
+ node_modules/
49
+
50
+ # Optional npm cache directory
51
+ .npm
52
+
53
+ # Optional eslint cache
54
+ .eslintcache
55
+
56
+ # Optional REPL history
57
+ .node_repl_history
58
+
59
+ # Output of 'npm pack'
60
+ *.tgz
61
+
62
+ # Yarn Integrity file
63
+ .yarn-integrity
64
+
65
+ # dotenv environment variables file
66
+ .env
67
+
68
+ # Custom
69
+ /dist
70
+ /packaged
71
+ /.temp
@@ -0,0 +1,8 @@
1
+ // Libraries
2
+ const Manager = new (require('browser-extension-manager/build'));
3
+ const logger = Manager.logger('build:post');
4
+
5
+ // Hook
6
+ module.exports = async (index) => {
7
+ logger.log('Running with index =', index);
8
+ }
@@ -0,0 +1,8 @@
1
+ // Libraries
2
+ const Manager = new (require('browser-extension-manager/build'));
3
+ const logger = Manager.logger('build:pre');
4
+
5
+ // Hook
6
+ module.exports = async (index) => {
7
+ logger.log('Running with index =', index);
8
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ appName: {
3
+ message: 'Ultimate Browser Extension - Browser Enhancer',
4
+ description: 'The name of the extension.',
5
+ },
6
+ appDescription: {
7
+ message: 'Ultimate Browser Extension - A powerful tool to enhance your browsing experience.',
8
+ description: 'The description of the extension.',
9
+ },
10
+ btnTooltip: {
11
+ message: 'Ultimate Browser Extension',
12
+ description: 'Tooltip for the button.',
13
+ },
14
+ }
@@ -0,0 +1,2 @@
1
+ // content.scss
2
+ // This file contains the styles for the content script of the extension.
@@ -0,0 +1,2 @@
1
+ // options.scss
2
+ // This file contains the styles for the options page of the extension.
@@ -0,0 +1,2 @@
1
+ // popup.scss
2
+ // This file contains the styles for the popup page of the extension.
File without changes
@@ -0,0 +1,11 @@
1
+ // Init service worker
2
+ const serviceWorker = self;
3
+
4
+ // Import the Ultimate Extension Manager
5
+ const Manager = new (require('browser-extension-manager/background'));
6
+
7
+ // Initialize
8
+ Manager.initialize()
9
+ .then(() => {
10
+ Manager.log('Initialized');
11
+ });
@@ -0,0 +1,8 @@
1
+ // Import the Ultimate Extension Manager
2
+ const Manager = new (require('browser-extension-manager/content'));
3
+
4
+ // Initialize
5
+ Manager.initialize()
6
+ .then(() => {
7
+ Manager.log('Initialized');
8
+ });
@@ -0,0 +1,7 @@
1
+ // Import the Ultimate Extension Manager
2
+ const Manager = new (require('browser-extension-manager'));
3
+
4
+ // Initialize
5
+ Manager.initialize(() => {
6
+ console.log('Initialized');
7
+ })
File without changes
@@ -0,0 +1,86 @@
1
+ {
2
+ // Basic info
3
+ version: '1.0.0',
4
+ name: '__MSG_appName__',
5
+ description: '__MSG_appDescription__',
6
+
7
+ // Background script
8
+ background: {
9
+ service_worker: 'assets/js/background.bundle.js',
10
+ },
11
+
12
+ // Permissions
13
+ permissions: [
14
+ // 'tabs',
15
+ // 'storage',
16
+ // 'activeTab',
17
+ // 'scripting',
18
+ ],
19
+ host_permissions: [
20
+ // 'http://*/*',
21
+ // 'https://*/*',
22
+ ],
23
+
24
+ // Options page
25
+ options_ui: {
26
+ page: 'pages/options.html',
27
+ },
28
+
29
+ // Content scripts
30
+ content_scripts: [
31
+ // {
32
+ // matches: [
33
+ // 'http://*/*',
34
+ // 'https://*/*',
35
+ // ],
36
+ // js: [
37
+ // 'assets/js/content.bundle.js',
38
+ // ],
39
+ // css: [
40
+ // 'assets/css/content.bundle.css',
41
+ // ],
42
+ // run_at: 'document_end',
43
+ // all_frames: false,
44
+ // },
45
+ ],
46
+
47
+ // Browser action
48
+ action: {
49
+ default_title: '__MSG_appName__',
50
+ default_popup: 'pages/popup.html',
51
+ },
52
+
53
+ // Content security policy
54
+ content_security_policy: {
55
+ extension_pages: "script-src 'self'; object-src 'self'; worker-src 'self';",
56
+ },
57
+
58
+ // Web accessible resources
59
+ externally_connectable: {
60
+ matches: [
61
+ ],
62
+ },
63
+
64
+ // Web accessible resources
65
+ web_accessible_resources: [
66
+ // {
67
+ // matches: [
68
+ // '<all_urls>',
69
+ // ],
70
+ // resources: [
71
+ // 'assets/styles/content.bundle.css',
72
+ // ],
73
+ // },
74
+ ],
75
+
76
+ // Commands
77
+ commands: {
78
+ },
79
+
80
+ // Sandbox
81
+ sandbox: {
82
+ pages: [
83
+ // 'pages/sandbox.html',
84
+ ],
85
+ },
86
+ }
@@ -0,0 +1,21 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <link href="/assets/css/options.bundle.css" rel="stylesheet">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
7
+ <title>Options & Settings</title>
8
+ </head>
9
+ <body class="wrap">
10
+ <footer class="main-footer">
11
+ <div class="grid">
12
+ <div class="unit whole center-on-mobiles">
13
+ <p class="text-center text-muted">
14
+ &copy; <a href="">ITW Creative Works</a> <span class="wm-year"></span>.
15
+ </p>
16
+ </div>
17
+ </div>
18
+ </footer>
19
+ <script src="/assets/css/options.bundle.js"></script>
20
+ </body>
21
+ </html>
@@ -0,0 +1,21 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <link href="/assets/css/popup.bundle.css" rel="stylesheet">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
7
+ <title>Popup</title>
8
+ </head>
9
+ <body class="wrap">
10
+ <footer class="main-footer">
11
+ <div class="grid">
12
+ <div class="unit whole center-on-mobiles">
13
+ <p class="text-center text-muted">
14
+ &copy; <a href="">ITW Creative Works</a> <span class="wm-year"></span>.
15
+ </p>
16
+ </div>
17
+ </div>
18
+ </footer>
19
+ <script src="/assets/css/popup.bundle.js"></script>
20
+ </body>
21
+ </html>
@@ -0,0 +1,50 @@
1
+ // Libraries
2
+ const Manager = new (require('../build.js'));
3
+ const logger = Manager.logger('main');
4
+ const argv = Manager.getArguments();
5
+ const { series, parallel, watch } = require('gulp');
6
+ const path = require('path');
7
+ const jetpack = require('fs-jetpack');
8
+
9
+ // Log
10
+ logger.log('Starting...', argv);
11
+
12
+ // Load tasks
13
+ const tasks = jetpack.list(path.join(__dirname, 'tasks'));
14
+
15
+ // Init global
16
+ global.tasks = {};
17
+ global.browserSync = null;
18
+
19
+ // Load tasks
20
+ tasks.forEach((file) => {
21
+ const name = file.replace('.js', '');
22
+
23
+ // Log
24
+ logger.log('Loading task:', name);
25
+
26
+ // Export task
27
+ exports[name] = require(path.join(__dirname, 'tasks', file));
28
+ });
29
+
30
+ // Set global variable to access tasks in other files
31
+ global.tasks = exports;
32
+
33
+ // Define build process
34
+ exports.build = series(
35
+ // exports.setup,
36
+ // exports.clean,
37
+ exports.distribute,
38
+ parallel(exports.sass, exports.webpack, exports.icons),
39
+ exports.package,
40
+ );
41
+
42
+ // Compose task scheduler
43
+ exports.default = series(
44
+ // exports.setup,
45
+ // exports.clean,
46
+ exports.serve,
47
+ exports.build,
48
+ exports.developmentRebuild,
49
+ // exports.watcher,
50
+ );
@@ -0,0 +1,52 @@
1
+ // Plugin
2
+ class ReplacePlugin {
3
+ 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
19
+ }
20
+
21
+ apply(compiler) {
22
+ compiler.hooks.compilation.tap('ReplacePlugin', (compilation) => {
23
+ compilation.hooks.processAssets.tap(
24
+ {
25
+ name: 'ReplacePlugin',
26
+ stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
27
+ },
28
+ (assets) => {
29
+ for (const filename in assets) {
30
+ if (filename.endsWith('.js')) {
31
+ let asset = assets[filename]
32
+ let content = asset.source()
33
+
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
+ }
38
+
39
+ compilation.updateAsset(
40
+ filename,
41
+ new compiler.webpack.sources.RawSource(content)
42
+ )
43
+ }
44
+ }
45
+ }
46
+ )
47
+ })
48
+ }
49
+ }
50
+
51
+ // Export
52
+ module.exports = ReplacePlugin
@@ -0,0 +1,94 @@
1
+ // Libraries
2
+ const Manager = new (require('../../build.js'));
3
+ const logger = Manager.logger('development-rebuild');
4
+ const { src, dest, watch, series } = require('gulp');
5
+ const path = require('path');
6
+ const { execute } = require('node-powertools');
7
+
8
+ // Load package
9
+ const package = Manager.getPackage('main');
10
+ const project = Manager.getPackage('project');
11
+
12
+ // Glob
13
+ const input = [
14
+ // Files to include
15
+ // `${__dirname}/../../defaults/dist/**/*`,
16
+ `${path.join(__dirname, '..', '..', 'defaults/dist')}/**/*`,
17
+
18
+ // Files to exclude
19
+ ];
20
+ const output = 'dist';
21
+ const delay = 250;
22
+
23
+ // Index
24
+ let index = -1;
25
+
26
+ // SASS Compilation Task
27
+ async function developmentRebuild(complete) {
28
+ // Increment index
29
+ index++;
30
+
31
+ // Log
32
+ logger.log('Starting...');
33
+
34
+ // Skip first run
35
+ if (index === 0 && false) {
36
+ logger.log('Skipping first run');
37
+ return complete();
38
+ }
39
+
40
+ // Execute uj setup again
41
+ const checks = [
42
+ '--check-manager=false',
43
+ '--check-node=false',
44
+ '--check-peer-dependencies=false',
45
+ '--setup-scripts=false',
46
+ '--build-site-files=true',
47
+ '--build-site-files-input="dist/**/*"',
48
+ '--check-locality=false',
49
+ ];
50
+
51
+ // Execute
52
+ await execute(`npx bxm setup ${checks.join(' ')}`, { log: true });
53
+
54
+ // Log
55
+ logger.log('Finished!');
56
+
57
+ // Complete
58
+ return complete();
59
+
60
+ // Compile
61
+ // return src(input)
62
+ // .pipe(dest(output))
63
+ // .on('end', () => {
64
+ // // Log
65
+ // logger.log('Finished!');
66
+
67
+ // // Complete
68
+ // return complete();
69
+ // });
70
+ }
71
+
72
+ // Watcher Task
73
+ function developmentRebuildWatcher(complete) {
74
+ // Quit if in build mode
75
+ if (Manager.isBuildMode()) {
76
+ logger.log('[watcher] Skipping watcher in build mode');
77
+ return complete();
78
+ }
79
+
80
+ // Log
81
+ logger.log('[watcher] Watching for changes...');
82
+
83
+ // Watch for changes
84
+ watch(input, { delay: delay }, developmentRebuild)
85
+ .on('change', function(path) {
86
+ logger.log(`[watcher] File ${path} was changed`);
87
+ });
88
+
89
+ // Complete
90
+ return complete();
91
+ }
92
+
93
+ // Default Task
94
+ module.exports = series(developmentRebuild, developmentRebuildWatcher);
@@ -0,0 +1,163 @@
1
+ // Libraries
2
+ const Manager = new (require('../../build.js'));
3
+ const logger = Manager.logger('distribute');
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
+
10
+ // Load package
11
+ const package = Manager.getPackage('main');
12
+ const project = Manager.getPackage('project');
13
+ const manifest = Manager.getManifest();
14
+
15
+ // Glob
16
+ const input = [
17
+ // Files to include
18
+ 'src/**/*',
19
+
20
+ // Files to exclude
21
+ // '!dist/**',
22
+ ];
23
+ const output = 'dist';
24
+ const delay = 250;
25
+
26
+ // Index
27
+ let index = -1;
28
+
29
+ // Main task
30
+ async function distribute(complete) {
31
+ // Increment index
32
+ index++;
33
+
34
+ // Log
35
+ logger.log('Starting...');
36
+
37
+ // Create build JSON
38
+ await createBuildJSON();
39
+
40
+ // Complete
41
+ return src(input, { base: 'src' })
42
+ // .pipe(customPathTransform())
43
+ .pipe(dest(output))
44
+ .on('end', () => {
45
+ // Log
46
+ logger.log('Finished!');
47
+
48
+ // Complete
49
+ return complete();
50
+ });
51
+ }
52
+
53
+ function customPathTransform() {
54
+ return through2.obj(function (file, _, callback) {
55
+ // Skip if it's a directory
56
+ if (file.isDirectory()) {
57
+ return callback(null, file);
58
+ }
59
+
60
+ // Get relative path
61
+ const relativePath = path.relative(file.base, file.path);
62
+
63
+ // Log
64
+ // logger.log(`Processing file 111: ${relativePath}`);
65
+
66
+ // Change path if it starts with 'pages/'
67
+ if (relativePath.startsWith('pages/')) {
68
+ const newRelativePath = relativePath.replace(/^pages\//, '');
69
+ file.path = path.join(file.base, newRelativePath);
70
+
71
+ // Log
72
+ // logger.log(`Changed path to 222: ${file.path}`);
73
+ }
74
+
75
+ // Log
76
+ // logger.log(`Processing file 333: ${file.path}`);
77
+
78
+ // Push the file
79
+ this.push(file);
80
+
81
+ // Continue
82
+ callback(null, file);
83
+ });
84
+ }
85
+
86
+ // Watcher task
87
+ function distributeWatcher(complete) {
88
+ // Quit if in build mode
89
+ if (process.env.BXM_ === 'true') {
90
+ logger.log('[watcher] Skipping watcher in build mode');
91
+ return complete();
92
+ }
93
+
94
+ // Log
95
+ logger.log('[watcher] Watching for changes...');
96
+
97
+ // Watch for changes
98
+ watch(input, { delay: delay }, distribute)
99
+ .on('change', function(path) {
100
+ logger.log(`[watcher] File ${path} was changed`);
101
+ });
102
+
103
+ // Complete
104
+ return complete();
105
+ }
106
+
107
+ // Default Task
108
+ module.exports = series(distribute, distributeWatcher);
109
+
110
+
111
+ // Get git info
112
+ async function getGitInfo() {
113
+ return await execute('git remote -v')
114
+ .then((r) => {
115
+ // Split on whitespace
116
+ const split = r.split(/\s+/);
117
+ const url = split[1];
118
+
119
+ // Get user and repo
120
+ const user = url.split('/')[3];
121
+ const name = url.split('/')[4].replace('.git', '');
122
+
123
+ // Return
124
+ return {user, name};
125
+ })
126
+ }
127
+
128
+ // Create build.json
129
+ async function createBuildJSON() {
130
+ // Create build log JSON
131
+ try {
132
+ // Get info first
133
+ const git = await getGitInfo();
134
+
135
+ // Create JSON
136
+ const json = {
137
+ timestamp: new Date().toISOString(),
138
+ repo: {
139
+ user: git.user,
140
+ name: git.name,
141
+ },
142
+ environment: Manager.getEnvironment(),
143
+ packages: {
144
+ 'web-manager': require('web-manager/package.json').version,
145
+ [package.name]: package.version,
146
+ },
147
+ manifest: manifest,
148
+ }
149
+
150
+ // Log object
151
+ // logger.log('Build JSON:', json);
152
+
153
+ // Write to file
154
+ jetpack.write('dist/build.json', JSON.stringify(json, null, 2));
155
+
156
+ // Log
157
+ logger.log('Created build.json');
158
+ } catch (e) {
159
+ console.error('Error updating build.json', e);
160
+ }
161
+ }
162
+
163
+