Socket
Socket
Sign inDemoInstall

@ray-js/build-plugin-router

Package Overview
Dependencies
Maintainers
1
Versions
368
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ray-js/build-plugin-router - npm Package Compare versions

Comparing version 0.5.5 to 0.5.6-beta-1

51

lib/index.js

@@ -10,2 +10,3 @@ "use strict";

const lodash_1 = __importDefault(require("lodash"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const plugin_utils_1 = require("@ray-js/plugin-utils");

@@ -19,2 +20,3 @@ const shared_1 = require("@ray-js/shared");

function PluginRouter(api) {
let cacheThemeLocation = {};
return {

@@ -40,2 +42,3 @@ name: '@ray-js/build-plugin-router',

buildRoutesConfig(immediate) {
var _a, _b;
const routesConfigFile = api.searchJSFile('src/routes.config');

@@ -53,11 +56,12 @@ const { target } = api.options;

}
const wechatAppConfig = this.getWechatAppConfigData(routesConfig, globalConfig['wechat'] || {});
const tuyaAppConfig = this.getTuyaAppConfigData(routesConfig, globalConfig['tuya'] || {});
const _target = lodash_1.default.capitalize(target);
const appConfig = (_a = this[`get${_target}AppConfigData`]) === null || _a === void 0 ? void 0 : _a.call(this, routesConfig, (_b = globalConfig[target]) !== null && _b !== void 0 ? _b : {});
if (lodash_1.default.isEmpty(appConfig.tabBar)) {
delete appConfig.tabBar; // 微信小程序tabBar不能为空对象,所以当为空对象时,索性所有小程序都删了
}
this.generateThemeConfig(appConfig);
// FIX: 修复初始化时找不到配置文件
// 初始化时,需要立即生成配置文件
if (lodash_1.default.isEmpty(wechatAppConfig.tabBar)) {
delete wechatAppConfig.tabBar;
}
if (immediate) {
return this.generateAppConfig({ wechat: wechatAppConfig, tuya: tuyaAppConfig });
return this.generateAppConfig({ [target]: appConfig });
}

@@ -69,3 +73,3 @@ // FIX: 修复间接(更新routes.config.ts)更新app.config.ts文件,无法触发重新编译,导致小程序app.json未更新

setTimeout(() => {
this.generateAppConfig({ wechat: wechatAppConfig, tuya: tuyaAppConfig });
this.generateAppConfig({ [target]: appConfig });
}, 1000);

@@ -187,4 +191,37 @@ },

},
generateThemeConfig(appConfig) {
const src = this.checkThemeConfig(appConfig.themeLocation);
if (cacheThemeLocation.source && cacheThemeLocation.source !== src) {
fs_extra_1.default.unlinkSync(cacheThemeLocation.dest);
fs_extra_1.default.unwatchFile(cacheThemeLocation.source);
cacheThemeLocation = {};
}
if (src) {
appConfig.themeLocation = path_1.default.basename(src);
handle();
fs_extra_1.default.watchFile(src, handle);
}
function handle() {
const { cwd, target } = api.options;
const output = path_1.default.join(cwd, 'dist', target, path_1.default.basename(src));
const data = fs_extra_1.default.readFileSync(src).toString('utf-8');
fs_extra_1.default.outputFile(output, data, 'utf-8');
cacheThemeLocation.dest = output;
cacheThemeLocation.source = src;
}
},
checkThemeConfig(src) {
if (!src) {
return;
}
const { cwd, source } = api.options;
const inputs = [path_1.default.resolve(cwd, source, src), path_1.default.resolve(cwd, src)];
for (const input of inputs) {
if (fs_extra_1.default.pathExistsSync(input)) {
return input;
}
}
},
};
}
exports.default = PluginRouter;

10

package.json
{
"name": "@ray-js/build-plugin-router",
"version": "0.5.5",
"version": "0.5.6-beta-1",
"description": "Ray build plugin for router",

@@ -24,4 +24,4 @@ "keywords": [

"dependencies": {
"@ray-js/plugin-utils": "^0.5.5",
"@ray-js/shared": "^0.5.5",
"@ray-js/plugin-utils": "^0.5.6-beta-1",
"@ray-js/shared": "^0.5.6-beta-1",
"chokidar": "^3.5.2",

@@ -31,3 +31,3 @@ "colors": "1.4.0"

"devDependencies": {
"@ray-js/types": "^0.5.5"
"@ray-js/types": "^0.5.6-beta-1"
},

@@ -40,4 +40,4 @@ "maintainers": [

],
"gitHead": "a8ddeab1f4782e6b3772dc2deeae3e3e3af0de00",
"gitHead": "46f291d3c38bb9fa1af739d01f9513c39e3b6be9",
"repository": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc