Commit e30cab79 authored by haiyoucuv's avatar haiyoucuv

oss upload

parent be5fcb95
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="16751153-0676-4795-9253-f8f1d2290e77" name="Default Changelist" comment="oss" /> <list default="true" id="16751153-0676-4795-9253-f8f1d2290e77" name="Default Changelist" comment="oss">
<change afterPath="$PROJECT_DIR$/.idea/jsLibraryMappings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/script/upload.js" beforeDir="false" afterPath="$PROJECT_DIR$/script/upload.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/yarn.lock" beforeDir="false" afterPath="$PROJECT_DIR$/yarn.lock" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -18,12 +24,35 @@ ...@@ -18,12 +24,35 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="javascript.nodejs.core.library.configured.version" value="14.2.0" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="yarn" /> <property name="nodejs_package_manager_path" value="yarn" />
<property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" /> <property name="settings.editor.selected.configurable" value="editor.preferences.fonts.default" />
</component> </component>
<component name="RunManager" selected="npm.upload">
<configuration name="upload.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/script/upload.js" working-dir="$PROJECT_DIR$/script">
<method v="2" />
</configuration>
<configuration name="upload" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="upload" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="npm.upload" />
<item itemvalue="Node.js.upload.js" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration"> <component name="SvnConfiguration">
<configuration /> <configuration />
</component> </component>
...@@ -34,7 +63,7 @@ ...@@ -34,7 +63,7 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1591270575177</updated> <updated>1591270575177</updated>
<workItem from="1591270576445" duration="308000" /> <workItem from="1591270576445" duration="3131000" />
</task> </task>
<task id="LOCAL-00001" summary="oss"> <task id="LOCAL-00001" summary="oss">
<created>1591270731235</created> <created>1591270731235</created>
...@@ -58,22 +87,30 @@ ...@@ -58,22 +87,30 @@
<screen x="37" y="23" width="1643" height="1027" /> <screen x="37" y="23" width="1643" height="1027" />
</state> </state>
<state x="467" y="108" key="CommitChangelistDialog2/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270742820" /> <state x="467" y="108" key="CommitChangelistDialog2/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270742820" />
<state width="1601" height="280" key="GridCell.Tab.0.bottom" timestamp="1591270708263"> <state width="788" height="466" key="DebuggerActiveHint" timestamp="1591272734456">
<screen x="37" y="23" width="1643" height="1027" /> <screen x="37" y="23" width="1643" height="1027" />
</state> </state>
<state width="1601" height="280" key="GridCell.Tab.0.bottom/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270708263" /> <state width="788" height="466" key="DebuggerActiveHint/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591272734456" />
<state width="1601" height="280" key="GridCell.Tab.0.center" timestamp="1591270708261"> <state width="1601" height="401" key="GridCell.Tab.0.bottom" timestamp="1591273345840">
<screen x="37" y="23" width="1643" height="1027" /> <screen x="1680" y="-199" width="1920" height="1177" />
</state> </state>
<state width="1601" height="280" key="GridCell.Tab.0.center/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270708261" /> <state width="1601" height="401" key="GridCell.Tab.0.bottom/37.23.1643.1027/1680.-199.1920.1177@1680.-199.1920.1177" timestamp="1591273345840" />
<state width="1601" height="280" key="GridCell.Tab.0.left" timestamp="1591270708260"> <state width="1601" height="280" key="GridCell.Tab.0.bottom/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591273002142" />
<screen x="37" y="23" width="1643" height="1027" /> <state width="1601" height="401" key="GridCell.Tab.0.center" timestamp="1591273345838">
<screen x="1680" y="-199" width="1920" height="1177" />
</state> </state>
<state width="1601" height="280" key="GridCell.Tab.0.left/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270708260" /> <state width="1601" height="401" key="GridCell.Tab.0.center/37.23.1643.1027/1680.-199.1920.1177@1680.-199.1920.1177" timestamp="1591273345838" />
<state width="1601" height="280" key="GridCell.Tab.0.right" timestamp="1591270708261"> <state width="1601" height="280" key="GridCell.Tab.0.center/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591273002141" />
<screen x="37" y="23" width="1643" height="1027" /> <state width="1601" height="401" key="GridCell.Tab.0.left" timestamp="1591273345835">
<screen x="1680" y="-199" width="1920" height="1177" />
</state>
<state width="1601" height="401" key="GridCell.Tab.0.left/37.23.1643.1027/1680.-199.1920.1177@1680.-199.1920.1177" timestamp="1591273345835" />
<state width="1601" height="280" key="GridCell.Tab.0.left/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591273002140" />
<state width="1601" height="401" key="GridCell.Tab.0.right" timestamp="1591273345839">
<screen x="1680" y="-199" width="1920" height="1177" />
</state> </state>
<state width="1601" height="280" key="GridCell.Tab.0.right/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591270708261" /> <state width="1601" height="401" key="GridCell.Tab.0.right/37.23.1643.1027/1680.-199.1920.1177@1680.-199.1920.1177" timestamp="1591273345839" />
<state width="1601" height="280" key="GridCell.Tab.0.right/37.23.1643.1027/1680.-199.1920.1177@37.23.1643.1027" timestamp="1591273002141" />
<state x="654" y="263" key="RollbackChangesDialog" timestamp="1591270716679"> <state x="654" y="263" key="RollbackChangesDialog" timestamp="1591270716679">
<screen x="37" y="23" width="1643" height="1027" /> <screen x="37" y="23" width="1643" height="1027" />
</state> </state>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2", "@testing-library/user-event": "^7.1.2",
"iconv-lite": "^0.5.1",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "3.4.1" "react-scripts": "3.4.1"
...@@ -20,7 +21,8 @@ ...@@ -20,7 +21,8 @@
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject",
"upload": "node script/upload.js"
}, },
"eslintConfig": { "eslintConfig": {
"extends": "react-app" "extends": "react-app"
......
...@@ -20,6 +20,7 @@ class TuiaAutoUpload { ...@@ -20,6 +20,7 @@ class TuiaAutoUpload {
} }
this.init(); this.init();
} }
init() { init() {
var _this = this; var _this = this;
this.client = new OSS({ this.client = new OSS({
...@@ -40,6 +41,7 @@ class TuiaAutoUpload { ...@@ -40,6 +41,7 @@ class TuiaAutoUpload {
}) })
return this; return this;
} }
files() { files() {
var _this = this; var _this = this;
if (this._files) return this._files; if (this._files) return this._files;
...@@ -78,16 +80,18 @@ class TuiaAutoUpload { ...@@ -78,16 +80,18 @@ class TuiaAutoUpload {
fileDisplay(this.options.dir); fileDisplay(this.options.dir);
return this._files; return this._files;
} }
start() { start() {
this.files().map((file, index) => { this.files().map((file, index) => {
let _this = this; let _this = this;
const path1 = path.join(path.resolve(__dirname, '..'), 'released', file); const path1 = path.join(path.resolve(__dirname, '..'), 'build', file);
let originFile; let originFile;
this.existFiles = 0; this.existFiles = 0;
this.uploadFiles = 0; this.uploadFiles = 0;
this.errorFiles = 0; this.errorFiles = 0;
co(function* () { co(function* () {
const originPath = `${_this.options.originDir}${file}`; /// TODO 去除了 static
const originPath = `${_this.options.originDir}${file}`.replace("/static", '');
try { try {
originFile = yield _this.client.head(originPath); originFile = yield _this.client.head(originPath);
} catch (error) { } catch (error) {
...@@ -120,41 +124,14 @@ class TuiaAutoUpload { ...@@ -120,41 +124,14 @@ class TuiaAutoUpload {
} }
} }
const configFileName = 'project.json';
if (!fs.existsSync(configFileName)) {
throw new Error(`${configFileName}不存在.`)
}
let config = fs.readFileSync('project.json');
config = JSON.parse(config + '');
if (!config.type) {
throw new Error(`${configFileName}的type不存在.`)
}
if (!config.name) {
throw new Error(`${configFileName}的name不存在.`)
}
const now = new Date(); const now = new Date();
const version = Math.round(now.getTime() / 1000); const version = Math.round(now.getTime() / 1000);
console.log(`版本号: console.log(`版本号:
${version}`) ${version}`);
const autoupload = new TuiaAutoUpload({ const autoupload = new TuiaAutoUpload({
dir: './released/', dir: './build/static/',
// dir: path.join(__dirname, './released/'), originDir: `/spark_v1/dev/${version}/`
originDir: `/db_games/${config.type}/${config.name}/${version}/`
}, "prod") }, "prod")
autoupload.start() autoupload.start()
var iconv = require('iconv-lite');
var readPath = "./released/resource/";
//读取json文件
var data = iconv.decode(fs.readFileSync(readPath + "res.json"), "GBK");
//反序列化
data = JSON.parse(data);
data.path = `https://yun.duiba.com.cn/spark_v1/`
//写入目标文件夹,可配置,每个项目必须修改,或者直接和project的保持一致(淘宝项目文件固定后)
var endPath = './src/';
var endFile = `export const ResJson = ${JSON.stringify(data, "", "\t")}`
fs.writeFileSync(endPath + "ResJson.ts", endFile);
\ No newline at end of file
...@@ -5429,6 +5429,13 @@ iconv-lite@0.4.24, iconv-lite@^0.4.15, iconv-lite@^0.4.24: ...@@ -5429,6 +5429,13 @@ iconv-lite@0.4.24, iconv-lite@^0.4.15, iconv-lite@^0.4.24:
dependencies: dependencies:
safer-buffer ">= 2.1.2 < 3" safer-buffer ">= 2.1.2 < 3"
iconv-lite@^0.5.1:
version "0.5.1"
resolved "https://registry.npm.taobao.org/iconv-lite/download/iconv-lite-0.5.1.tgz?cache=0&sync_timestamp=1579333928319&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ficonv-lite%2Fdownload%2Ficonv-lite-0.5.1.tgz#b2425d3c7b18f7219f2ca663d103bddb91718d64"
integrity sha1-skJdPHsY9yGfLKZj0QO925FxjWQ=
dependencies:
safer-buffer ">= 2.1.2 < 3"
icss-utils@^4.0.0, icss-utils@^4.1.1: icss-utils@^4.0.0, icss-utils@^4.1.1:
version "4.1.1" version "4.1.1"
resolved "https://registry.npm.taobao.org/icss-utils/download/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467" resolved "https://registry.npm.taobao.org/icss-utils/download/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment