Prepare preview version for stable (#1437)

* First preparations for preview version from the master branch

* Add logic to process nightly releases

* Update docs

Co-authored-by: RedMickey <33267199+RedMickey@users.noreply.github.com>
This commit is contained in:
Yuri Skorokhodov 2020-10-12 12:45:20 +03:00 коммит произвёл GitHub
Родитель 58882bb6b3
Коммит 9928222cb8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 52 добавлений и 8 удалений

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

@ -1,9 +1,20 @@
# 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=master)](https://dev.azure.com/vscode-webdiag-extensions/VS%20Code%20WebDiag%20extensions/_build/latest?definitionId=60&branchName=master)
Stable:
![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)
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)
## React Native Tools Preview
The extension has a [nightly version](https://marketplace.visualstudio.com/items?itemName=msjsdiag.vscode-react-native-preview) which is released on a daily basis at 9 PM PST on each day that changes occur.
To avoid conflicts, if both extensions are installed - the only stable version will be activated. So to use the preview version it is needed to disable or remove the stable version and reload VS Code.
## About the extension
This VS Code extension provides a development environment for React Native projects.
@ -15,6 +26,7 @@ Using this extension, you can **debug your code and quickly run `react-native` c
# Table of Contents
- [React Native Tools Preview](#react-native-tools-preview)
- [About the extension](#about-the-extension)
- [Getting started](#getting-started)
- [React Native commands in the Command Palette](#react-native-commands-in-the-command-palette)

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

@ -33,9 +33,14 @@ const tsProject = ts.createProject("tsconfig.json");
*/
const isNightly = process.argv.includes("--nightly");
const ExtensionName = isNightly
const fullExtensionName = isNightly
? "msjsdiag.vscode-react-native-preview"
: "msjsdiag.vscode-react-native";
const extensionName = isNightly
? "vscode-react-native-preview"
: "vscode-react-native";
const translationProjectName = "vscode-extensions";
const defaultLanguages = [
{ id: "zh-tw", folderName: "cht", transifexId: "zh-hant" },
@ -180,7 +185,7 @@ const generateSrcLocBundle = () => {
.pipe(tsProject())
.js.pipe(nls.createMetaDataFiles())
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
.pipe(nls.bundleMetaDataFiles(ExtensionName, "dist"))
.pipe(nls.bundleMetaDataFiles(fullExtensionName, "dist"))
.pipe(nls.bundleLanguageFiles())
.pipe(
filter([
@ -213,7 +218,9 @@ function build(failOnError, buildNls) {
? nls.createAdditionalLanguageFiles(defaultLanguages, "i18n", ".")
: es.through()
)
.pipe(buildNls ? nls.bundleMetaDataFiles(ExtensionName, ".") : es.through())
.pipe(
buildNls ? nls.bundleMetaDataFiles(fullExtensionName, ".") : es.through()
)
.pipe(buildNls ? nls.bundleLanguageFiles() : es.through())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "." }))
.pipe(gulp.dest((file) => file.cwd))
@ -458,7 +465,12 @@ const getVersionNumber = () => {
};
gulp.task("release", function prepareLicenses() {
const backupFiles = ["LICENSE.txt", "ThirdPartyNotices.txt", "package.json"];
const backupFiles = [
"LICENSE.txt",
"ThirdPartyNotices.txt",
"package.json",
"package-lock.json",
];
const backupFolder = path.resolve(
path.join(os.tmpdir(), "vscode-react-native")
);
@ -491,6 +503,9 @@ gulp.task("release", function prepareLicenses() {
if (isNightly) {
log("Performing nightly release...");
packageJson.version = getVersionNumber();
packageJson.name = extensionName;
packageJson.preview = true;
packageJson.displayName += " (Preview)";
}
writeJson("package.json", packageJson);
log("Creating release package...");
@ -539,7 +554,7 @@ gulp.task(
"nls.metadata.header.json",
"nls.metadata.json",
])
.pipe(nls.createXlfFiles(translationProjectName, ExtensionName))
.pipe(nls.createXlfFiles(translationProjectName, fullExtensionName))
.pipe(
gulp.dest(
path.join("..", `${translationProjectName}-localization-export`)
@ -566,7 +581,7 @@ gulp.task(
options.location,
id,
"vscode-extensions",
`${ExtensionName}.xlf`
`${fullExtensionName}.xlf`
)
);
return gulp
@ -575,7 +590,7 @@ gulp.task(
options.location,
id,
"vscode-extensions",
`${ExtensionName}.xlf`
`${fullExtensionName}.xlf`
)
)
.pipe(nls.prepareJsonFiles())

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

@ -13,6 +13,15 @@ export function getExtensionVersion() {
}
}
export function getExtensionName(): string | null {
const packageJsonPath = findFileInFolderHierarchy(__dirname, "package.json");
if (packageJsonPath) {
return JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")).name;
} else {
return null;
}
}
export function findFileInFolderHierarchy(dir: string, filename: string): string | null {
let parentPath: string;
let projectRoot: string = dir;

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

@ -29,7 +29,7 @@ import { ReactNativeSessionManager } from "./reactNativeSessionManager";
import { ProjectsStorage } from "./projectsStorage";
import { AppLauncher } from "./appLauncher";
import * as nls from "vscode-nls";
import { getExtensionVersion } from "../common/extensionHelper";
import { getExtensionVersion, getExtensionName } from "../common/extensionHelper";
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize = nls.loadMessageBundle();
@ -46,6 +46,14 @@ interface ISetupableDisposable extends vscode.Disposable {
export function activate(context: vscode.ExtensionContext): Promise<void> {
const extensionName = getExtensionName();
if (extensionName && extensionName.includes("preview")) {
if (vscode.extensions.getExtension("msjsdiag.vscode-react-native")) {
vscode.window.showInformationMessage(localize("RNTTwoVersionsFound", "React Native Tools: Both Stable and Preview extensions are installed. Stable will be used. Disable or remove it to work with Preview version."));
return Promise.resolve();
}
}
outputChannelLogger.debug("Begin to activate...");
const appVersion = getExtensionVersion();
if (!appVersion) {