oc 0.49.50 → 0.49.52
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/.husky/pre-commit +51 -2
- package/.husky/prepare-commit-msg +53 -0
- package/CHANGELOG.md +6 -0
- package/biome.json +36 -0
- package/dist/cli/domain/clean.js +2 -2
- package/dist/cli/domain/get-components-by-dir.js +6 -6
- package/dist/cli/domain/get-mocked-plugins.d.ts +1 -1
- package/dist/cli/domain/get-mocked-plugins.js +8 -10
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +2 -2
- package/dist/cli/domain/handle-dependencies/get-compiler.js +2 -2
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +4 -4
- package/dist/cli/domain/handle-dependencies/index.d.ts +2 -2
- package/dist/cli/domain/handle-dependencies/index.js +9 -7
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +2 -2
- package/dist/cli/domain/handle-dependencies/install-compiler.js +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +4 -4
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +4 -4
- package/dist/cli/domain/handle-dependencies/require-template.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/require-template.js +12 -7
- package/dist/cli/domain/init-template/index.d.ts +1 -1
- package/dist/cli/domain/init-template/index.js +3 -3
- package/dist/cli/domain/init-template/install-template.d.ts +1 -1
- package/dist/cli/domain/init-template/install-template.js +1 -1
- package/dist/cli/domain/init-template/scaffold.js +7 -8
- package/dist/cli/domain/local.d.ts +1 -1
- package/dist/cli/domain/local.js +8 -10
- package/dist/cli/domain/mock.js +3 -3
- package/dist/cli/domain/package-components.d.ts +1 -1
- package/dist/cli/domain/package-components.js +33 -9
- package/dist/cli/domain/registry.d.ts +2 -2
- package/dist/cli/domain/registry.js +4 -4
- package/dist/cli/domain/url-parser.d.ts +1 -1
- package/dist/cli/domain/url-parser.js +5 -5
- package/dist/cli/domain/watch.js +3 -3
- package/dist/cli/facade/clean.d.ts +1 -1
- package/dist/cli/facade/clean.js +2 -2
- package/dist/cli/facade/dev.d.ts +1 -1
- package/dist/cli/facade/dev.js +18 -15
- package/dist/cli/facade/init.d.ts +1 -1
- package/dist/cli/facade/init.js +3 -3
- package/dist/cli/facade/mock.d.ts +1 -1
- package/dist/cli/facade/package.d.ts +2 -2
- package/dist/cli/facade/package.js +11 -11
- package/dist/cli/facade/preview.d.ts +2 -2
- package/dist/cli/facade/publish.d.ts +2 -2
- package/dist/cli/facade/publish.js +16 -18
- package/dist/cli/facade/registry-add.d.ts +2 -2
- package/dist/cli/facade/registry-ls.d.ts +2 -2
- package/dist/cli/facade/registry-ls.js +4 -4
- package/dist/cli/facade/registry-remove.d.ts +2 -2
- package/dist/cli/facade/registry.js +1 -3
- package/dist/cli/index.js +10 -10
- package/dist/cli/logger.js +0 -1
- package/dist/cli/programmatic-api.d.ts +2 -2
- package/dist/cli/programmatic-api.js +1 -2
- package/dist/cli/validate-command.d.ts +1 -1
- package/dist/cli/validate-command.js +1 -1
- package/dist/components/oc-client/_package/package.json +37 -1
- package/dist/components/oc-client/_package/server.js +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/components/oc-client/server.js +1 -1
- package/dist/registry/app-start.d.ts +1 -1
- package/dist/registry/app-start.js +3 -4
- package/dist/registry/domain/authentication.d.ts +2 -2
- package/dist/registry/domain/components-cache/components-list.d.ts +2 -2
- package/dist/registry/domain/components-cache/components-list.js +6 -6
- package/dist/registry/domain/components-cache/index.d.ts +2 -2
- package/dist/registry/domain/components-cache/index.js +5 -5
- package/dist/registry/domain/components-details.d.ts +2 -2
- package/dist/registry/domain/components-details.js +7 -6
- package/dist/registry/domain/events-handler.d.ts +1 -3
- package/dist/registry/domain/events-handler.js +3 -3
- package/dist/registry/domain/extract-package.d.ts +1 -1
- package/dist/registry/domain/extract-package.js +6 -6
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +1 -1
- package/dist/registry/domain/get-package-json-from-temp-dir.js +2 -2
- package/dist/registry/domain/nested-renderer.d.ts +2 -2
- package/dist/registry/domain/nested-renderer.js +4 -4
- package/dist/registry/domain/options-sanitiser.d.ts +1 -1
- package/dist/registry/domain/options-sanitiser.js +2 -4
- package/dist/registry/domain/plugins-initialiser.js +15 -13
- package/dist/registry/domain/register-templates.d.ts +1 -1
- package/dist/registry/domain/register-templates.js +2 -2
- package/dist/registry/domain/repository.d.ts +1 -1
- package/dist/registry/domain/repository.js +26 -29
- package/dist/registry/domain/require-wrapper.js +3 -3
- package/dist/registry/domain/sanitiser.d.ts +1 -1
- package/dist/registry/domain/sanitiser.js +4 -4
- package/dist/registry/domain/storage-adapter.d.ts +1 -1
- package/dist/registry/domain/url-builder.js +5 -5
- package/dist/registry/domain/validators/component-parameters.d.ts +1 -1
- package/dist/registry/domain/validators/component-parameters.js +8 -8
- package/dist/registry/domain/validators/index.d.ts +2 -2
- package/dist/registry/domain/validators/index.js +2 -2
- package/dist/registry/domain/validators/node-version.js +3 -3
- package/dist/registry/domain/validators/oc-cli-version.js +3 -3
- package/dist/registry/domain/validators/plugins-requirements.d.ts +1 -1
- package/dist/registry/domain/validators/registry-configuration.d.ts +1 -1
- package/dist/registry/domain/validators/registry-configuration.js +11 -13
- package/dist/registry/domain/validators/uploaded-package.js +4 -6
- package/dist/registry/index.d.ts +2 -4
- package/dist/registry/index.js +7 -8
- package/dist/registry/middleware/base-url-handler.d.ts +1 -1
- package/dist/registry/middleware/cors.d.ts +1 -1
- package/dist/registry/middleware/discovery-handler.d.ts +1 -1
- package/dist/registry/middleware/file-uploads.d.ts +2 -2
- package/dist/registry/middleware/index.d.ts +2 -2
- package/dist/registry/middleware/index.js +1 -1
- package/dist/registry/middleware/request-handler.d.ts +1 -1
- package/dist/registry/middleware/request-handler.js +1 -1
- package/dist/registry/router.d.ts +1 -1
- package/dist/registry/router.js +8 -6
- package/dist/registry/routes/component-info.d.ts +3 -3
- package/dist/registry/routes/component-info.js +20 -10
- package/dist/registry/routes/component-preview.d.ts +2 -2
- package/dist/registry/routes/component-preview.js +3 -3
- package/dist/registry/routes/component.d.ts +2 -2
- package/dist/registry/routes/component.js +3 -3
- package/dist/registry/routes/components.d.ts +2 -2
- package/dist/registry/routes/components.js +5 -5
- package/dist/registry/routes/dependencies.d.ts +2 -2
- package/dist/registry/routes/dependencies.js +1 -1
- package/dist/registry/routes/helpers/apply-default-values.d.ts +1 -1
- package/dist/registry/routes/helpers/apply-default-values.js +2 -2
- package/dist/registry/routes/helpers/get-available-dependencies.js +1 -1
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +4 -6
- package/dist/registry/routes/helpers/get-component-fallback.js +4 -4
- package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +1 -3
- package/dist/registry/routes/helpers/get-component.d.ts +2 -4
- package/dist/registry/routes/helpers/get-component.js +15 -16
- package/dist/registry/routes/helpers/get-components-history.d.ts +2 -1
- package/dist/registry/routes/helpers/get-components-history.js +3 -1
- package/dist/registry/routes/index.d.ts +1 -1
- package/dist/registry/routes/index.js +10 -11
- package/dist/registry/routes/plugins.d.ts +2 -2
- package/dist/registry/routes/publish.d.ts +1 -1
- package/dist/registry/routes/publish.js +2 -2
- package/dist/registry/routes/static-redirector.d.ts +1 -1
- package/dist/registry/routes/static-redirector.js +10 -10
- package/dist/registry/views/index.d.ts +1 -1
- package/dist/registry/views/index.js +1 -1
- package/dist/registry/views/info.d.ts +2 -1
- package/dist/registry/views/info.js +88 -4
- package/dist/registry/views/partials/component-author.js +1 -1
- package/dist/registry/views/partials/component-parameters.d.ts +1 -1
- package/dist/registry/views/partials/component-parameters.js +2 -2
- package/dist/registry/views/partials/component-state.d.ts +1 -1
- package/dist/registry/views/partials/component-versions.d.ts +1 -1
- package/dist/registry/views/partials/components-dependencies.d.ts +1 -1
- package/dist/registry/views/partials/components-dependencies.js +1 -1
- package/dist/registry/views/partials/components-history.d.ts +1 -1
- package/dist/registry/views/partials/components-history.js +4 -2
- package/dist/registry/views/partials/components-list.d.ts +1 -1
- package/dist/registry/views/partials/components-list.js +14 -4
- package/dist/registry/views/partials/components-plugins.d.ts +1 -1
- package/dist/registry/views/partials/components-templates.d.ts +1 -1
- package/dist/registry/views/partials/selected-checkbox.d.ts +1 -1
- package/dist/registry/views/preview.d.ts +1 -1
- package/dist/resources/index.js +2 -2
- package/dist/types.d.ts +13 -8
- package/dist/utils/error-to-string.js +1 -1
- package/dist/utils/is-template-valid.d.ts +1 -1
- package/dist/utils/is-template-valid.js +1 -1
- package/dist/utils/module-exists.js +2 -2
- package/dist/utils/npm-utils.js +4 -4
- package/dist/utils/pLimit.js +3 -3
- package/dist/utils/put.js +4 -4
- package/dist/utils/strip-version.js +3 -3
- package/lefthook.yml +5 -0
- package/logintervals.md +1 -1
- package/package.json +6 -11
package/.husky/pre-commit
CHANGED
|
@@ -1,4 +1,53 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
. "$(dirname "$0")/_/husky.sh"
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
|
|
4
|
+
set -x
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
if [ "$LEFTHOOK" = "0" ]; then
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
call_lefthook()
|
|
12
|
+
{
|
|
13
|
+
dir="$(git rev-parse --show-toplevel)"
|
|
14
|
+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
|
|
15
|
+
cpuArch=$(uname -m | sed 's/aarch64/arm64/')
|
|
16
|
+
|
|
17
|
+
if test -n "$LEFTHOOK_BIN"
|
|
18
|
+
then
|
|
19
|
+
"$LEFTHOOK_BIN" "$@"
|
|
20
|
+
elif lefthook -h >/dev/null 2>&1
|
|
21
|
+
then
|
|
22
|
+
lefthook "$@"
|
|
23
|
+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
|
|
24
|
+
then
|
|
25
|
+
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
|
26
|
+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
|
27
|
+
then
|
|
28
|
+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
|
29
|
+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
|
30
|
+
then
|
|
31
|
+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
|
32
|
+
|
|
33
|
+
elif bundle exec lefthook -h >/dev/null 2>&1
|
|
34
|
+
then
|
|
35
|
+
bundle exec lefthook "$@"
|
|
36
|
+
elif yarn lefthook -h >/dev/null 2>&1
|
|
37
|
+
then
|
|
38
|
+
yarn lefthook "$@"
|
|
39
|
+
elif pnpm lefthook -h >/dev/null 2>&1
|
|
40
|
+
then
|
|
41
|
+
pnpm lefthook "$@"
|
|
42
|
+
elif swift package plugin lefthook >/dev/null 2>&1
|
|
43
|
+
then
|
|
44
|
+
swift package --disable-sandbox plugin lefthook "$@"
|
|
45
|
+
elif command -v npx >/dev/null 2>&1
|
|
46
|
+
then
|
|
47
|
+
npx lefthook "$@"
|
|
48
|
+
else
|
|
49
|
+
echo "Can't find lefthook in PATH"
|
|
50
|
+
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
call_lefthook run "pre-commit" "$@"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
|
|
4
|
+
set -x
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
if [ "$LEFTHOOK" = "0" ]; then
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
call_lefthook()
|
|
12
|
+
{
|
|
13
|
+
dir="$(git rev-parse --show-toplevel)"
|
|
14
|
+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
|
|
15
|
+
cpuArch=$(uname -m | sed 's/aarch64/arm64/')
|
|
16
|
+
|
|
17
|
+
if test -n "$LEFTHOOK_BIN"
|
|
18
|
+
then
|
|
19
|
+
"$LEFTHOOK_BIN" "$@"
|
|
20
|
+
elif lefthook -h >/dev/null 2>&1
|
|
21
|
+
then
|
|
22
|
+
lefthook "$@"
|
|
23
|
+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
|
|
24
|
+
then
|
|
25
|
+
"$dir/node_modules/lefthook/bin/index.js" "$@"
|
|
26
|
+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
|
27
|
+
then
|
|
28
|
+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
|
29
|
+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
|
30
|
+
then
|
|
31
|
+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
|
|
32
|
+
|
|
33
|
+
elif bundle exec lefthook -h >/dev/null 2>&1
|
|
34
|
+
then
|
|
35
|
+
bundle exec lefthook "$@"
|
|
36
|
+
elif yarn lefthook -h >/dev/null 2>&1
|
|
37
|
+
then
|
|
38
|
+
yarn lefthook "$@"
|
|
39
|
+
elif pnpm lefthook -h >/dev/null 2>&1
|
|
40
|
+
then
|
|
41
|
+
pnpm lefthook "$@"
|
|
42
|
+
elif swift package plugin lefthook >/dev/null 2>&1
|
|
43
|
+
then
|
|
44
|
+
swift package --disable-sandbox plugin lefthook "$@"
|
|
45
|
+
elif command -v npx >/dev/null 2>&1
|
|
46
|
+
then
|
|
47
|
+
npx lefthook "$@"
|
|
48
|
+
else
|
|
49
|
+
echo "Can't find lefthook in PATH"
|
|
50
|
+
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
call_lefthook run "prepare-commit-msg" "$@"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v0.49.52
|
|
4
|
+
- [#1364](https://github.com/opencomponents/oc/pull/1364) Move to Biome
|
|
5
|
+
|
|
6
|
+
### v0.49.51
|
|
7
|
+
- [#1363](https://github.com/opencomponents/oc/pull/1363) calculate sizes on packaging and show in registry UI if available
|
|
8
|
+
|
|
3
9
|
### v0.49.50
|
|
4
10
|
- [#1362](https://github.com/opencomponents/oc/pull/1362) update oc client to fix a bug with externals
|
|
5
11
|
|
package/biome.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
|
|
3
|
+
"organizeImports": {
|
|
4
|
+
"enabled": true
|
|
5
|
+
},
|
|
6
|
+
"javascript": {
|
|
7
|
+
"formatter": {
|
|
8
|
+
"trailingComma": "none",
|
|
9
|
+
"indentStyle": "space",
|
|
10
|
+
"quoteStyle": "single"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": {
|
|
14
|
+
"ignore": [
|
|
15
|
+
"src/components/oc-client/*",
|
|
16
|
+
"test/fixtures/*"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"linter": {
|
|
20
|
+
"enabled": true,
|
|
21
|
+
"rules": {
|
|
22
|
+
"recommended": true,
|
|
23
|
+
"complexity": {
|
|
24
|
+
"useLiteralKeys": "off"
|
|
25
|
+
},
|
|
26
|
+
"style": {
|
|
27
|
+
"noParameterAssign": "off",
|
|
28
|
+
"noNonNullAssertion": "off",
|
|
29
|
+
"useTemplate": "off"
|
|
30
|
+
},
|
|
31
|
+
"suspicious": {
|
|
32
|
+
"noExplicitAny": "off"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/cli/domain/clean.js
CHANGED
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.remove = exports.fetchList = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
9
|
const get_components_by_dir_1 = __importDefault(require("./get-components-by-dir"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const getComponentsByDir = (0, get_components_by_dir_1.default)();
|
|
11
11
|
async function fetchList(dirPath) {
|
|
12
12
|
const list = await getComponentsByDir(dirPath);
|
|
13
13
|
if (list.length === 0)
|
|
14
14
|
return [];
|
|
15
|
-
const toRemove = list.map(folder =>
|
|
15
|
+
const toRemove = list.map((folder) => node_path_1.default.join(folder, 'node_modules'));
|
|
16
16
|
return toRemove.filter(fs_extra_1.default.existsSync);
|
|
17
17
|
}
|
|
18
18
|
exports.fetchList = fetchList;
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
8
|
function getComponentsByDir() {
|
|
9
9
|
return async (componentsDir, componentsToRun) => {
|
|
10
10
|
const isOcComponent = (file) => {
|
|
11
|
-
const filePath =
|
|
12
|
-
const packagePath =
|
|
11
|
+
const filePath = node_path_1.default.resolve(componentsDir, file);
|
|
12
|
+
const packagePath = node_path_1.default.join(filePath, 'package.json');
|
|
13
13
|
let content;
|
|
14
14
|
try {
|
|
15
15
|
content = fs_extra_1.default.readJsonSync(packagePath);
|
|
@@ -20,17 +20,17 @@ function getComponentsByDir() {
|
|
|
20
20
|
if (!content.oc) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
|
-
const packagedProperty = content.oc
|
|
23
|
+
const packagedProperty = content.oc?.packaged;
|
|
24
24
|
return typeof packagedProperty === 'undefined';
|
|
25
25
|
};
|
|
26
26
|
try {
|
|
27
27
|
let dirContent = await fs_extra_1.default.readdir(componentsDir);
|
|
28
28
|
if (componentsToRun) {
|
|
29
|
-
dirContent = dirContent.filter(content => componentsToRun.includes(content));
|
|
29
|
+
dirContent = dirContent.filter((content) => componentsToRun.includes(content));
|
|
30
30
|
}
|
|
31
31
|
const components = dirContent
|
|
32
32
|
.filter(isOcComponent)
|
|
33
|
-
.map(component =>
|
|
33
|
+
.map((component) => node_path_1.default.resolve(componentsDir, component));
|
|
34
34
|
return components;
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
9
8
|
const resources_1 = __importDefault(require("../../resources/"));
|
|
9
|
+
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
10
10
|
const isMockValid = (plugin) => {
|
|
11
11
|
const isFunction = typeof plugin === 'function';
|
|
12
12
|
const isValidObject = !!plugin &&
|
|
@@ -32,7 +32,7 @@ const registerDynamicMocks = (ocJsonLocation, mocks, logger) => Object.entries(m
|
|
|
32
32
|
.map(([pluginName, source]) => {
|
|
33
33
|
let pluginMock;
|
|
34
34
|
try {
|
|
35
|
-
pluginMock = require(
|
|
35
|
+
pluginMock = require(node_path_1.default.resolve(ocJsonLocation, source));
|
|
36
36
|
}
|
|
37
37
|
catch (er) {
|
|
38
38
|
logger.err(String(er));
|
|
@@ -54,21 +54,19 @@ const registerDynamicMocks = (ocJsonLocation, mocks, logger) => Object.entries(m
|
|
|
54
54
|
.filter((pluginMock) => !!pluginMock);
|
|
55
55
|
const findPath = (pathToResolve, fileName) => {
|
|
56
56
|
const rootDir = fs_extra_1.default.realpathSync('.');
|
|
57
|
-
const fileToResolve =
|
|
57
|
+
const fileToResolve = node_path_1.default.join(pathToResolve, fileName);
|
|
58
58
|
if (!fs_extra_1.default.existsSync(fileToResolve)) {
|
|
59
59
|
if (pathToResolve === rootDir) {
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return findPath(parentDir, fileName);
|
|
66
|
-
}
|
|
62
|
+
const getParent = (pathToResolve) => pathToResolve.split('/').slice(0, -1).join('/');
|
|
63
|
+
const parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
|
|
64
|
+
return findPath(parentDir, fileName);
|
|
67
65
|
}
|
|
68
66
|
return fileToResolve;
|
|
69
67
|
};
|
|
70
68
|
function getMockedPlugins(logger, componentsDir) {
|
|
71
|
-
componentsDir =
|
|
69
|
+
componentsDir = node_path_1.default.resolve(componentsDir || '.');
|
|
72
70
|
let plugins = [];
|
|
73
71
|
const ocJsonFileName = settings_1.default.configFile.src.replace('./', '');
|
|
74
72
|
const ocJsonPath = findPath(componentsDir, ocJsonFileName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Template } from '../../../types';
|
|
2
|
-
import { Logger } from '../../logger';
|
|
1
|
+
import type { Template } from '../../../types';
|
|
2
|
+
import type { Logger } from '../../logger';
|
|
3
3
|
export default function getCompiler(options: {
|
|
4
4
|
compilerDep: string;
|
|
5
5
|
componentPath: string;
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
7
|
const clean_require_1 = __importDefault(require("../../../utils/clean-require"));
|
|
8
8
|
const install_compiler_1 = __importDefault(require("./install-compiler"));
|
|
9
9
|
function getCompiler(options) {
|
|
10
10
|
const { compilerDep, componentPath, logger, pkg } = options;
|
|
11
|
-
const compilerPath =
|
|
11
|
+
const compilerPath = node_path_1.default.join(componentPath, 'node_modules', compilerDep);
|
|
12
12
|
const compiler = (0, clean_require_1.default)(compilerPath, { justTry: true });
|
|
13
13
|
if (compiler) {
|
|
14
14
|
return Promise.resolve(compiler);
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
7
|
const module_exists_1 = __importDefault(require("../../../utils/module-exists"));
|
|
8
8
|
function getMissingDependencies(dependencies = {}) {
|
|
9
9
|
const missing = [];
|
|
10
|
-
|
|
11
|
-
const pathToModule =
|
|
10
|
+
for (const [dependency, version] of Object.entries(dependencies)) {
|
|
11
|
+
const pathToModule = node_path_1.default.resolve('node_modules/', dependency);
|
|
12
12
|
if (!(0, module_exists_1.default)(pathToModule)) {
|
|
13
13
|
missing.push(`${dependency}@${version || 'latest'}`);
|
|
14
14
|
}
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
return missing;
|
|
17
17
|
}
|
|
18
18
|
exports.default = getMissingDependencies;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Template } from '../../../types';
|
|
2
|
+
import type { Logger } from '../../logger';
|
|
3
3
|
export default function handleDependencies(options: {
|
|
4
4
|
components: string[];
|
|
5
5
|
logger: Logger;
|
|
@@ -3,25 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
7
|
const builtin_modules_1 = __importDefault(require("builtin-modules"));
|
|
7
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const
|
|
9
|
+
const resources_1 = __importDefault(require("../../../resources"));
|
|
10
|
+
const is_template_legacy_1 = __importDefault(require("../../../utils/is-template-legacy"));
|
|
9
11
|
const ensure_compiler_is_declared_as_devDependency_1 = __importDefault(require("./ensure-compiler-is-declared-as-devDependency"));
|
|
10
12
|
const get_compiler_1 = __importDefault(require("./get-compiler"));
|
|
11
13
|
const install_missing_dependencies_1 = __importDefault(require("./install-missing-dependencies"));
|
|
12
14
|
const link_missing_dependencies_1 = __importDefault(require("./link-missing-dependencies"));
|
|
13
|
-
const
|
|
14
|
-
const resources_1 = __importDefault(require("../../../resources"));
|
|
15
|
-
const getComponentPackageJson = (componentPath) => fs_extra_1.default.readJson(path_1.default.join(componentPath, 'package.json'));
|
|
15
|
+
const getComponentPackageJson = (componentPath) => fs_extra_1.default.readJson(node_path_1.default.join(componentPath, 'package.json'));
|
|
16
16
|
const union = (a, b) => [
|
|
17
17
|
...new Set([...a, ...b])
|
|
18
18
|
];
|
|
19
19
|
async function handleDependencies(options) {
|
|
20
20
|
const { components, logger, useComponentDependencies } = options;
|
|
21
21
|
const dependencies = {};
|
|
22
|
-
const addDependencies = (componentDependencies) =>
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const addDependencies = (componentDependencies) => {
|
|
23
|
+
for (const [dependency, version] of Object.entries(componentDependencies || {})) {
|
|
24
|
+
dependencies[dependency] = version;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
25
27
|
const templates = {};
|
|
26
28
|
const addTemplate = (templateName, template) => {
|
|
27
29
|
templates[templateName] = template;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Template } from '../../../types';
|
|
2
|
+
import type { Logger } from '../../logger';
|
|
3
3
|
export default function installCompiler(options: {
|
|
4
4
|
compilerPath: string;
|
|
5
5
|
componentPath: string;
|
|
@@ -26,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const index_1 = __importDefault(require("../../../resources/index"));
|
|
29
30
|
const clean_require_1 = __importDefault(require("../../../utils/clean-require"));
|
|
30
31
|
const is_template_valid_1 = __importDefault(require("../../../utils/is-template-valid"));
|
|
31
32
|
const npm = __importStar(require("../../../utils/npm-utils"));
|
|
32
|
-
const index_1 = __importDefault(require("../../../resources/index"));
|
|
33
33
|
async function installCompiler(options) {
|
|
34
34
|
const { compilerPath, componentPath, dependency, logger } = options;
|
|
35
35
|
logger.warn(index_1.default.messages.cli.INSTALLING_DEPS(dependency, componentPath));
|
|
@@ -26,17 +26,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
30
|
-
const get_missing_dependencies_1 = __importDefault(require("./get-missing-dependencies"));
|
|
31
|
-
const npm = __importStar(require("../../../utils/npm-utils"));
|
|
29
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
32
30
|
const index_1 = __importDefault(require("../../../resources/index"));
|
|
31
|
+
const npm = __importStar(require("../../../utils/npm-utils"));
|
|
32
|
+
const get_missing_dependencies_1 = __importDefault(require("./get-missing-dependencies"));
|
|
33
33
|
async function installMissingDependencies(options) {
|
|
34
34
|
const { dependencies, logger } = options;
|
|
35
35
|
const missing = (0, get_missing_dependencies_1.default)(dependencies);
|
|
36
36
|
if (!missing.length) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
const installPath =
|
|
39
|
+
const installPath = node_path_1.default.resolve('.');
|
|
40
40
|
logger.warn(index_1.default.messages.cli.INSTALLING_DEPS(missing.join(', '), installPath));
|
|
41
41
|
const npmOptions = {
|
|
42
42
|
dependencies: missing,
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const get_missing_dependencies_1 = __importDefault(require("./get-missing-dependencies"));
|
|
9
8
|
const index_1 = __importDefault(require("../../../resources/index"));
|
|
10
9
|
const strip_version_1 = __importDefault(require("../../../utils/strip-version"));
|
|
10
|
+
const get_missing_dependencies_1 = __importDefault(require("./get-missing-dependencies"));
|
|
11
11
|
async function linkMissingDependencies(options) {
|
|
12
12
|
const { componentPath, dependencies, logger } = options;
|
|
13
13
|
const missingDependencies = (0, get_missing_dependencies_1.default)(dependencies);
|
|
@@ -18,8 +18,8 @@ async function linkMissingDependencies(options) {
|
|
|
18
18
|
const symLinkType = 'dir';
|
|
19
19
|
for (const dependency of missingDependencies) {
|
|
20
20
|
const moduleName = (0, strip_version_1.default)(dependency);
|
|
21
|
-
const pathToComponentModule =
|
|
22
|
-
const pathToModule =
|
|
21
|
+
const pathToComponentModule = node_path_1.default.resolve(componentPath, 'node_modules', moduleName);
|
|
22
|
+
const pathToModule = node_path_1.default.resolve('.', 'node_modules', moduleName);
|
|
23
23
|
try {
|
|
24
24
|
await fs_extra_1.default.ensureSymlink(pathToComponentModule, pathToModule, symLinkType);
|
|
25
25
|
}
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
+
const resources_1 = __importDefault(require("../../../resources"));
|
|
7
8
|
const clean_require_1 = __importDefault(require("../../../utils/clean-require"));
|
|
8
9
|
const is_template_legacy_1 = __importDefault(require("../../../utils/is-template-legacy"));
|
|
9
10
|
const is_template_valid_1 = __importDefault(require("../../../utils/is-template-valid"));
|
|
10
|
-
const resources_1 = __importDefault(require("../../../resources"));
|
|
11
11
|
function requireTemplate(template, options) {
|
|
12
12
|
const requireOptions = options || {};
|
|
13
13
|
let ocTemplate;
|
|
@@ -17,12 +17,17 @@ function requireTemplate(template, options) {
|
|
|
17
17
|
if (requireOptions.compiler) {
|
|
18
18
|
template = `${template}-compiler`;
|
|
19
19
|
}
|
|
20
|
-
const localTemplate =
|
|
21
|
-
const relativeTemplate =
|
|
22
|
-
const componentRelativePath =
|
|
23
|
-
|
|
20
|
+
const localTemplate = node_path_1.default.join(__dirname, '../../../../node_modules', template);
|
|
21
|
+
const relativeTemplate = node_path_1.default.resolve('.', 'node_modules', template);
|
|
22
|
+
const componentRelativePath = node_path_1.default.join(requireOptions.componentPath, 'node_modules', template);
|
|
23
|
+
for (const pathToTry of [
|
|
24
|
+
componentRelativePath,
|
|
25
|
+
template,
|
|
26
|
+
localTemplate,
|
|
27
|
+
relativeTemplate
|
|
28
|
+
]) {
|
|
24
29
|
ocTemplate = ocTemplate || (0, clean_require_1.default)(pathToTry, { justTry: true });
|
|
25
|
-
}
|
|
30
|
+
}
|
|
26
31
|
if (!ocTemplate) {
|
|
27
32
|
throw new Error(resources_1.default.errors.cli.TEMPLATE_NOT_FOUND(template));
|
|
28
33
|
}
|
|
@@ -26,14 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
29
30
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
-
const path_1 = __importDefault(require("path"));
|
|
31
|
-
const install_template_1 = __importDefault(require("./install-template"));
|
|
32
31
|
const npm = __importStar(require("../../../utils/npm-utils"));
|
|
32
|
+
const install_template_1 = __importDefault(require("./install-template"));
|
|
33
33
|
const scaffold_1 = __importDefault(require("./scaffold"));
|
|
34
34
|
async function initTemplate(options) {
|
|
35
35
|
const { compiler, componentPath } = options;
|
|
36
|
-
const compilerPath =
|
|
36
|
+
const compilerPath = node_path_1.default.join(componentPath, 'node_modules', compiler);
|
|
37
37
|
const npmOptions = { initPath: componentPath, silent: true };
|
|
38
38
|
await fs_extra_1.default.ensureDir(componentPath);
|
|
39
39
|
await npm.init(npmOptions);
|
|
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const try_require_1 = __importDefault(require("try-require"));
|
|
30
|
+
const resources_1 = __importDefault(require("../../../resources"));
|
|
30
31
|
const is_template_valid_1 = __importDefault(require("../../../utils/is-template-valid"));
|
|
31
32
|
const npm = __importStar(require("../../../utils/npm-utils"));
|
|
32
|
-
const resources_1 = __importDefault(require("../../../resources"));
|
|
33
33
|
async function installTemplate(options) {
|
|
34
34
|
const { compiler, componentPath, logger, templateType } = options;
|
|
35
35
|
const errorMessage = 'template type not valid';
|
|
@@ -3,22 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const resources_1 = __importDefault(require("../../../resources"));
|
|
9
9
|
async function scaffold(options) {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const { compiler, compilerPath, componentName, componentPath, templateType } = options;
|
|
12
|
-
const baseComponentPath =
|
|
13
|
-
const baseComponentFiles =
|
|
14
|
-
const compilerPackage = await fs_extra_1.default.readJson(
|
|
12
|
+
const baseComponentPath = node_path_1.default.join(compilerPath, 'scaffold');
|
|
13
|
+
const baseComponentFiles = node_path_1.default.join(baseComponentPath, 'src');
|
|
14
|
+
const compilerPackage = await fs_extra_1.default.readJson(node_path_1.default.join(compilerPath, 'package.json'));
|
|
15
15
|
try {
|
|
16
16
|
await fs_extra_1.default.copy(baseComponentFiles, componentPath);
|
|
17
|
-
const componentPackage = await fs_extra_1.default.readJson(
|
|
17
|
+
const componentPackage = await fs_extra_1.default.readJson(node_path_1.default.join(componentPath, 'package.json'));
|
|
18
18
|
componentPackage.name = componentName;
|
|
19
19
|
componentPackage.scripts ?? (componentPackage.scripts = {});
|
|
20
20
|
(_a = componentPackage.scripts).start ?? (_a.start = `oc dev .. --components ${componentName}`);
|
|
21
|
-
(_b = componentPackage.scripts).build ?? (_b.build =
|
|
21
|
+
(_b = componentPackage.scripts).build ?? (_b.build = 'oc package .');
|
|
22
22
|
componentPackage.devDependencies[compiler] = compilerPackage.version;
|
|
23
23
|
await fs_extra_1.default.writeJson(componentPath + '/package.json', componentPackage, {
|
|
24
24
|
spaces: 2
|
|
@@ -26,8 +26,7 @@ async function scaffold(options) {
|
|
|
26
26
|
return { ok: true };
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
const url =
|
|
30
|
-
`the ${templateType} repo`;
|
|
29
|
+
const url = compilerPackage.bugs?.url || `the ${templateType} repo`;
|
|
31
30
|
throw resources_1.default.errors.cli.scaffoldError(url, String(error));
|
|
32
31
|
}
|
|
33
32
|
}
|