Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 66828ee

Browse files
committed
fix: run updater scripts through ./bin/update-ns-webpack
1 parent 641ac9b commit 66828ee

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

bin/update-ns-webpack

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#!/usr/bin/env node
2-
const path = require("path");
3-
const fs = require("fs");
2+
const { resolve } = require("path");
43

5-
const helpers = require("../projectHelpers");
6-
const forceUpdateProjectDeps = require("../dependencyManager").forceUpdateProjectDeps;
4+
const { getPackageJson, writePackageJson } = require("../projectHelpers");
5+
const { forceUpdateProjectDeps } = require("../dependencyManager");
6+
const { editExistingProjectFiles } = require("../projectFilesManager");
77

8-
const PROJECT_DIR = path.resolve(__dirname, "../../../");
9-
const packageJson = helpers.getPackageJson(PROJECT_DIR);
8+
const PROJECT_DIR = resolve(__dirname, "../../../");
109

10+
console.info("Updating dev dependencies...");
11+
const packageJson = getPackageJson(PROJECT_DIR);
1112
const { deps } = forceUpdateProjectDeps(packageJson);
1213
packageJson.devDependencies = deps;
14+
writePackageJson(packageJson, PROJECT_DIR);
15+
16+
console.info("\nUpdating configuration files...");
17+
editExistingProjectFiles(PROJECT_DIR);
18+
19+
console.info("\nProject successfully updated! Don't forget to run `npm install`");
1320

14-
helpers.writePackageJson(packageJson, PROJECT_DIR);

installer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const APP_DIR = path.resolve(PROJECT_DIR, "app");
1212
function install() {
1313
let packageJson = helpers.getPackageJson(PROJECT_DIR);
1414

15-
projectFilesManager.editExistingProjectFiles(PROJECT_DIR);
1615
projectFilesManager.addProjectFiles(PROJECT_DIR, APP_DIR);
1716

1817
let scripts = packageJson.scripts || {};

projectFilesManager.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,30 @@ function editFileContent(path, ...funcs) {
152152
}
153153

154154
function replaceStyleUrlResolvePlugin(config) {
155+
if (config.indexOf("StyleUrlResolvePlugin") === -1) {
156+
return config;
157+
}
158+
159+
console.info("Replacing deprecated StyleUrlsResolvePlugin with UrlResolvePlugin...");
155160
return config.replace(/StyleUrlResolvePlugin/g, "UrlResolvePlugin");
156161
}
157162

158163
function addSnapshotPlugin(config) {
159-
return config.indexOf("NativeScriptSnapshotPlugin") > -1 ?
160-
config :
161-
config.replace(CONFIG_MATCH, CONFIG_REPLACE);
164+
if (config.indexOf("NativeScriptSnapshotPlugin") > -1) {
165+
return config;
166+
}
167+
168+
console.info("Adding NativeScriptSnapshotPlugin configuration...");
169+
return config.replace(CONFIG_MATCH, CONFIG_REPLACE);
162170
}
163171

164172
function addSnapshotToVendor(content) {
165-
return content.indexOf("__snapshot") > -1 ?
166-
content :
167-
content.replace(FRAME_MATCH, SCOPED_FRAME);
173+
if (content.indexOf("__snapshot") > -1) {
174+
return content;
175+
}
176+
177+
console.info("Adding __snapshot configuration to app/vendor-platform.android ...");
178+
return content.replace(FRAME_MATCH, SCOPED_FRAME);
168179
}
169180

170181
function getFullPath(projectDir, filePath) {

0 commit comments

Comments
 (0)