Remove mentions of the preview extension (#1403)

* Revert changes from the preview branch and prepare for production

* Add i18n import command to the main loc import function, style fix in gulpfile.js

* Remove mentions of preview extension

* Add absent releases, disable format for the whole file

* Update dependencies

* Fix eslint problems
This commit is contained in:
Yuri Skorokhodov 2020-09-21 10:11:39 +03:00 коммит произвёл GitHub
Родитель 4dfc9ffdec
Коммит d55f3c22ee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 12547 добавлений и 12396 удалений

1
.vscode/settings.json поставляемый
Просмотреть файл

@ -2,6 +2,7 @@
{
"javascript.validate.enable": false,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"files.trimTrailingWhitespace": true,
"eslint.enable": true,
"editor.insertSpaces": true,

Просмотреть файл

@ -1,3 +1,20 @@
## 0.17.0
* Enhanced extension security [#1339](https://github.com/microsoft/vscode-react-native/pull/1339), [#1350](https://github.com/microsoft/vscode-react-native/pull/1350), [#1355](https://github.com/microsoft/vscode-react-native/pull/1355), [#1362](https://github.com/microsoft/vscode-react-native/pull/1362)
* Updated extension troubleshooting for the Expo debugging case [#1338](https://github.com/microsoft/vscode-react-native/pull/1338)
* Fixed the Github organisation name capitalization in URLs to the repository, thanks to [Frieder Bluemle(@friederbluemle)](https://github.com/friederbluemle) [#1324](https://github.com/microsoft/vscode-react-native/pull/1324)
* Updated Packager statusbar indicator representation [#1340](https://github.com/microsoft/vscode-react-native/pull/1340), [#1353](https://github.com/microsoft/vscode-react-native/pull/1353):
* Now there are two representations available: `Full` and `Short`. To change it add `react-native.packager.status-indicator` property with a value `Full` for full representation or `Short` for icon only mode. [More info](https://github.com/microsoft/vscode-react-native/pull/1353).
## 0.16.1
* Improved extension security [#1310](https://github.com/microsoft/vscode-react-native/pull/1310), [#1329](https://github.com/microsoft/vscode-react-native/pull/1329)
* Fixed the incorrect handling of spaces in `adb` path from `local.properties` [#1326](https://github.com/microsoft/vscode-react-native/pull/1326)
* Internal changes:
* Migrated from TSLint to ESLint [#1315](https://github.com/microsoft/vscode-react-native/pull/1315)
* Implemented service for running different checks of the extension work [#1309](https://github.com/microsoft/vscode-react-native/pull/1309), [#1322](https://github.com/microsoft/vscode-react-native/pull/1322)
* Smoke tests were updated to work with VS Code 1.45.1 and Expo SDK 38
## 0.16.0
* Improved extension security [#1253](https://github.com/microsoft/vscode-react-native/pull/1253)
* Updated extension license to MIT [#1286](https://github.com/microsoft/vscode-react-native/pull/1286)

Просмотреть файл

@ -1,43 +1,8 @@
# React Native Tools (Preview)
# React Native Tools
[![Build Status](https://dev.azure.com/vscode-webdiag-extensions/VS%20Code%20WebDiag%20extensions/_apis/build/status/%5BUnit%20tests%5D%20vscode-react-native%20%5Bmaster%5D?branchName=preview)](https://dev.azure.com/vscode-webdiag-extensions/VS%20Code%20WebDiag%20extensions/_build/latest?definitionId=60&branchName=preview)
![VS Marketplace version](https://vsmarketplacebadge.apphb.com/version-short/msjsdiag.vscode-react-native-preview.svg)
![VS Marketplace rating](https://vsmarketplacebadge.apphb.com/rating-star/msjsdiag.vscode-react-native-preview.svg)
> This is a preview version of the updated React Native Tools extension. It's not recommended to use the preview version and the stable one at the same time.
## React Native Tools Preview migration guide
In order to use the preview version of the extension it's required to add `-preview` suffix in the `type` field of a debug configuration of the RNT stable extension. The difference between the configurations is shown below:
- React Native debug configuration:
```diff
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
- "type": "reactnative",
+ "type": "reactnative-preview",
"request": "launch",
"platform": "android"
}
```
- React Native Hermes debug configuration:
```diff
{
"name": "Debug Android (Hermes)",
"cwd": "${workspaceFolder}",
- "type": "reactnativedirect",
+ "type": "reactnativedirect-preview",
"request": "launch",
"platform": "android"
}
```
We also added `(Preview)` suffix to Command Palette command names.
![React Native commands preview](https://raw.githubusercontent.com/Microsoft/vscode-react-native/preview/images/command-palette-preview.png)
To avoid conflicts, it's not recommended to use Command Palette commands and debug configurations of the preview version and the stable one at the same time.
[![Build Status](https://dev.azure.com/vscode-webdiag-extensions/VS%20Code%20WebDiag%20extensions/_apis/build/status/%5BUnit%20tests%5D%20vscode-react-native%20%5Bmaster%5D?branchName=master)](https://dev.azure.com/vscode-webdiag-extensions/VS%20Code%20WebDiag%20extensions/_build/latest?definitionId=60&branchName=master)
![Stable version](https://vsmarketplacebadge.apphb.com/version-short/msjsdiag.vscode-react-native.svg)
![VS Marketplace rating](https://vsmarketplacebadge.apphb.com/rating-star/msjsdiag.vscode-react-native.svg)
## About the extension
@ -50,7 +15,6 @@ Using this extension, you can **debug your code and quickly run `react-native` c
# Table of Contents
- [React Native Tools Preview migration guide](#react-native-tools-preview-migration-guide)
- [About the extension](#about-the-extension)
- [Getting started](#getting-started)
- [React Native commands in the Command Palette](#react-native-commands-in-the-command-palette)

Просмотреть файл

@ -18,7 +18,7 @@ const es = require("event-stream");
const remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");
const nls = require("vscode-nls-dev");
const webpack = require("webpack");
const filter = require('gulp-filter');
const filter = require("gulp-filter");
const del = require("del");
const vscodeTest = require("vscode-test");
const cp = require("child_process");
@ -28,30 +28,31 @@ const imports = GulpExtras.checkImports;
const executeCommand = GulpExtras.executeCommand;
const tsProject = ts.createProject("tsconfig.json");
/**
* Whether we're running a nightly build.
*/
const isNightly = process.argv.includes("--nightly");
const ExtensionName = isNightly ? "msjsdiag.vscode-react-native-preview" : "msjsdiag.vscode-react-native";
const translationProjectName = "vscode-extensions";
const ExtensionName = isNightly
? "msjsdiag.vscode-react-native-preview"
: "msjsdiag.vscode-react-native";
const translationProjectName = "vscode-extensions";
const defaultLanguages = [
{ id: "zh-tw", folderName: "cht", transifexId: "zh-hant" },
{ id: "zh-cn", folderName: "chs", transifexId: "zh-hans" },
{ id: "ja", folderName: "jpn" },
{ id: "ko", folderName: "kor" },
{ id: "de", folderName: "deu" },
{ id: "fr", folderName: "fra" },
{ id: "es", folderName: "esn" },
{ id: "ru", folderName: "rus" },
{ id: "it", folderName: "ita" },
{ id: "zh-tw", folderName: "cht", transifexId: "zh-hant" },
{ id: "zh-cn", folderName: "chs", transifexId: "zh-hans" },
{ id: "ja", folderName: "jpn" },
{ id: "ko", folderName: "kor" },
{ id: "de", folderName: "deu" },
{ id: "fr", folderName: "fra" },
{ id: "es", folderName: "esn" },
{ id: "ru", folderName: "rus" },
{ id: "it", folderName: "ita" },
// These language-pack languages are included for VS but excluded from the vscode package
{ id: "cs", folderName: "csy" },
{ id: "tr", folderName: "trk" },
{ id: "pt-br", folderName: "ptb", transifexId: "pt-BR" },
{ id: "pl", folderName: "plk" }
// These language-pack languages are included for VS but excluded from the vscode package
{ id: "cs", folderName: "csy" },
{ id: "tr", folderName: "trk" },
{ id: "pt-br", folderName: "ptb", transifexId: "pt-BR" },
{ id: "pl", folderName: "plk" },
];
const srcPath = "src";
@ -63,416 +64,527 @@ const distSrcDir = `${distDir}/src`;
const sources = [srcPath, testPath].map((tsFolder) => tsFolder + "/**/*.ts");
const knownOptions = {
string: "env",
default: { env: "production" }
string: "env",
default: { env: "production" },
};
const options = minimist(process.argv.slice(2), knownOptions);
let lintSources = [srcPath, testPath].map((tsFolder) => tsFolder + "/**/*.ts");
lintSources = lintSources.concat([
"!src/typings/**",
"!test/resources/sampleReactNative022Project/**",
"!test/smoke/**",
"!/SmokeTestLogs/**"
"!src/typings/**",
"!test/resources/sampleReactNative022Project/**",
"!test/smoke/**",
"!/SmokeTestLogs/**",
]);
async function runWebpack({
packages = [],
devtool = false,
compileInPlace = false,
mode = process.argv.includes("watch") ? "development" : "production",
} = options) {
packages = [],
devtool = false,
compileInPlace = false,
mode = process.argv.includes("watch") ? "development" : "production",
} = options) {
let configs = [];
for (const { entry, library, filename } of packages) {
const config = {
mode,
target: "node",
entry: path.resolve(entry),
output: {
path: compileInPlace
? path.resolve(path.dirname(entry))
: path.resolve(distDir),
filename: filename || path.basename(entry).replace(".js", ".bundle.js"),
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: devtool,
resolve: {
extensions: [".js", ".ts", ".json"],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
// vscode-nls-dev loader:
// * rewrite nls-calls
loader: "vscode-nls-dev/lib/webpack-loader",
options: {
base: path.join(__dirname),
},
},
{
// configure TypeScript loader:
// * enable sources maps for end-to-end source maps
loader: "ts-loader",
options: {
compilerOptions: {
sourceMap: true,
},
},
},
],
},
],
},
node: {
__dirname: false,
__filename: false,
},
externals: {
vscode: "commonjs vscode",
},
};
let configs = [];
for (const { entry, library, filename } of packages) {
const config = {
mode,
target: "node",
entry: path.resolve(entry),
output: {
path: compileInPlace ? path.resolve(path.dirname(entry)) : path.resolve(distDir),
filename: filename || path.basename(entry).replace(".js", ".bundle.js"),
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: devtool,
resolve: {
extensions: [".js", ".ts", ".json"],
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
use: [{
// vscode-nls-dev loader:
// * rewrite nls-calls
loader: 'vscode-nls-dev/lib/webpack-loader',
options: {
base: path.join(__dirname)
}
}, {
// configure TypeScript loader:
// * enable sources maps for end-to-end source maps
loader: 'ts-loader',
options: {
compilerOptions: {
"sourceMap": true,
}
}
}]
}]
},
node: {
__dirname: false,
__filename: false,
},
externals: {
vscode: "commonjs vscode",
}
};
if (library) {
config.output.libraryTarget = "commonjs2";
}
if (process.argv.includes("--analyze-size")) {
config.plugins = [
new (require("webpack-bundle-analyzer").BundleAnalyzerPlugin)({
analyzerMode: "static",
reportFilename: path.resolve(distSrcDir, path.basename(entry) + ".html"),
}),
];
}
configs.push(config);
if (library) {
config.output.libraryTarget = "commonjs2";
}
await new Promise((resolve, reject) =>
webpack(configs, (err, stats) => {
if (err) {
reject(err);
} else if (stats.hasErrors()) {
reject(stats);
} else {
resolve();
}
}),
);
if (process.argv.includes("--analyze-size")) {
config.plugins = [
new (require("webpack-bundle-analyzer").BundleAnalyzerPlugin)({
analyzerMode: "static",
reportFilename: path.resolve(
distSrcDir,
path.basename(entry) + ".html"
),
}),
];
}
configs.push(config);
}
await new Promise((resolve, reject) =>
webpack(configs, (err, stats) => {
if (err) {
reject(err);
} else if (stats.hasErrors()) {
reject(stats);
} else {
resolve();
}
})
);
}
// Generates ./dist/nls.bundle.<language_id>.json from files in ./i18n/** *//<src_path>/<filename>.i18n.json
// Localized strings are read from these files at runtime.
const generateSrcLocBundle = () => {
// Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize.
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(nls.createMetaDataFiles())
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
.pipe(nls.bundleMetaDataFiles(ExtensionName, 'dist'))
.pipe(nls.bundleLanguageFiles())
.pipe(filter(['**/nls.bundle.*.json', '**/nls.metadata.header.json', '**/nls.metadata.json', "!src/**"]))
.pipe(gulp.dest('dist'));
// Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize.
return tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(nls.createMetaDataFiles())
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
.pipe(nls.bundleMetaDataFiles(ExtensionName, "dist"))
.pipe(nls.bundleLanguageFiles())
.pipe(
filter([
"**/nls.bundle.*.json",
"**/nls.metadata.header.json",
"**/nls.metadata.json",
"!src/**",
])
)
.pipe(gulp.dest("dist"));
};
function build(failOnError, buildNls) {
const isProd = options.env === "production";
const preprocessorContext = isProd ? { PROD: true } : { DEBUG: true };
let gotError = false;
log(
`Building with preprocessor context: ${JSON.stringify(preprocessorContext)}`
);
const tsResult = tsProject
.src()
.pipe(preprocess({ context: preprocessorContext })) //To set environment variables in-line
.pipe(sourcemaps.init())
.pipe(tsProject());
const isProd = options.env === "production";
const preprocessorContext = isProd ? { PROD: true } : { DEBUG: true };
let gotError = false;
log(`Building with preprocessor context: ${JSON.stringify(preprocessorContext)}`);
const tsResult = tsProject.src()
.pipe(preprocess({ context: preprocessorContext })) //To set environment variables in-line
.pipe(sourcemaps.init())
.pipe(tsProject());
return tsResult.js
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(buildNls ? nls.createAdditionalLanguageFiles(defaultLanguages, "i18n", ".") : es.through())
.pipe(buildNls ? nls.bundleMetaDataFiles(ExtensionName, ".") : es.through())
.pipe(buildNls ? nls.bundleLanguageFiles() : es.through())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "." }))
.pipe(gulp.dest((file) => file.cwd))
.once("error", () => {
gotError = true;
})
.once("finish", () => {
if (failOnError && gotError) {
process.exit(1);
}
});
return tsResult.js
.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through())
.pipe(
buildNls
? nls.createAdditionalLanguageFiles(defaultLanguages, "i18n", ".")
: es.through()
)
.pipe(buildNls ? nls.bundleMetaDataFiles(ExtensionName, ".") : es.through())
.pipe(buildNls ? nls.bundleLanguageFiles() : es.through())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "." }))
.pipe(gulp.dest((file) => file.cwd))
.once("error", () => {
gotError = true;
})
.once("finish", () => {
if (failOnError && gotError) {
process.exit(1);
}
});
}
async function test() {
// Check if arguments were passed
if (options.pattern) {
log(`\nTesting cases that match pattern: ${options.pattern}`);
} else {
log(
`\nTesting cases that don't match pattern: extensionContext|localizationContext`
);
}
// Check if arguments were passed
if (options.pattern) {
log(`\nTesting cases that match pattern: ${options.pattern}`);
} else {
log(`\nTesting cases that don't match pattern: extensionContext|localizationContext`);
}
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = __dirname;
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = __dirname;
// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "test", "index");
console.log(extensionTestsPath);
// Download VS Code, unzip it and run the integration test
await vscodeTest.runTests({
extensionDevelopmentPath,
extensionTestsPath,
});
} catch (err) {
console.error(err);
console.error("Failed to run tests");
process.exit(1);
}
// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "test", "index");
console.log(extensionTestsPath);
// Download VS Code, unzip it and run the integration test
await vscodeTest.runTests({
extensionDevelopmentPath,
extensionTestsPath,
});
} catch (err) {
console.error(err);
console.error("Failed to run tests");
process.exit(1);
}
}
gulp.task("check-imports", () => {
const tsProject = ts.createProject("tsconfig.json");
return tsProject.src()
.pipe(imports());
const tsProject = ts.createProject("tsconfig.json");
return tsProject.src().pipe(imports());
});
gulp.task("check-copyright", () => {
return gulp.src([
"**/*.ts",
"**/*.js",
"!**/*.d.ts",
"!coverage/**",
"!node_modules/**",
"!test/**/*.js",
"!SampleApplication/**",
"!test/resources/sampleReactNative022Project/**/*.js",
"!test/smoke/package/node_modules/**",
"!test/smoke/automation/node_modules/**",
"!test/smoke/resources/**",
"!test/smoke/vscode/**",
"!dist/**"
return gulp
.src([
"**/*.ts",
"**/*.js",
"!**/*.d.ts",
"!coverage/**",
"!node_modules/**",
"!test/**/*.js",
"!SampleApplication/**",
"!test/resources/sampleReactNative022Project/**/*.js",
"!test/smoke/package/node_modules/**",
"!test/smoke/automation/node_modules/**",
"!test/smoke/resources/**",
"!test/smoke/vscode/**",
"!dist/**",
])
.pipe(copyright());
.pipe(copyright());
});
const runEslint = (fix, callback) => {
const child = cp.fork(
"./node_modules/eslint/bin/eslint.js",
[
'--color',
"src/**/*.ts",
fix ? '--fix' : '',
],
{ stdio: 'inherit' },
);
const child = cp.fork(
"./node_modules/eslint/bin/eslint.js",
["--color", "src/**/*.ts", fix ? "--fix" : ""],
{ stdio: "inherit" }
);
child.on('exit', code => (code ? callback(`Eslint exited with code ${code}`) : callback()));
}
child.on("exit", (code) =>
code ? callback(`Eslint exited with code ${code}`) : callback()
);
};
gulp.task('eslint', callback => runEslint(false, callback));
gulp.task('eslint:format', callback => runEslint(true, callback));
gulp.task("eslint", (callback) => runEslint(false, callback));
gulp.task("eslint:format", (callback) => runEslint(true, callback));
/** Run webpack to bundle the extension output files */
gulp.task("webpack-bundle", async () => {
const packages = [
{ entry: `${buildDir}/extension/rn-extension.ts`, filename: "rn-extension.js", library: true },
];
return runWebpack({ packages });
const packages = [
{
entry: `${buildDir}/extension/rn-extension.ts`,
filename: "rn-extension.js",
library: true,
},
];
return runWebpack({ packages });
});
gulp.task("clean", () => {
const pathsToDelete = [
"src/**/*.js",
"src/**/*.js.map",
"test/**/*.js",
"test/**/*.js.map",
"out/",
"dist",
"!test/resources/sampleReactNative022Project/**/*.js",
".vscode-test/",
"nls.*.json",
"!test/smoke/**/*",
]
return del(pathsToDelete, { force: true });
const pathsToDelete = [
"src/**/*.js",
"src/**/*.js.map",
"test/**/*.js",
"test/**/*.js.map",
"out/",
"dist",
"!test/resources/sampleReactNative022Project/**/*.js",
".vscode-test/",
"nls.*.json",
"!test/smoke/**/*",
];
return del(pathsToDelete, { force: true });
});
// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
// We should also make sure that we always generate urls in all the path properties (We shouldn"t have \\s. This seems to
// be an issue on Windows platforms)
gulp.task("build", gulp.series("check-imports", "eslint", function runBuild(done) {
build(true, true)
.once("finish", () => {
done();
});
}));
gulp.task(
"build",
gulp.series("check-imports", "eslint", function runBuild(done) {
build(true, true).once("finish", () => {
done();
});
})
);
gulp.task("build-dev", gulp.series("check-imports", "eslint", function runBuild(done) {
build(false, false)
.once("finish", () => {
done();
});
}));
gulp.task(
"build-dev",
gulp.series("check-imports", "eslint", function runBuild(done) {
build(false, false).once("finish", () => {
done();
});
})
);
gulp.task("quick-build", gulp.series("build-dev"));
gulp.task("watch", gulp.series("build", function runWatch() {
gulp.task(
"watch",
gulp.series("build", function runWatch() {
log("Watching build sources...");
return gulp.watch(sources, gulp.series("build"));
}));
})
);
gulp.task("prod-build", gulp.series("clean", "webpack-bundle", generateSrcLocBundle));
gulp.task(
"prod-build",
gulp.series("clean", "webpack-bundle", generateSrcLocBundle)
);
gulp.task("default", gulp.series("prod-build"));
gulp.task("test", gulp.series("build", "eslint", test));
gulp.task("coverage:instrument", () => {
return gulp.src(["src/**/*.js", "!test/**"])
.pipe(istanbul({
// Use the isparta instrumenter (code coverage for ES6)
instrumenter: isparta.Instrumenter,
includeUntested: true
}))
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
return (
gulp
.src(["src/**/*.js", "!test/**"])
.pipe(
istanbul({
// Use the isparta instrumenter (code coverage for ES6)
instrumenter: isparta.Instrumenter,
includeUntested: true,
})
)
// Force `require` to return covered files
.pipe(istanbul.hookRequire())
);
});
gulp.task("coverage:report", () => {
return gulp.src(
["src/**/*.js", "!test/**"],
{ read: false }
)
.pipe(istanbul.writeReports({
reporters: ["json", "text-summary"]
}));
return gulp.src(["src/**/*.js", "!test/**"], { read: false }).pipe(
istanbul.writeReports({
reporters: ["json", "text-summary"],
})
);
});
gulp.task("coverage:remap", () => {
return gulp.src("coverage/coverage-final.json")
.pipe(remapIstanbul({
reports: {
"json": "coverage/coverage.json",
"html": "coverage/html-report"
}
}));
return gulp.src("coverage/coverage-final.json").pipe(
remapIstanbul({
reports: {
json: "coverage/coverage.json",
html: "coverage/html-report",
},
})
);
});
gulp.task("test-no-build", test);
gulp.task("test:coverage", gulp.series("quick-build", "coverage:instrument", "test-no-build", "coverage:report", "coverage:remap"));
gulp.task(
"test:coverage",
gulp.series(
"quick-build",
"coverage:instrument",
"test-no-build",
"coverage:report",
"coverage:remap"
)
);
gulp.task("watch-build-test", gulp.series("build", "test", function runWatch() {
gulp.task(
"watch-build-test",
gulp.series("build", "test", function runWatch() {
return gulp.watch(sources, gulp.series("build", "test"));
}));
})
);
gulp.task("package", (callback) => {
const command = path.join(__dirname, "node_modules", ".bin", "vsce");
const args = ["package"];
executeCommand(command, args, callback);
const command = path.join(__dirname, "node_modules", ".bin", "vsce");
const args = ["package"];
executeCommand(command, args, callback);
});
function readJson(file) {
const contents = fs.readFileSync(path.join(__dirname, file), "utf-8").toString();
return JSON.parse(contents);
const contents = fs
.readFileSync(path.join(__dirname, file), "utf-8")
.toString();
return JSON.parse(contents);
}
function writeJson(file, jsonObj) {
const content = JSON.stringify(jsonObj, null , 2);
fs.writeFileSync(path.join(__dirname, file), content);
const content = JSON.stringify(jsonObj, null, 2);
fs.writeFileSync(path.join(__dirname, file), content);
}
/**
* Generate version number for a nightly build.
*/
const getVersionNumber = () => {
const date = new Date(new Date().toLocaleString("en-US", { timeZone: "America/Los_Angeles" }));
const date = new Date(
new Date().toLocaleString("en-US", { timeZone: "America/Los_Angeles" })
);
return [
// YY
date.getFullYear(),
// MM,
date.getMonth() + 1,
//DDHH
`${date.getDate()}${String(date.getHours()).padStart(2, "0")}`,
].join(".");
return [
// YY
date.getFullYear(),
// MM,
date.getMonth() + 1,
//DDHH
`${date.getDate()}${String(date.getHours()).padStart(2, "0")}`,
].join(".");
};
gulp.task("release", function prepareLicenses() {
const backupFiles = ["LICENSE.txt", "ThirdPartyNotices.txt", "package.json"];
const backupFolder = path.resolve(path.join(os.tmpdir(), "vscode-react-native"));
if (!fs.existsSync(backupFolder)) {
fs.mkdirSync(backupFolder);
}
const backupFiles = ["LICENSE.txt", "ThirdPartyNotices.txt", "package.json"];
const backupFolder = path.resolve(
path.join(os.tmpdir(), "vscode-react-native")
);
if (!fs.existsSync(backupFolder)) {
fs.mkdirSync(backupFolder);
}
return Promise.resolve()
.then(() => {
/* back up LICENSE.txt, ThirdPartyNotices.txt, README.md */
log("Backing up license files to " + backupFolder + "...");
backupFiles.forEach((fileName) => {
fs.writeFileSync(
path.join(backupFolder, fileName),
fs.readFileSync(fileName)
);
});
return Promise.resolve()
.then(() => {
/* back up LICENSE.txt, ThirdPartyNotices.txt, README.md */
log("Backing up license files to " + backupFolder + "...");
backupFiles.forEach((fileName) => {
fs.writeFileSync(path.join(backupFolder, fileName), fs.readFileSync(fileName));
});
/* copy over the release package license files */
log("Preparing license files for release...");
fs.writeFileSync("LICENSE.txt", fs.readFileSync("release/LICENSE.txt"));
fs.writeFileSync("ThirdPartyNotices.txt", fs.readFileSync("release/ThirdPartyNotices.txt"));
}).then(() => {
let packageJson = readJson("package.json");
packageJson.main = "./dist/rn-extension";
if (isNightly) {
log("Performing nightly release...");
packageJson.version = getVersionNumber();
/* copy over the release package license files */
log("Preparing license files for release...");
fs.writeFileSync("LICENSE.txt", fs.readFileSync("release/LICENSE.txt"));
fs.writeFileSync(
"ThirdPartyNotices.txt",
fs.readFileSync("release/ThirdPartyNotices.txt")
);
})
.then(() => {
let packageJson = readJson("package.json");
packageJson.main = "./dist/rn-extension";
if (isNightly) {
log("Performing nightly release...");
packageJson.version = getVersionNumber();
}
writeJson("package.json", packageJson);
log("Creating release package...");
return new Promise((resolve, reject) => {
// NOTE: vsce must see npm 3.X otherwise it will not correctly strip out dev dependencies.
executeCommand(
"vsce",
["package"],
(arg) => {
if (arg) {
reject(arg);
}
writeJson("package.json", packageJson);
log("Creating release package...");
return new Promise((resolve, reject) => {
// NOTE: vsce must see npm 3.X otherwise it will not correctly strip out dev dependencies.
executeCommand("vsce", ["package"], (arg) => { if (arg) { reject(arg); } resolve(); }, { cwd: path.resolve(__dirname) });
})
}).finally(() => {
/* restore backed up files */
log("Restoring modified files...");
backupFiles.forEach((fileName) => {
fs.writeFileSync(path.join(__dirname, fileName), fs.readFileSync(path.join(backupFolder, fileName)));
});
});
resolve();
},
{ cwd: path.resolve(__dirname) }
);
});
})
.finally(() => {
/* restore backed up files */
log("Restoring modified files...");
backupFiles.forEach((fileName) => {
fs.writeFileSync(
path.join(__dirname, fileName),
fs.readFileSync(path.join(backupFolder, fileName))
);
});
});
});
// Creates package.i18n.json files for all languages from {workspaceRoot}/i18n folder into project root
gulp.task("add-i18n", () => {
return gulp.src(["package.nls.json"])
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
.pipe(gulp.dest("."))
return gulp
.src(["package.nls.json"])
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
.pipe(gulp.dest("."));
});
// Creates MLCP readable .xliff file and saves it locally
gulp.task("translations-export", gulp.series("build", function runTranslationExport() {
return gulp.src(["package.nls.json", "nls.metadata.header.json", "nls.metadata.json"])
.pipe(nls.createXlfFiles(translationProjectName, ExtensionName))
.pipe(gulp.dest(path.join("..", `${translationProjectName}-localization-export`)));
}));
gulp.task(
"translations-export",
gulp.series("build", function runTranslationExport() {
return gulp
.src([
"package.nls.json",
"nls.metadata.header.json",
"nls.metadata.json",
])
.pipe(nls.createXlfFiles(translationProjectName, ExtensionName))
.pipe(
gulp.dest(
path.join("..", `${translationProjectName}-localization-export`)
)
);
})
);
// Imports localization from raw localized MLCP strings to VS Code .i18n.json files
gulp.task("translations-import", (done) => {
gulp.task(
"translations-import",
gulp.series((done) => {
var options = minimist(process.argv.slice(2), {
string: "location",
default: {
location: "../vscode-translations-import"
}
string: "location",
default: {
location: "../vscode-translations-import",
},
});
es.merge(defaultLanguages.map((language) => {
es.merge(
defaultLanguages.map((language) => {
let id = language.transifexId || language.id;
log(path.join(options.location, id, "vscode-extensions", `${ExtensionName}.xlf`));
return gulp.src(path.join(options.location, id, "vscode-extensions", `${ExtensionName}.xlf`))
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest(path.join("./i18n", language.folderName)));
}))
.pipe(es.wait(() => {
done();
}));
});
log(
path.join(
options.location,
id,
"vscode-extensions",
`${ExtensionName}.xlf`
)
);
return gulp
.src(
path.join(
options.location,
id,
"vscode-extensions",
`${ExtensionName}.xlf`
)
)
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest(path.join("./i18n", language.folderName)));
})
).pipe(
es.wait(() => {
done();
})
);
}, "add-i18n")
);

21995
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,7 +8,7 @@ import { InternalErrorCode } from "./error/internalErrorCode";
export interface PatternToFailure {
pattern: string | RegExp;
errorCode: number;
};
}
/* This class transforms a spawn process to only succeed if all defined success patterns
are found on stdout, and none of the failure patterns were found on stderr */

Просмотреть файл

@ -64,7 +64,7 @@ export class IWDPHelper {
throw ErrorHelper.getInternalError(InternalErrorCode.IOSCouldNotFoundDeviceForDirectDebugging);
}
});
};
}
public cleanUp(): void {
if (this.iOSWebkitDebugProxyProcess) {

Просмотреть файл

@ -13,7 +13,7 @@ export interface IVirtualDevice {
export abstract class VirtualDeviceManager {
protected async selectVirtualDevice(filter?: (el: IVirtualDevice) => {}): Promise<string | undefined> {
protected async selectVirtualDevice(filter?: (el: IVirtualDevice) => unknown): Promise<string | undefined> {
const emulatorsList = await this.getVirtualDevicesNamesList(filter);
const quickPickOptions: QuickPickOptions = {
ignoreFocusOut: true,
@ -29,7 +29,7 @@ export abstract class VirtualDeviceManager {
public abstract async startSelection(): Promise<string | undefined>;
protected abstract async getVirtualDevicesNamesList(filter?: (el: IVirtualDevice) => {}): Promise<string[]>;
protected abstract async getVirtualDevicesNamesList(filter?: (el: IVirtualDevice) => unknown): Promise<string[]>;
}

Просмотреть файл

@ -11,71 +11,71 @@ nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFo
const localize = nls.loadMessageBundle();
export const DEBUG_TYPES = {
REACT_NATIVE: "reactnative-preview",
REACT_NATIVE_DIRECT: "reactnativedirect-preview",
REACT_NATIVE: "reactnative",
REACT_NATIVE_DIRECT: "reactnativedirect",
};
export class ReactNativeDebugConfigProvider implements vscode.DebugConfigurationProvider {
private debugConfigurations = {
"Debug Android (Preview)": {
"name": "Debug Android (Preview)",
"Debug Android": {
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.Android,
},
"Run Android (Preview)": {
"name": "Run Android (Preview)",
"Run Android": {
"name": "Run Android",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.Android,
"enableDebug": false,
},
"Debug iOS (Preview)": {
"name": "Debug iOS (Preview)",
"Debug iOS": {
"name": "Debug iOS",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.iOS,
},
"Run iOS (Preview)": {
"name": "Run iOS (Preview)",
"Run iOS": {
"name": "Run iOS",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.iOS,
"enableDebug": false,
},
"Debug Windows (Preview)": {
"name": "Debug Windows (Preview)",
"Debug Windows": {
"name": "Debug Windows",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.Windows,
},
"Attach to packager (Preview)": {
"name": "Attach to packager (Preview)",
"Attach to packager": {
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "attach",
},
"Debug in Exponent (Preview)": {
"name": "Debug in Exponent (Preview)",
"Debug in Exponent": {
"name": "Debug in Exponent",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE,
"request": "launch",
"platform": PlatformType.Exponent,
},
"Debug Android Hermes (Preview) - Experimental": {
"name": "Debug Android Hermes (Preview) - Experimental",
"Debug Android Hermes - Experimental": {
"name": "Debug Android Hermes - Experimental",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE_DIRECT,
"request": "launch",
"platform": PlatformType.Android,
},
"Run Android Hermes (Preview) - Experimental": {
"name": "Run Android Hermes (Preview) - Experimental",
"Run Android Hermes - Experimental": {
"name": "Run Android Hermes - Experimental",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE_DIRECT,
"request": "launch",
@ -96,16 +96,16 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration
"platform": PlatformType.iOS,
"port": IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT // 9221
},
"Debug Direct iOS (Preview) - Experimental": {
"name": "Debug Direct iOS (Preview) - Experimental",
"Debug Direct iOS - Experimental": {
"name": "Debug Direct iOS - Experimental",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE_DIRECT,
"request": "launch",
"platform": PlatformType.iOS,
"port": IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT // 9221
},
"Run Direct iOS (Preview) - Experimental": {
"name": "Run Direct iOS (Preview) - Experimental",
"Run Direct iOS - Experimental": {
"name": "Run Direct iOS - Experimental",
"cwd": "${workspaceFolder}",
"type": DEBUG_TYPES.REACT_NATIVE_DIRECT,
"request": "launch",
@ -116,35 +116,35 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration
private pickConfig: ReadonlyArray<vscode.QuickPickItem> = [
{
label: "Debug Android (Preview)",
label: "Debug Android",
description: localize("DebugAndroidConfigDesc", "Run and debug Android application"),
},
{
label: "Run Android (Preview)",
label: "Run Android",
description: localize("RunAndroidConfigDesc", "Run Android application"),
},
{
label: "Debug iOS (Preview)",
label: "Debug iOS",
description: localize("DebugiOSConfigDesc", "Run and debug iOS application"),
},
{
label: "Run iOS (Preview)",
label: "Run iOS",
description: localize("RuniOSConfigDesc", "Run iOS application"),
},
{
label: "Debug Windows (Preview)",
label: "Debug Windows",
description: localize("DebugWindowsConfigDesc", "Run and debug Windows application"),
},
{
label: "Attach to packager (Preview)",
label: "Attach to packager",
description: localize("AttachToPackagerConfigDesc", "Attach to already working application packager"),
},
{
label: "Debug in Exponent (Preview)",
label: "Debug in Exponent",
description: localize("DebugExpoConfigDesc", "Debug Expo application or React Native application in Expo"),
},
{
label: "Debug Android Hermes (Preview) - Experimental",
label: "Debug Android Hermes - Experimental",
description: localize("DebugAndroidHermesConfigDesc", "Run and debug Android Hermes application"),
},
{
@ -156,11 +156,11 @@ export class ReactNativeDebugConfigProvider implements vscode.DebugConfiguration
description: localize("AttachToPackageriOSConfigDesc", "Attach to already working React Native iOS application directly"),
},
{
label: "Debug Direct iOS (Preview) - Experimental",
label: "Debug Direct iOS - Experimental",
description: localize("DebugDirectiOSConfigDesc", "Run and debug iOS application directly"),
},
{
label: "Run Direct iOS (Preview) - Experimental",
label: "Run Direct iOS - Experimental",
description: localize("RunDirectiOSConfigDesc", "Run iOS application with direct debugging support"),
},
];

Просмотреть файл

@ -91,7 +91,7 @@ export class IOSSimulatorManager extends VirtualDeviceManager {
return undefined;
}
protected async getVirtualDevicesNamesList(filter?: (el: IiOSSimulator) => {}): Promise<string[]> {
protected async getVirtualDevicesNamesList(filter?: (el: IiOSSimulator) => unknown): Promise<string[]> {
const names: string[] = [];
this.simulators.forEach((el: IiOSSimulator) => {
if (el.name && (!filter || filter(el))) {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import {window, Disposable, StatusBarItem, StatusBarAlignment} from "vscode";
import { window, Disposable, StatusBarItem, StatusBarAlignment } from "vscode";
import * as nls from "vscode-nls";
import { SettingsHelper } from "./settingsHelper";
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
@ -37,9 +37,9 @@ export class PackagerStatusIndicator implements Disposable {
private static ACTIVITY_ICON = "$(loading~spin)";
private static RESTART_ICON = "$(sync)";
private static START_COMMAND = "reactNative.startPackager-preview";
private static RESTART_COMMAND = "reactNative.restartPackager-preview";
private static STOP_COMMAND = "reactNative.stopPackager-preview";
private static START_COMMAND = "reactNative.startPackager";
private static RESTART_COMMAND = "reactNative.restartPackager";
private static STOP_COMMAND = "reactNative.stopPackager";
public static FULL_VERSION = "Full";
public static SHORT_VERSION = "Short";

Просмотреть файл

@ -12,22 +12,22 @@ try {
// @endif
import * as vscode from "vscode";
import * as semver from "semver";
import {CommandPaletteHandler} from "./commandPaletteHandler";
import {EntryPointHandler, ProcessType} from "../common/entryPointHandler";
import {ErrorHelper} from "../common/error/errorHelper";
import {InternalError} from "../common/error/internalError";
import {InternalErrorCode} from "../common/error/internalErrorCode";
import {SettingsHelper} from "./settingsHelper";
import {ProjectVersionHelper} from "../common/projectVersionHelper";
import {ReactDirManager} from "./reactDirManager";
import {Telemetry} from "../common/telemetry";
import {TelemetryHelper, ICommandTelemetryProperties} from "../common/telemetryHelper";
import {OutputChannelLogger} from "./log/OutputChannelLogger";
import {ReactNativeDebugConfigProvider, DEBUG_TYPES} from "./debugConfigurationProvider";
import {DebugSessionBase} from "../debugger/debugSessionBase";
import {ReactNativeSessionManager} from "./reactNativeSessionManager";
import {ProjectsStorage} from "./projectsStorage";
import {AppLauncher} from "./appLauncher";
import { CommandPaletteHandler } from "./commandPaletteHandler";
import { EntryPointHandler, ProcessType } from "../common/entryPointHandler";
import { ErrorHelper } from "../common/error/errorHelper";
import { InternalError } from "../common/error/internalError";
import { InternalErrorCode } from "../common/error/internalErrorCode";
import { SettingsHelper } from "./settingsHelper";
import { ProjectVersionHelper } from "../common/projectVersionHelper";
import { ReactDirManager } from "./reactDirManager";
import { Telemetry } from "../common/telemetry";
import { TelemetryHelper, ICommandTelemetryProperties } from "../common/telemetryHelper";
import { OutputChannelLogger } from "./log/OutputChannelLogger";
import { ReactNativeDebugConfigProvider, DEBUG_TYPES } from "./debugConfigurationProvider";
import { DebugSessionBase } from "../debugger/debugSessionBase";
import { ReactNativeSessionManager } from "./reactNativeSessionManager";
import { ProjectsStorage } from "./projectsStorage";
import { AppLauncher } from "./appLauncher";
import * as nls from "vscode-nls";
import { getExtensionVersion } from "../common/extensionHelper";
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
@ -59,7 +59,7 @@ export function activate(context: vscode.ExtensionContext): Promise<void> {
let extProps: ICommandTelemetryProperties = {};
if (workspaceFolders) {
extProps = {
["workspaceFoldersCount"]: {value: workspaceFolders.length, isPii: false},
["workspaceFoldersCount"]: { value: workspaceFolders.length, isPii: false },
};
}
@ -95,7 +95,7 @@ export function activate(context: vscode.ExtensionContext): Promise<void> {
TelemetryHelper.sendErrorEvent(
"ActivateCouldNotFindWorkspace",
ErrorHelper.getInternalError(InternalErrorCode.CouldNotFindWorkspace)
);
);
}
return Promise.all(promises).then(() => {
@ -112,13 +112,13 @@ export function deactivate(): Promise<void> {
() => {
debugConfigProvider.dispose();
CommandPaletteHandler.stopAllPackagers()
.then(() => {
return CommandPaletteHandler.stopElementInspector();
})
.then(() => {
// Tell vscode that we are done with deactivation
resolve();
});
.then(() => {
return CommandPaletteHandler.stopElementInspector();
})
.then(() => {
// Tell vscode that we are done with deactivation
resolve();
});
}, /*errorsAreFatal*/ true);
});
}
@ -171,7 +171,7 @@ function onFolderAdded(context: vscode.ExtensionContext, folder: vscode.Workspac
outputChannelLogger.debug(`react-native@${versions.reactNativeVersion} isn't supported`);
}
return Promise.all(promises).then(() => {});
return Promise.all(promises).then(() => { });
});
}
@ -221,19 +221,19 @@ function isSupportedVersion(version: string): boolean {
}
function registerReactNativeCommands(context: vscode.ExtensionContext): void {
registerVSCodeCommand(context, "launchAndroidSimulator-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToStartAndroidEmulator), () => CommandPaletteHandler.launchAndroidEmulator());
registerVSCodeCommand(context, "runAndroidSimulator-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnAndroid), () => CommandPaletteHandler.runAndroid("simulator"));
registerVSCodeCommand(context, "runAndroidDevice-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnAndroid), () => CommandPaletteHandler.runAndroid("device"));
registerVSCodeCommand(context, "runIosSimulator-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnIos), () => CommandPaletteHandler.runIos("simulator"));
registerVSCodeCommand(context, "runIosDevice-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnIos), () => CommandPaletteHandler.runIos("device"));
registerVSCodeCommand(context, "runExponent-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunExponent), () => CommandPaletteHandler.runExponent());
registerVSCodeCommand(context, "startPackager-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToStartPackager), () => CommandPaletteHandler.startPackager());
registerVSCodeCommand(context, "stopPackager-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToStopPackager), () => CommandPaletteHandler.stopPackager());
registerVSCodeCommand(context, "restartPackager-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToRestartPackager), () => CommandPaletteHandler.restartPackager());
registerVSCodeCommand(context, "publishToExpHost-preview", ErrorHelper.getInternalError(InternalErrorCode.FailedToPublishToExpHost), () => CommandPaletteHandler.publishToExpHost());
registerVSCodeCommand(context, "showDevMenu-preview", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeShowDevMenu", "React Native: Show Developer Menu for app")), () => CommandPaletteHandler.showDevMenu());
registerVSCodeCommand(context, "reloadApp-preview", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeReloadApp", "React Native: Reload App")), () => CommandPaletteHandler.reloadApp());
registerVSCodeCommand(context, "runInspector-preview", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeRunElementInspector", "React Native: Run Element Inspector")), () => CommandPaletteHandler.runElementInspector());
registerVSCodeCommand(context, "launchAndroidSimulator", ErrorHelper.getInternalError(InternalErrorCode.FailedToStartAndroidEmulator), () => CommandPaletteHandler.launchAndroidEmulator());
registerVSCodeCommand(context, "runAndroidSimulator", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnAndroid), () => CommandPaletteHandler.runAndroid("simulator"));
registerVSCodeCommand(context, "runAndroidDevice", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnAndroid), () => CommandPaletteHandler.runAndroid("device"));
registerVSCodeCommand(context, "runIosSimulator", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnIos), () => CommandPaletteHandler.runIos("simulator"));
registerVSCodeCommand(context, "runIosDevice", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunOnIos), () => CommandPaletteHandler.runIos("device"));
registerVSCodeCommand(context, "runExponent", ErrorHelper.getInternalError(InternalErrorCode.FailedToRunExponent), () => CommandPaletteHandler.runExponent());
registerVSCodeCommand(context, "startPackager", ErrorHelper.getInternalError(InternalErrorCode.FailedToStartPackager), () => CommandPaletteHandler.startPackager());
registerVSCodeCommand(context, "stopPackager", ErrorHelper.getInternalError(InternalErrorCode.FailedToStopPackager), () => CommandPaletteHandler.stopPackager());
registerVSCodeCommand(context, "restartPackager", ErrorHelper.getInternalError(InternalErrorCode.FailedToRestartPackager), () => CommandPaletteHandler.restartPackager());
registerVSCodeCommand(context, "publishToExpHost", ErrorHelper.getInternalError(InternalErrorCode.FailedToPublishToExpHost), () => CommandPaletteHandler.publishToExpHost());
registerVSCodeCommand(context, "showDevMenu", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeShowDevMenu", "React Native: Show Developer Menu for app")), () => CommandPaletteHandler.showDevMenu());
registerVSCodeCommand(context, "reloadApp", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeReloadApp", "React Native: Reload App")), () => CommandPaletteHandler.reloadApp());
registerVSCodeCommand(context, "runInspector", ErrorHelper.getInternalError(InternalErrorCode.CommandFailed, localize("ReactNativeRunElementInspector", "React Native: Run Element Inspector")), () => CommandPaletteHandler.runElementInspector());
}
function registerVSCodeCommand(context: vscode.ExtensionContext, commandName: string, error: InternalError, commandHandler: () => Promise<void>): void {

Просмотреть файл

@ -6,7 +6,7 @@ import * as path from "path";
import { LaunchScenariosManager } from "../../src/extension/launchScenariosManager";
import * as assert from "assert";
suite("LaunchScenarioManager", function() {
suite("LaunchScenarioManager", function () {
const tmpPath = path.resolve(__dirname, "..", "resources", "tmp");
const launchPath = path.resolve(tmpPath, ".vscode", "launch.json");
const launchContent = {
@ -15,7 +15,7 @@ suite("LaunchScenarioManager", function() {
{
name: "Debug Android",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "android",
target: "simulator"
@ -23,7 +23,7 @@ suite("LaunchScenarioManager", function() {
{
name: "Debug Android (Hermes) - Experimental",
cwd: "${workspaceFolder}",
type: "reactnativedirect-preview",
type: "reactnativedirect",
request: "launch",
platform: "android",
env: {
@ -34,33 +34,33 @@ suite("LaunchScenarioManager", function() {
{
name: "Attach to Hermes application - Experimental",
cwd: "${workspaceFolder}",
type: "reactnativedirect-preview",
type: "reactnativedirect",
request: "attach"
},
{
name: "Debug iOS",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "ios"
},
{
name: "Attach to packager",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "attach"
},
{
name: "Debug in Exponent",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "exponent"
},
{
name: "Debug in Exponent (LAN)",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "exponent",
expoHostType: "lan"
@ -68,7 +68,7 @@ suite("LaunchScenarioManager", function() {
{
name: "Debug in Exponent (Local)",
cwd: "${workspaceFolder}",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "exponent",
expoHostType: "local"
@ -91,7 +91,7 @@ suite("LaunchScenarioManager", function() {
fs.writeFileSync(launchPath, JSON.stringify(launchContent, null, 4));
});
suite("updateLaunchScenario", function() {
suite("updateLaunchScenario", function () {
function autogenerateUpdateAndCheck(configIndex: number, updates: any) {
const config = Object.assign({}, launchContent.configurations[configIndex]);
@ -114,30 +114,30 @@ suite("LaunchScenarioManager", function() {
assert.deepStrictEqual(launchObject, result);
}
test("should overwrite existing parameters for proper configuration", function() {
autogenerateUpdateAndCheck(2, {env:{env1: "newValue"}});
test("should overwrite existing parameters for proper configuration", function () {
autogenerateUpdateAndCheck(2, { env: { env1: "newValue" } });
});
test("should add new parameters to proper configuration", function() {
autogenerateUpdateAndCheck(5, {env:{env1: "newValue1", env2: "newValue2"}});
test("should add new parameters to proper configuration", function () {
autogenerateUpdateAndCheck(5, { env: { env1: "newValue1", env2: "newValue2" } });
});
test("should nothing happens if launch.json do not contains config", function() {
test("should nothing happens if launch.json do not contains config", function () {
const config = {
name: "Debug Android",
type: "reactnative-preview",
type: "reactnative",
request: "launch",
platform: "android",
};
let configCopy = Object.assign({}, config);
tryUpdateAndCheck(Object.assign(configCopy, {name: "Other name"}), {param: "value1"}, launchContent);
tryUpdateAndCheck(Object.assign(configCopy, { name: "Other name" }), { param: "value1" }, launchContent);
configCopy = Object.assign({}, config);
tryUpdateAndCheck(Object.assign(configCopy, {type: "Other type"}), {param: "value2"}, launchContent);
tryUpdateAndCheck(Object.assign(configCopy, { type: "Other type" }), { param: "value2" }, launchContent);
configCopy = Object.assign({}, config);
tryUpdateAndCheck(Object.assign(configCopy, {request: "Other request"}), {param: "value3"}, launchContent);
tryUpdateAndCheck(Object.assign(configCopy, { request: "Other request" }), { param: "value3" }, launchContent);
configCopy = Object.assign({}, config);
tryUpdateAndCheck(Object.assign(configCopy, {platform: "Other platform"}), {param: "value4"}, launchContent);
tryUpdateAndCheck(Object.assign(configCopy, { platform: "Other platform" }), { param: "value4" }, launchContent);
});
});
});

Просмотреть файл

@ -1,62 +1,62 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "launch",
"platform": "android",
"target": "simulator"
},
{
"name": "Debug Android (Hermes) - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect-preview",
"request": "launch",
"platform": "android"
},
{
"name": "Attach to Hermes application - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect-preview",
"request": "attach"
},
{
"name": "Debug iOS",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "launch",
"platform": "ios"
},
{
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "attach"
},
{
"name": "Debug in Exponent",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "launch",
"platform": "exponent"
},
{
"name": "Debug in Exponent (LAN)",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "launch",
"platform": "exponent",
"expoHostType": "lan"
},
{
"name": "Debug in Exponent (Local)",
"cwd": "${workspaceFolder}",
"type": "reactnative-preview",
"request": "launch",
"platform": "exponent",
"expoHostType": "local"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android",
"target": "simulator"
},
{
"name": "Debug Android (Hermes) - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect",
"request": "launch",
"platform": "android"
},
{
"name": "Attach to Hermes application - Experimental",
"cwd": "${workspaceFolder}",
"type": "reactnativedirect",
"request": "attach"
},
{
"name": "Debug iOS",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "ios"
},
{
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "attach"
},
{
"name": "Debug in Exponent",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "exponent"
},
{
"name": "Debug in Exponent (LAN)",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"expoHostType": "lan"
},
{
"name": "Debug in Exponent (Local)",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"expoHostType": "local"
}
]
}

Просмотреть файл

@ -40,7 +40,7 @@ export function setup(testParameters?: TestRunArguments) {
clientInited.closeApp();
clientInited.endAll();
}
};
}
afterEach(disposeAll);

Просмотреть файл

@ -13,6 +13,7 @@ import { Platform } from "./appiumHelper";
import { IosSimulatorHelper } from "./iosSimulatorHelper";
import { AndroidEmulatorHelper } from "./androidEmulatorHelper";
// eslint-disable-next-line
export function nfcall<R>(fn: Function, ...args): Promise<R> {
return new Promise<R>((c, e) => fn(...args, (err, r) => err ? e(err) : c(r)));
}