aberlaas-helper 2.10.0
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/LICENSE +9 -0
- package/lib/main.js +98 -0
- package/lib/versions.js +13 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Tim Carry (tim@pixelastic.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { _ } from 'golgoth';
|
|
3
|
+
import { exists, firostImport, glob } from 'firost';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
/**
|
|
7
|
+
* Return absolute path to the host dir
|
|
8
|
+
* @returns {string} Absolute path to host dir
|
|
9
|
+
*/
|
|
10
|
+
hostRoot() {
|
|
11
|
+
return process.cwd();
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Return an absolute path to a file in the host
|
|
15
|
+
* @param {string} relativePath Relative path from the host root
|
|
16
|
+
* @returns {string} Absolute path to the host file
|
|
17
|
+
*/
|
|
18
|
+
hostPath(relativePath = '') {
|
|
19
|
+
return path.resolve(this.hostRoot(), relativePath);
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Find files in host directory following glob patterns. Will exclude some
|
|
23
|
+
* directories by default, and allow specifying only specific file extensions
|
|
24
|
+
* @param {Array} userPattern Patterns to match
|
|
25
|
+
* @param {Array} safeExtensions Optional array of extensions to safelist. If
|
|
26
|
+
* set, only files of this extensions will be returned
|
|
27
|
+
* @returns {Array} Array of files matching the patterns
|
|
28
|
+
*/
|
|
29
|
+
async findHostFiles(userPattern, safeExtensions = []) {
|
|
30
|
+
const patterns = _.castArray(userPattern);
|
|
31
|
+
// Making all path relative to the host
|
|
32
|
+
const globs = _.map(patterns, (pattern) => {
|
|
33
|
+
return this.hostPath(pattern);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Exclude folders that shouldn't be included
|
|
37
|
+
const blockedFolders = [
|
|
38
|
+
'build',
|
|
39
|
+
'dist',
|
|
40
|
+
'fixtures',
|
|
41
|
+
'node_modules',
|
|
42
|
+
'tmp',
|
|
43
|
+
'vendors',
|
|
44
|
+
'.git',
|
|
45
|
+
'.yarn',
|
|
46
|
+
];
|
|
47
|
+
_.each(blockedFolders, (blockedFolder) => {
|
|
48
|
+
const deepFolder = `**/${blockedFolder}/**`;
|
|
49
|
+
globs.push(`!${this.hostPath(deepFolder)}`);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Expanding globs
|
|
53
|
+
let allFiles = await glob(globs, { directories: false });
|
|
54
|
+
|
|
55
|
+
if (_.isEmpty(safeExtensions)) {
|
|
56
|
+
return allFiles;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Keep only files of specified extensions
|
|
60
|
+
allFiles = _.filter(allFiles, (filepath) => {
|
|
61
|
+
const extension = path.extname(filepath);
|
|
62
|
+
const extensionWithoutDot = _.replace(extension, '.', '');
|
|
63
|
+
return (
|
|
64
|
+
_.includes(safeExtensions, extension) ||
|
|
65
|
+
_.includes(safeExtensions, extensionWithoutDot)
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return allFiles;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Return a config object for a specific tool.
|
|
73
|
+
* Will first check for the user supplied path to the config file, then
|
|
74
|
+
* fallback to the default config file in the host, and finally fallback to
|
|
75
|
+
* the default base config in the aberlaas module.
|
|
76
|
+
* @param {string} userConfigPath User specified config file, relative to the host root
|
|
77
|
+
* @param {string} hostConfigPath Default host config path, relative to the host root
|
|
78
|
+
* @param {object} baseConfig Base aberlaas config, final fallback
|
|
79
|
+
* @returns {object} Config object
|
|
80
|
+
*/
|
|
81
|
+
async getConfig(userConfigPath, hostConfigPath, baseConfig = {}) {
|
|
82
|
+
// Taking value from --config in CLI in priority
|
|
83
|
+
if (userConfigPath) {
|
|
84
|
+
return await firostImport(this.hostPath(userConfigPath));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Checking for custom config in the host
|
|
88
|
+
if (hostConfigPath) {
|
|
89
|
+
const hostConfigFullPath = this.hostPath(hostConfigPath);
|
|
90
|
+
if (await exists(hostConfigFullPath)) {
|
|
91
|
+
return await firostImport(hostConfigFullPath);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Fallback on default config in aberlaas
|
|
96
|
+
return baseConfig;
|
|
97
|
+
},
|
|
98
|
+
};
|
package/lib/versions.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const nodeVersion = '18.18.0';
|
|
2
|
+
export const yarnVersion = '4.5.0';
|
|
3
|
+
export const norskaVersion = '2.9.0';
|
|
4
|
+
export const norskaThemeDocsVersion = '5.0.3';
|
|
5
|
+
export const lernaVersion = '4.0.0';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
nodeVersion,
|
|
9
|
+
yarnVersion,
|
|
10
|
+
norskaVersion,
|
|
11
|
+
norskaThemeDocsVersion,
|
|
12
|
+
lernaVersion,
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aberlaas-helper",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "aberlaas shared helper: Common methods used by all commands",
|
|
5
|
+
"version": "2.10.0",
|
|
6
|
+
"repository": "pixelastic/aberlaas",
|
|
7
|
+
"homepage": "https://projects.pixelastic.com/aberlaas/",
|
|
8
|
+
"author": "Tim Carry (@pixelastic)",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib/*.js"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./lib/main.js"
|
|
15
|
+
},
|
|
16
|
+
"main": "./lib/main.js",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.18.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "../../scripts/local/build",
|
|
22
|
+
"build:prod": "../../scripts/local/build-prod",
|
|
23
|
+
"cms": "../../scripts/local/cms",
|
|
24
|
+
"serve": "../../scripts/local/serve",
|
|
25
|
+
"ci": "../../scripts/local/ci",
|
|
26
|
+
"release": "../../scripts/local/release",
|
|
27
|
+
"update": "node ../../scripts/meta/update.js",
|
|
28
|
+
"test:meta": "../../scripts/local/test-meta",
|
|
29
|
+
"test": "../../scripts/local/test",
|
|
30
|
+
"test:watch": "../../scripts/local/test-watch",
|
|
31
|
+
"compress": "../../scripts/local/compress",
|
|
32
|
+
"lint": "../../scripts/local/lint",
|
|
33
|
+
"lint:fix": "../../scripts/local/lint-fix"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"find-up": "7.0.0",
|
|
37
|
+
"firost": "4.3.0",
|
|
38
|
+
"golgoth": "2.4.0"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "bcdaf87c198a588e02b5539c222f611e356d3079"
|
|
41
|
+
}
|