Skip to content

Commit

Permalink
fix CRLF
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Apr 8, 2020
1 parent b370253 commit f4cb3ff
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 48 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## [Unreleased]

## [0.13.13] - 2020-04-08

**koot**

- 修正 `CRLF` 问题,重新发布

## [0.13.12] - 2020-04-08

**koot**
Expand Down
77 changes: 38 additions & 39 deletions packages/koot/bin/analyze.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env node

const fs = require('fs-extra')
const path = require('path')
const program = require('commander')
const fs = require('fs-extra');
const path = require('path');
const program = require('commander');
// const chalk = require('chalk')

const before = require('./_before')
const before = require('./_before');

// const __ = require('../utils/translate')
const validateConfig = require('../libs/validate-config')
const validateConfig = require('../libs/validate-config');
// const readBuildConfigFile = require('../utils/read-build-config-file')
const setEnvFromCommand = require('../utils/set-env-from-command')
const initNodeEnv = require('../utils/init-node-env')
const getDirTemp = require('../libs/get-dir-tmp')
const setEnvFromCommand = require('../utils/set-env-from-command');
const initNodeEnv = require('../utils/init-node-env');
const getDirTemp = require('../libs/get-dir-tmp');

const kootWebpackBuild = require('koot-webpack/build')
const kootWebpackBuild = require('koot-webpack/build');

program
.version(require('../package').version, '-v, --version')
Expand All @@ -25,64 +25,63 @@ program
.option('--config <config-file-path>', 'Set config file pathname')
.option('--type <project-type>', 'Set project type')
.option('--koot-test', 'Koot test mode')
.parse(process.argv)
.parse(process.argv);

const run = async () => {
// 清空 log
process.stdout.write('\x1B[2J\x1B[0f')
process.stdout.write('\x1B[2J\x1B[0f');

const {
client, server,
stage: _stage,
config,
type,
} = program
const { client, server, stage: _stage, config, type } = program;

initNodeEnv()
initNodeEnv();
// console.log(program)

setEnvFromCommand({
config,
type,
})
type
});

const stage = _stage ||
const stage =
_stage ||
(client ? 'client' : undefined) ||
(server ? 'server' : undefined) ||
'client'
'client';

process.env.WEBPACK_BUILD_STAGE = stage || 'client'
process.env.WEBPACK_BUILD_ENV = 'prod'
process.env.WEBPACK_BUILD_STAGE = stage || 'client';
process.env.WEBPACK_BUILD_ENV = 'prod';

await before(program)
await before(program);

// 处理目录
const dirAnalyzeBuild = require('../libs/get-dir-dev-tmp')(undefined, 'analyze')
await fs.ensureDir(dirAnalyzeBuild)
await fs.emptyDir(dirAnalyzeBuild)
await fs.ensureDir(path.resolve(dirAnalyzeBuild, 'public'))
await fs.ensureDir(path.resolve(dirAnalyzeBuild, 'server'))
const dirAnalyzeBuild = require('../libs/get-dir-dev-tmp')(
undefined,
'analyze'
);
await fs.ensureDir(dirAnalyzeBuild);
await fs.emptyDir(dirAnalyzeBuild);
await fs.ensureDir(path.resolve(dirAnalyzeBuild, 'public'));
await fs.ensureDir(path.resolve(dirAnalyzeBuild, 'server'));

// 读取构建配置
const kootConfig = {
...await validateConfig(),
...(await validateConfig()),

dist: dirAnalyzeBuild,
bundleVersionsKeep: false,
}
bundleVersionsKeep: false
};

await kootWebpackBuild({
analyze: true,
...kootConfig
})
});

// 清理临时目录
await fs.remove(getDirTemp())
await fs.remove(getDirTemp());

// 清理结果目录
await fs.remove(dirAnalyzeBuild)
await fs.remove(dirAnalyzeBuild);

console.log(' ')
}
console.log(' ');
};

run()
run();
5 changes: 3 additions & 2 deletions packages/koot/bin/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
/* eslint-disable no-console */

const fs = require('fs-extra');
const path = require('path');
Expand Down Expand Up @@ -85,7 +86,7 @@ const run = async () => {
(typeof type === 'string' ? ` --type ${type}` : '') +
(kootTest ? ` --koot-test` : '');

let stderr = '';
const stderr = '';
await new Promise(resolve => {
const child = spawn('koot-build', buildCmdArgs.split(' '), {
stdio: 'inherit',
Expand Down Expand Up @@ -149,7 +150,7 @@ const run = async () => {

// 打出错误报告
console.log('');
console.trace(stderr);
console.error(stderr);

// 终止流程
return;
Expand Down
14 changes: 7 additions & 7 deletions packages/koot/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global
__KOOT_SSR__: false,
__KOOT_SSR__: false
*/

import isRenderSafe from './React/is-render-safe';
Expand Down Expand Up @@ -62,7 +62,7 @@ export let history = (() => getHistory())();

// ============================================================================

export const getCache = (localeId) => {
export const getCache = localeId => {
if (!isRenderSafe()) return {};
if (__CLIENT__) {
if (typeof window.__KOOT_CACHE__ !== 'object')
Expand Down Expand Up @@ -91,22 +91,22 @@ export const getCtx = () => {
// ============================================================================

if (__DEV__) {
global.__KOOT_SSR_SET__ = (v) => {
global.__KOOT_SSR_SET__ = v => {
global.__KOOT_SSR__ = v;
};
global.__KOOT_SSR_SET_LOCALEID__ = (v) => {
global.__KOOT_SSR_SET_LOCALEID__ = v => {
global.__KOOT_LOCALEID__ = v;
localeId = v;
};
global.__KOOT_SSR_SET_STORE__ = (v) => {
global.__KOOT_SSR_SET_STORE__ = v => {
global.__KOOT_STORE__ = v;
store = v;
};
global.__KOOT_SSR_SET_HISTORY__ = (v) => {
global.__KOOT_SSR_SET_HISTORY__ = v => {
global.__KOOT_HISTORY__ = v;
history = v;
};
global.__KOOT_SSR_SET_CTX__ = (v) => {
global.__KOOT_SSR_SET_CTX__ = v => {
global.__KOOT_CTX__ = v;
};
// if (__CLIENT__) {
Expand Down

0 comments on commit f4cb3ff

Please sign in to comment.