Skip to content

Commit

Permalink
feat(publish): 使用统一的发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
novlan1 committed Aug 15, 2023
1 parent 43e7ee4 commit f9b6a45
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
"typings": "lib/index.d.ts",
"files": [
"lib",
"bin",
"LICENSE",
"CHANGELOG.md",
"README.md",
"script",
"cil"
"README.md"
],
"sideEffects": "false",
"repository": {
Expand Down
29 changes: 0 additions & 29 deletions script/publish.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/build-upload/build-upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { execCommand } from '../node/node-command';

import { getPublishBashPath } from '../publish/helper';

const DEFAULT_HOST_TARGET_DIR = '/root/ft_local';

Expand Down Expand Up @@ -57,7 +57,7 @@ function upload({
}
console.log('[upload] 开始上传...');

const publishBash = require('path').resolve(__dirname, '../script/publish.sh');
const publishBash = getPublishBashPath();

execCommand(`sh ${publishBash} ./dist/${bundleName}.tar.gz ${hostTargetDir} ${hostName} ${hostPwd}`, root, 'inherit');

Expand Down
5 changes: 5 additions & 0 deletions src/publish/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export function getRootDir() {
}


export function getPublishBashPath() {
return path.resolve(__dirname, '../bin/publish.sh');
}


export function getEnvValue(key: string) {
const rootDir = getRootDir();
const localEnvPath = path.join(rootDir, '.env.local');
Expand Down
4 changes: 2 additions & 2 deletions src/publish/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { spawnSync } from 'child_process';

import { getIPAddress, getIPAddressStr } from '../ip/ip';

import { getRootDir, getEnvValue } from './helper';
import { getRootDir, getEnvValue, getPublishBashPath } from './helper';
import { postFile } from './post-file';
import { ENV_MAP, PUBLISH_ENV_MAP, PUBLISH_HOST_ENV } from './config';
import type { IPublishOptions } from './types';

const rootDir = getRootDir();
const PUBLISH_BASH_FILE = path.resolve(__dirname, '../script/publish.sh');
const PUBLISH_BASH_FILE = getPublishBashPath();


function getDevPwd() {
Expand Down

0 comments on commit f9b6a45

Please sign in to comment.