Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Node.js >=14.20.1 <19 #4071

Merged
merged 38 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0ddddce
Bump Node.js requirements to 18
AMoo-Miki Mar 8, 2023
2dc3185
Replace `lmdb-store` with `lmdb`
AMoo-Miki Mar 8, 2023
9fe5086
Bump `elastic-apm-node` to the latest minor
AMoo-Miki Mar 8, 2023
c2be7fa
Replace webpack and plugins with a patched version that uses xxhash64
AMoo-Miki Mar 8, 2023
a77443f
Replace `fs.rmdir` with `fs.rm` in cross-platform tests
AMoo-Miki Mar 16, 2023
11de409
Increase listener limit
AMoo-Miki Apr 17, 2023
6ddf265
Add promise-stripping serializer
AMoo-Miki Apr 18, 2023
77f11e0
Bump heap for CI
AMoo-Miki Apr 18, 2023
ba8f84b
Correct use of fs/promises in @osd/pm
AMoo-Miki Apr 18, 2023
ae5c780
Use fs/promise in plugin post-install cleanup
AMoo-Miki Apr 18, 2023
9f4cf53
Set the test server's host to `0.0.0.0`
AMoo-Miki Apr 19, 2023
c82b6ab
Sync `.node-version` file
AMoo-Miki Apr 19, 2023
35bab54
Support both `isPrimary`, for Node 18, and `isMaster`, for Node 14
AMoo-Miki Apr 19, 2023
060a2c8
Add types when using `isDeepStrictEqual`
AMoo-Miki Apr 19, 2023
b77ff74
Add names to `SchemaError` to log more specific errors
AMoo-Miki Apr 19, 2023
a13e9c9
Fix failing vega visualization tests outside the CI
AMoo-Miki Apr 19, 2023
5926e4f
Fix snapshot of errors thrown for undefined accessors
AMoo-Miki Apr 19, 2023
c54e795
Fix flakiness of log_rotator
AMoo-Miki Apr 19, 2023
d98158b
Fix asynchronous `fs` usafe in plugin discover
AMoo-Miki Apr 19, 2023
b0bbeed
Fix mocks in @osd/optimizer
AMoo-Miki Apr 19, 2023
aaff6a7
Fix memory leaks caused by setting states on unloaded components
AMoo-Miki Apr 19, 2023
59040e8
Bump Node in Dockerfile
AMoo-Miki Apr 19, 2023
ef195cc
Remove the response `close` event as an indicator of the requesting f…
AMoo-Miki Apr 19, 2023
9be7e50
[BWC] Timeout after 3 mins of waiting for OSD to be running in tests
AMoo-Miki Apr 19, 2023
0a396cb
Make build use the same node version that tests are run against
AMoo-Miki Apr 19, 2023
a907736
Make Node resolve DNS by IPv4 first
AMoo-Miki Apr 19, 2023
a9e2db0
Standardize patterns used by plugin discovery
AMoo-Miki Apr 20, 2023
79d6f15
Mock fetch in SenseEditor tests
AMoo-Miki Apr 21, 2023
005e3e6
Restore node-sass usage to fix build performance
ananzh Apr 21, 2023
5319181
Revert "[CI] setup Chrome and utilize binary path (#3997)"
AMoo-Miki May 17, 2023
ce5f732
Prevent fast-fail while running functional test in CI
AMoo-Miki May 17, 2023
dd3ce63
Revert "Temporarily hardcode chromedriver to 112.0.0 to enable all ft…
AMoo-Miki May 17, 2023
f9c56ce
Save Cypress results artifacts during CI
AMoo-Miki May 17, 2023
2e073e4
Add missing required dependency on `set-value`
AMoo-Miki May 17, 2023
5070935
Prevent multiple calls to bootstrap's shutdown
AMoo-Miki May 18, 2023
d2d4714
Use Node 18.16.0 in distributions
AMoo-Miki May 20, 2023
fa897a8
Normalize test snapshots across Node 14, 16, and 18
AMoo-Miki May 20, 2023
90e7b2a
Update CHANGELOG for Node.js >=14.20.1 <19 support
AMoo-Miki May 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions .github/workflows/build_and_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ env:
TEST_OPENSEARCH_TRANSPORT_PORT: 9403
TEST_OPENSEARCH_PORT: 9400
OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true
# Version 112.0.5615.0
CHROME_VERSION: 1109208
NODE_OPTIONS: "--max-old-space-size=6144 --dns-result-order=ipv4first"

jobs:
build-lint-test:
name: Build and Verify on ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
Expand Down Expand Up @@ -137,22 +137,6 @@ jobs:
steps:
- run: echo Running functional tests for ciGroup${{ matrix.group }}

- name: Setup Chrome
id: setup-chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: ${{ env.CHROME_VERSION }}

- name: Set Chrome Path
if: matrix.os != 'windows-latest'
run: |
echo "TEST_BROWSER_BINARY_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $GITHUB_ENV

- name: Set Chrome Path (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "TEST_BROWSER_BINARY_PATH=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV

- name: Configure git's autocrlf (Windows only)
if: matrix.os == 'windows-latest'
run: |
Expand Down Expand Up @@ -403,6 +387,7 @@ jobs:
with:
name: ${{ matrix.version }}-test-failures
path: |
./artifacts/bwc_tmp/test/cypress/videos/without-security/*
./artifacts/bwc_tmp/test/cypress/screenshots/without-security/*
./artifacts/bwc_tmp/test/cypress/videos/*
./artifacts/bwc_tmp/test/cypress/screenshots/*
./artifacts/bwc_tmp/test/cypress/results/*
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
retention-days: 1
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.16.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.16.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as noted. Build repo uses this file to build OpenSearch Dashboards so we should take this into consideration if the build system needs to publish CI Runner images with Node 18 installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ananzh are we going to create a subsequent PR for this or fix this one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main will continue to have 18; 2.8 will use 16.

3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Vis Builder] Add persistence to visualizations inner state ([#3751](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3751))
- [Table Visualization] Move format table, consolidate types and add unit tests ([#3397](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3397))
- [Multiple Datasource] Support Amazon OpenSearch Serverless ([#3957](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3957))
- Add support for Node.js >=14.20.1 <19 ([#4071](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4071))

### 🐛 Bug Fixes

- [Vis Builder] Fixes auto bounds for timeseries bar chart visualization ([2401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2401))
Expand Down Expand Up @@ -216,7 +218,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Prevent primitive linting limitations from being applied to unit tests found under `src/setup_node_env` ([#3403](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3403))
- [Tests] Fix unit tests for `get_keystore` ([#3854](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3854))
- [Tests] Use `scripts/use_node` instead of `node` in functional test plugins ([#3783](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3783))
- Temporarily hardcode the largest support `chromedriver` version to `112.0.0` to enable all ftr tests ([#3976](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3976))

## [2.x]

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VERSION=14.20.1
ARG NODE_VERSION=18.16.0
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
FROM node:${NODE_VERSION} AS base

ENV HOME '.'
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"test:jest:ci": "scripts/use_node scripts/jest --ci --colors --runInBand",
"test:jest:ci:coverage": "scripts/use_node scripts/jest --ci --colors --runInBand --coverage",
"test:jest_integration": "scripts/use_node scripts/jest_integration",
"test:jest_integration:ci": "scripts/use_node scripts/jest_integration --ci --colors --max-old-space-size=5120",
"test:jest_integration:ci": "scripts/use_node scripts/jest_integration --ci --colors",
"test:mocha": "scripts/use_node scripts/mocha",
"test:mocha:coverage": "yarn nyc --reporter=text-summary --reporter=lcov --report-dir=./target/opensearch-dashboards-coverage/mocha scripts/use_node scripts/mocha",
"test:ftr": "scripts/use_node scripts/functional_tests",
Expand Down Expand Up @@ -81,7 +81,7 @@
"url": "https://github.com/opensearch-project/opensearch-dashboards.git"
},
"resolutions": {
"**/@types/node": "^14.17.32",
"**/@types/node": "~18.7.0",
"**/ansi-regex": "^5.0.1",
"**/async": "^3.2.3",
"**/d3-color": "^3.1.0",
Expand All @@ -97,6 +97,7 @@
"**/unset-value": "^2.0.1",
"**/jest-config": "npm:@amoo-miki/jest-config@27.5.1",
"**/jest-jasmine2": "npm:@amoo-miki/jest-jasmine2@27.5.1",
"**/set-value": "^4.1.0",
"**/xml2js": "^0.5.0",
"**/yaml": "^2.2.2"
},
Expand Down Expand Up @@ -167,7 +168,7 @@
"deep-freeze-strict": "^1.1.1",
"del": "^6.1.1",
"dns-sync": "^0.2.1",
"elastic-apm-node": "^3.7.0",
"elastic-apm-node": "^3.43.0",
"elasticsearch": "^16.7.0",
"http-aws-es": "npm:@zhongnansu/http-aws-es@6.0.1",
"execa": "^4.0.2",
Expand All @@ -177,7 +178,7 @@
"getos": "^3.2.1",
"glob": "^7.1.7",
"glob-all": "^3.2.1",
"globby": "^8.0.1",
"globby": "^11.1.0",
"handlebars": "4.7.7",
"hjson": "3.2.1",
"http-proxy-agent": "^2.1.0",
Expand Down Expand Up @@ -211,6 +212,7 @@
"rison-node": "1.0.2",
"rxjs": "^6.5.5",
"semver": "^5.7.0",
"set-value": "^4.1.0",
"source-map-support": "^0.5.19",
"symbol-observable": "^1.2.0",
"tar": "^6.1.11",
Expand Down Expand Up @@ -301,7 +303,7 @@
"@types/mock-fs": "^4.10.0",
"@types/moment-timezone": "^0.5.12",
"@types/mustache": "^0.8.31",
"@types/node": "^14.17.32",
"@types/node": "~18.7.0",
"@types/node-forge": "^1.0.1",
"@types/normalize-path": "^3.0.0",
"@types/pegjs": "^0.10.1",
Expand Down Expand Up @@ -396,7 +398,7 @@
"immer": "^9.0.6",
"intl-messageformat-parser": "^1.4.0",
"jest": "^27.5.1",
"jest-canvas-mock": "^2.3.1",
"jest-canvas-mock": "^2.5.1",
"jest-raw-loader": "^1.0.1",
"jimp": "^0.14.0",
"jquery": "^3.5.0",
Expand Down Expand Up @@ -468,7 +470,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "^14.20.1",
"node": ">=14.20.1 <19",
"yarn": "^1.22.10"
}
}
2 changes: 1 addition & 1 deletion packages/osd-ace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"@osd/babel-preset": "1.0.0",
"raw-loader": "^4.0.2",
"typescript": "4.0.2",
"webpack": "^4.41.5"
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2"
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions packages/osd-config-schema/src/errors/schema_error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ import { SchemaError } from '.';

import { standardize, getRepoRoot } from '@osd/cross-platform';

// ToDo: Remove this logic when Node 14 support is removed
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
const isNode14 = process.version.startsWith('v14.');

/**
* Make all paths in stacktrace relative.
*/
export const cleanStack = (stack: string) =>
stack
export const cleanStack = (stack: string) => {
const result = stack
.split('\n')
.filter((line) => !line.includes('node_modules' + sep) && !line.includes('internal/'))
.map((line) => {
Expand All @@ -54,6 +57,11 @@ export const cleanStack = (stack: string) =>
})
.join('\n');

return isNode14
? result.replace(/Error:\s([^\n]+)\n\s*at new ([^ ]+) [^\n]*\n/, '$2: $1\n')
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
: result;
};

it('includes stack', () => {
try {
throw new SchemaError('test');
Expand Down
1 change: 1 addition & 0 deletions packages/osd-config-schema/src/errors/schema_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class SchemaError extends Error {
constructor(message: string, cause?: Error) {
super(message);
this.cause = cause;
this.name = this.constructor.name;

// Set the prototype explicitly, see:
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Expand Down
18 changes: 9 additions & 9 deletions packages/osd-config/src/config_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ test('throws if config at path does not match schema', async () => {
);

await expect(valuesReceived).toMatchInlineSnapshot(`
Array [
[Error: [config validation of [key]]: expected value of type [string] but got [number]],
]
`);
Array [
[ValidationError: [config validation of [key]]: expected value of type [string] but got [number]],
]
`);
});

test('re-validate config when updated', async () => {
Expand All @@ -120,11 +120,11 @@ test('re-validate config when updated', async () => {
rawConfig$.next({ key: 123 });

await expect(valuesReceived).toMatchInlineSnapshot(`
Array [
"value",
[Error: [config validation of [key]]: expected value of type [string] but got [number]],
]
`);
Array [
"value",
[ValidationError: [config validation of [key]]: expected value of type [string] but got [number]],
]
`);
});

test("returns undefined if fetching optional config at a path that doesn't exist", async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/osd-cross-platform/src/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import path from 'path';
import fs from 'fs';
import { access, rmdir, mkdir, writeFile, symlink } from 'fs/promises';
import { access, rm, mkdir, writeFile, symlink } from 'fs/promises';

import {
resolveToFullNameSync,
Expand Down Expand Up @@ -43,9 +43,9 @@ describe('Cross Platform', () => {
try {
// If leftover artifacts were found, get rid of them
await access(tmpTestFolder);
await rmdir(tmpTestFolder, { recursive: true });
await rm(tmpTestFolder, { recursive: true });
} catch (ex) {
// Do nothing; if `rmdir` failed, let the `mkdir` below throw the error
// Do nothing; if `rm` failed, let the `mkdir` below throw the error
}

await mkdir(tmpTestFolder);
Expand All @@ -60,7 +60,7 @@ describe('Cross Platform', () => {

afterAll(async () => {
try {
await rmdir(tmpTestFolder, { recursive: true });
await rm(tmpTestFolder, { recursive: true });
} catch (ex) {
// Do nothing
}
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"execa": "^4.0.2",
"exit-hook": "^2.2.0",
"getopts": "^2.2.5",
"globby": "^8.0.1",
"globby": "^11.1.0",
"load-json-file": "^6.2.0",
"markdown-it": "^12.3.2",
"moment": "^2.24.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-dev-utils/src/proc_runner/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
await withTimeout(
async () => {
log.debug(`Sending "${signal}" to proc "${name}"`);
await treeKillAsync(childProcess.pid, signal);
await treeKillAsync(childProcess.pid!, signal);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the non-null assertion instead of optional chaining?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is due to this error

ERROR Error: Command failed with exit code 2: /usr/share/yarn/bin/yarn.js run osd:bootstrap
      error Command failed with exit code 2.
      error Command failed with exit code 2.
      $ yarn build
      $ tsc
      src/proc_runner/proc.ts(156,29): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
        Type 'undefined' is not assignable to type 'number'.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
          at makeError (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:25045:11)
          at handlePromise (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:23981:26)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at async /home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:9238:9
          at async scheduleItem (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:11285:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The problem is with the childProcess.pid value. In Node.js, the pid is undefined if the child process has not been successfully spawned (or if the child process has already exited). Hence, childProcess.pid is of type number | undefined. The treeKillAsync function expects a PID of type number, not number | undefined. Therefore, we see ts throws an error.

! allows ts to treat childProcess.pid as type number rather than number | undefined. An optional chain childProcess.pid? would not solve the issue because it would still result in undefined if pid doesn't exist, and treeKillAsync requires a number. Here is the result of using ?:

ubuntu@ip-172-31-55-237:~/OpenSearch-Dashboards$ yarn osd bootstrap
yarn run v1.22.19
$ scripts/use_node scripts/osd bootstrap
 info [opensearch-dashboards] running yarn

$ scripts/use_node ./preinstall_check
[1/4] Resolving packages...
warning Resolution field "typescript@4.0.2" is incompatible with requested version "typescript@~4.5.2"
success Already up-to-date.

 succ yarn.lock analysis completed without any issues
 succ 8 bootstrap builds are cached
 info [@osd/dev-utils] running [osd:bootstrap] script
ERROR [bootstrap] failed:
ERROR Error: Command failed with exit code 2: /usr/share/yarn/bin/yarn.js run osd:bootstrap
      error Command failed with exit code 2.
      error Command failed with exit code 2.
      $ yarn build
      $ tsc
      src/proc_runner/proc.ts(156,46): error TS1109: Expression expected.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
          at makeError (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:25045:11)
          at handlePromise (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:23981:26)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at async /home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:9238:9
          at async scheduleItem (/home/ubuntu/OpenSearch-Dashboards/packages/osd-pm/dist/index.js:11285:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
``

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - I was suggesting that what you really needed here was a optional chaining with a fallback value so that you never pass undefined to treeKillAsync. The non-null assertion doesn't do anything other than tell typescript not to worry about the potential of undefined - but if pid is undefined, you'll still pass that to a function that isn't prepared to handle that. What you probably want instead is a type guard, so that you only call treeKillAsync when pid is defined.

await outcomePromise;
},
STOP_TIMEOUT,
async () => {
log.warning(
`Proc "${name}" was sent "${signal}" didn't emit the "exit" or "error" events after ${STOP_TIMEOUT} ms, sending SIGKILL`
);
await treeKillAsync(childProcess.pid, 'SIGKILL');
await treeKillAsync(childProcess.pid!, 'SIGKILL');
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export function createAbsolutePathSerializer(
) {
const rootPaths = Array.isArray(rootPath) ? rootPath : [rootPath];

if (process.platform === 'win32') {
rootPaths.push(...rootPaths.map((name) => name.replace(/\\/g, '/')));
}
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved

return {
test: (value: any) =>
typeof value === 'string' && rootPaths.some((path) => value.startsWith(path)),
Expand Down
1 change: 1 addition & 0 deletions packages/osd-dev-utils/src/serializers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export * from './strip_ansi_serializer';
export * from './recursive_serializer';
export * from './any_instance_serizlizer';
export * from './replace_serializer';
export * from './strip_promises_serizlizer';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const createStripPromisesSerializer = () => ({
joshuarrrr marked this conversation as resolved.
Show resolved Hide resolved
serialize: (value: string) => value.replace(/("value": Promise) \{[^}]+}/gm, '$1 {}'),
test: (value: any) => typeof value === 'string',
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
* under the License.
*/

import Path from 'path';
import { resolve } from 'path';
import { standardize } from '@osd/cross-platform';

import globby from 'globby';

Expand All @@ -47,24 +48,23 @@ export function simpleOpenSearchDashboardsPlatformPluginDiscovery(
...scanDirs.reduce(
(acc: string[], dir) => [
...acc,
Path.resolve(dir, '*/opensearch_dashboards.json'),
Path.resolve(dir, '*/*/opensearch_dashboards.json'),
Path.resolve(dir, '*/*/*/opensearch_dashboards.json'),
Path.resolve(dir, '*/*/*/*/opensearch_dashboards.json'),
Path.resolve(dir, '*/*/*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/opensearch_dashboards.json'),
resolve(dir, '*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/*/opensearch_dashboards.json'),
resolve(dir, '*/*/*/*/*/opensearch_dashboards.json'),
],
[]
),
...pluginPaths.map((path) => Path.resolve(path, `opensearch_dashboards.json`)),
...pluginPaths.map((path) => resolve(path, `opensearch_dashboards.json`)),
])
);

const manifestPaths = globby.sync(patterns, { absolute: true }).map((path) =>
// absolute paths returned from globby are using normalize or
// something so the path separators are `/` even on windows,
// Path.resolve solves this
Path.resolve(path)
);
const standardizedPatterns = patterns.map((pattern) => standardize(pattern));

const manifestPaths = globby
.sync(standardizedPatterns, { absolute: true })
.map((path) => standardize(resolve(path)));

return manifestPaths.map(parseOpenSearchDashboardsPlatformPlugin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"glob-all": "^3.2.1",
"lru-cache": "^4.1.5",
"resolve": "^1.7.1",
"webpack": "^4.41.5"
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2"
}
}
4 changes: 2 additions & 2 deletions packages/osd-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"del": "^6.1.1",
"getopts": "^2.2.5",
"pegjs": "0.10.0",
"sass-loader": "^10.2.0",
"sass-loader": "^10.4.1",
"style-loader": "^1.1.3",
"supports-color": "^7.0.0",
"url-loader": "^2.2.0",
"webpack": "^4.41.5",
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2",
"webpack-cli": "^4.9.2"
}
}
Loading