Skip to content

Commit ae79996

Browse files
author
Miki
authored
Manually backports Windows changes from #2601 (#2647)
* [Windows] Replaces `rm -rf` with `remove.js` * [dev/build] Facilitates using zipped archives of node releases * [div/build] Introduces Windows as a platform * [dev/build] Corrects cleaning of platform specific build artifacts * [dev/build] Enhances the cleanup of downloaded node binaries * [opensearch-dashboards-plugin] Removes prohibition on installing plugins on Windows * [@osd/utils] Adds a method to standardize path references across platforms * [dev/build] Standardize paths in tests * [@osd/telemetry-tools] Normalizes the collection paths * [plugins/url-forwarding] Fixes the usage of `normalizePath` across node and browser * [@osd/pm] Allows symlink created for tests without elevated privileges on Windows * [@osd/opensearch] Allows usage of Windows snapshots in integration tests * [@osd/opensearch] Employs absolute paths in tests * [@osd/apm-config-loader] Employs absolute paths in tests * [core/server] Employs absolute and posix references to paths * [@osd/optimizer] Standardize paths in tests * [@osd/tests] Employs absolute paths in tests * [@osd/pm] Standardize paths in project trees * [plugins/telemetry] Accommodates the inability of Windows to create unreadable files for testing * [@osd/config-schema] Normalize paths in tests * [@osd/plugin-helpers] Standardize paths in tests * [@osd/plugin-generator] Standardize paths in tests * [Windows] Update changelog backport PR: #2601 Signed-off-by: Miki <miki@amazon.com>
1 parent 054e550 commit ae79996

File tree

71 files changed

+360
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+360
-141
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
2323
* [Multi DataSource] Add data source config to opensearch-dashboards-docker ([#2557](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2557))
2424
* [Multi DataSource] Make text content dynamically translated & update unit tests ([#2570](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2570))
2525
* [Vis Builder] Change classname prefix wiz to vb ([#2581](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2581/files))
26+
* [Windows] Facilitate building and running OSD and plugins on Windows platforms ([#2601](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2601))
2627

2728
### 🐛 Bug Fixes
2829
* [Vis Builder] Fixes auto bounds for timeseries bar chart visualization ([2401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2401))

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"makelogs": "node scripts/makelogs",
6666
"uiFramework:compileCss": "cd packages/osd-ui-framework && yarn compileCss",
6767
"osd:watch": "node scripts/opensearch_dashboards --dev --logging.json=false",
68-
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
68+
"build:types": "node scripts/remove.js ./target/types && tsc --p tsconfig.types.json",
6969
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
7070
"osd:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook",
7171
"spec_to_console": "node scripts/spec_to_console",
@@ -410,6 +410,7 @@
410410
"mutation-observer": "^1.0.3",
411411
"ngreact": "^0.5.1",
412412
"nock": "12.0.3",
413+
"node-stream-zip": "^1.15.0",
413414
"normalize-path": "^3.0.0",
414415
"nyc": "^15.1.0",
415416
"pixelmatch": "^5.1.0",
@@ -459,4 +460,4 @@
459460
"node": "14.20.0",
460461
"yarn": "^1.21.1"
461462
}
462-
}
463+
}

packages/osd-apm-config-loader/src/utils/get_config_file_paths.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('getConfigurationFilePaths', () => {
4040

4141
expect(getConfigurationFilePaths(argv)).toEqual([
4242
resolve(cwd, join('.', 'relative-path')),
43-
'/absolute-path',
43+
resolve('/absolute-path'),
4444
]);
4545
});
4646

packages/osd-config-schema/src/errors/__snapshots__/schema_error.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/osd-config-schema/src/errors/schema_error.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
import { relative } from 'path';
31+
import { relative, sep } from 'path';
3232
import { SchemaError } from '.';
3333

3434
/**
@@ -37,7 +37,7 @@ import { SchemaError } from '.';
3737
export const cleanStack = (stack: string) =>
3838
stack
3939
.split('\n')
40-
.filter((line) => !line.includes('node_modules/') && !line.includes('internal/'))
40+
.filter((line) => !line.includes('node_modules' + sep) && !line.includes('internal/'))
4141
.map((line) => {
4242
const parts = /.*\((.*)\).?/.exec(line) || [];
4343

@@ -46,7 +46,11 @@ export const cleanStack = (stack: string) =>
4646
}
4747

4848
const path = parts[1];
49-
return line.replace(path, relative(process.cwd(), path));
49+
// Cannot use `standardize` from `@osd/utils
50+
let relativePath = relative(process.cwd(), path);
51+
if (process.platform === 'win32') relativePath = relativePath.replace(/\\/g, '/');
52+
53+
return line.replace(path, relativePath);
5054
})
5155
.join('\n');
5256

packages/osd-opensearch-archiver/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"devOnly": true
88
},
99
"scripts": {
10-
"osd:bootstrap": "rm -rf target && tsc",
11-
"osd:watch": "rm -rf target && tsc --watch"
10+
"osd:bootstrap": "node ../../scripts/remove.js target && tsc",
11+
"osd:watch": "node ../../scripts/remove.js target && tsc --watch"
1212
},
1313
"dependencies": {
1414
"@osd/dev-utils": "1.0.0",
@@ -17,4 +17,4 @@
1717
"devDependencies": {
1818
"@types/elasticsearch": "^5.0.33"
1919
}
20-
}
20+
}

packages/osd-opensearch/src/artifact.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,14 @@ async function getArtifactSpecForSnapshotFromUrl(urlVersion, log) {
186186
// issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/475
187187
const platform = process.platform === 'win32' ? 'windows' : process.platform;
188188
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
189-
if (platform !== 'linux') {
190-
throw createCliError(`Snapshots are only available for Linux`);
189+
const extension = process.platform === 'win32' ? 'zip' : 'tar.gz';
190+
191+
if (platform !== 'linux' && platform !== 'windows') {
192+
throw createCliError(`Snapshots are only available for Linux and Windows`);
191193
}
192194

193195
const latestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}-SNAPSHOT`;
194-
const latestFile = `opensearch-min-${desiredVersion}-SNAPSHOT-${platform}-${arch}-latest.tar.gz`;
196+
const latestFile = `opensearch-min-${desiredVersion}-SNAPSHOT-${platform}-${arch}-latest.${extension}`;
195197
const completeLatestUrl = `${latestUrl}/${latestFile}`;
196198

197199
let { abc, resp } = await verifySnapshotUrl(completeLatestUrl, log);

packages/osd-opensearch/src/artifact.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ describe('Artifact', () => {
163163
});
164164
});
165165

166-
it('should throw when on a non-Linux platform', async () => {
166+
it('should throw when on a non-Linux or non-Windows platform', async () => {
167167
Object.defineProperties(process, {
168168
platform: {
169-
value: 'win32',
169+
value: 'darwin',
170170
},
171171
arch: {
172172
value: ORIGINAL_ARCHITECTURE,

packages/osd-opensearch/src/utils/decompress.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ beforeEach(() => {
5252
fs.copyFileSync(path.resolve(fixturesFolder, 'snapshot.tar.gz'), tarGzSnapshot);
5353
});
5454

55-
afterEach(() => {
56-
del.sync(tmpFolder, { force: true });
55+
afterEach(async () => {
56+
await del(tmpFolder, { force: true });
5757
});
5858

5959
test('zip strips root directory', async () => {

packages/osd-opensearch/src/utils/extract_config_files.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jest.mock('fs', () => ({
3636

3737
const { extractConfigFiles } = require('./extract_config_files');
3838
const fs = require('fs');
39+
const path = require('path');
3940

4041
afterEach(() => {
4142
jest.clearAllMocks();
@@ -55,7 +56,7 @@ test('copies file', () => {
5556
extractConfigFiles(['path=/data/foo.yml'], '/opensearch');
5657

5758
expect(fs.readFileSync.mock.calls[0][0]).toEqual('/data/foo.yml');
58-
expect(fs.writeFileSync.mock.calls[0][0]).toEqual('/opensearch/config/foo.yml');
59+
expect(fs.writeFileSync.mock.calls[0][0]).toEqual(path.resolve('/opensearch/config/foo.yml'));
5960
});
6061

6162
test('ignores file which does not exist', () => {

0 commit comments

Comments
 (0)