Skip to content

Commit de860f4

Browse files
authored
feat: rename rpk (#37)
Signed-off-by: JayFate <[email protected]>
1 parent 56e05d9 commit de860f4

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

packages/hap-packager/src/plugins/zip-plugin.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,26 @@ function getDistFilename(options, distExt) {
160160
)
161161
}
162162
let distName
163+
164+
let { PACKAGE_NAME, PACKAGE_TYPE, NODE_ENV } =
165+
globalConfig.launchOptions?.compileOptions?.defineOptions || {}
166+
// eg. packageName.release.production.customName.version.rpk
167+
const distNameOption = [
168+
PACKAGE_NAME || options.name,
169+
PACKAGE_TYPE || flagSign,
170+
NODE_ENV,
171+
// customName
172+
undefined,
173+
options.versionName,
174+
distExt
175+
]
163176
if (options.buildNameFormat === compileOptionsMeta.buildNameFormat.ORIGINAL) {
164177
distName = `${options.name}.${flagSign}.${distExt}`
165178
} else if (options.buildNameFormat && options.buildNameFormat.startsWith('CUSTOM=')) {
166-
const custom = options.buildNameFormat.split('=')[1]
167-
distName = `${options.name}.${flagSign}.${custom}.${options.versionName}.${distExt}`
168-
} else {
169-
distName = `${options.name}.${flagSign}.${options.versionName}.${distExt}`
179+
// customName
180+
distNameOption[3] = options.buildNameFormat.split('=')[1]
170181
}
182+
distName = distName || distNameOption.filter(Boolean).join('.')
171183
return distName
172184
}
173185

packages/hap-packager/src/router/routes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ async function logger(context, next) {
131131
async function notify(context, next) {
132132
const callback = context.conf.options.callback
133133
if (typeof callback === 'function') {
134-
const params = { action: 'runCompile' }
134+
const params = {
135+
action: 'runCompile',
136+
defineOptions: globalConfig.launchOptions?.compileOptions?.defineOptions
137+
}
135138
callback(params)
136139
}
137140
context.status = 200

packages/hap-toolkit/src/gen-webpack-conf/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default async function genWebpackConf(launchOptions, mode) {
8989
if (launchOptions.ideConfig && typeof launchOptions.ideConfig.cli === 'object') {
9090
launchOptions = Object.assign({}, launchOptions.ideConfig.cli, launchOptions)
9191
}
92+
globalConfig.launchOptions = launchOptions
9293

9394
// 源代码目录
9495
const SRC_DIR = path.resolve(cwd, globalConfig.sourceRoot)

0 commit comments

Comments
 (0)