Skip to content

Commit 7ec3e31

Browse files
authored
Merge pull request #52 from appworks-lab/release-next
Release 0.2.1
2 parents c901e69 + 4643b69 commit 7ec3e31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+779
-241
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = getESLintConfig('react-ts', {
66
'@typescript-eslint/explicit-function-return-type': 0,
77
'react-hooks/exhaustive-deps': 0,
88
'@iceworks/best-practices/recommend-polyfill': 0,
9-
'import/order': 1,
9+
'import/order': 0,
1010
'no-param-reassign': 0,
1111
'@typescript-eslint/no-require-imports': 0,
1212
'no-await-in-loop': 0

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# CHANGELOG
2+
3+
## 0.2.1
4+
5+
- Fix: fail to get internal npm package info
6+
7+
## 0.2.0
8+
9+
- Feat: git manager, including global config, user config and SSH key
10+
- Feat: npm register manager, fast switch between different registries, e.g: npm, yarn, taobao
11+
- Feat: npm package manager, fast install, upgrade, reinstall and uninstall global dependencies
12+
13+
## 0.1.1
14+
15+
- Feat: record DAU
16+
- Feat: download package automatically
17+
- Fix: nvm install fail when bash profile files exist
18+
- Fix: icon size
19+
- Fix: code command was not found
20+
21+
## 0.1.0
22+
23+
- Feat: fast install packages, including VS Code/Git/Node.js/AppWorks/Chrome
24+
- Feat: node version manager

main/constants.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as path from 'path';
2+
import * as os from 'os';
23
import { ILocalPackageInfo } from './types';
34

45
export const APPLICATIONS_DIR_PATH = '/Applications';
5-
6+
export const HOME_DIR = os.homedir();
67
export const PACKAGE_JSON_FILE_NAME = 'package.json';
78

89
export const TOOLKIT_DIR = path.join(process.env.HOME, '.toolkit');
@@ -26,15 +27,14 @@ export const INSTALL_COMMAND_PACKAGES = [
2627
commandRelativePath: './Contents/Resources/app/bin/code',
2728
},
2829
];
29-
export const NOT_REINSTALL_DEPENDENCIES = ['npm'];
3030
// bash profile
31-
export const PROFILE_FILES = ['.bash_profile', '.bashrc', '.zshrc'];
32-
export const DEFAULT_PROFILE_FILE = '.bash_profile';
31+
export const ZSHRC_FILE_NAME = '.zshrc';
32+
export const BASH_PROFILE_FILE_NAME = '.bash_profile';
33+
export const PROFILE_FILES = [BASH_PROFILE_FILE_NAME, '.bashrc', ZSHRC_FILE_NAME];
3334
// npm
34-
export const NPMRC_PATH = path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.npmrc');
35+
export const NPMRC_PATH = path.join(HOME_DIR, '.npmrc');
3536
export const NPM_REGISTRY = 'https://registry.npmjs.org/';
3637
export const TAOBAO_NPM_REGISTRY = 'https://registry.npm.taobao.org';
37-
export const ALI_NPM_REGISTRY = 'https://registry.npm.alibaba-inc.com/';
3838
export const TAOBAO_NODE_MIRROR = 'https://npm.taobao.org/mirrors/node';
3939
// git
40-
export const GLOBAL_GITCONFIG_PATH = path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.gitconfig');
40+
export const GLOBAL_GITCONFIG_PATH = path.join(HOME_DIR, '.gitconfig');

main/data/data.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,8 @@
122122
{
123123
"name": "taobao",
124124
"registry": "https://registry.npm.taobao.org/",
125-
"isInternal": false
126-
},
127-
{
128-
"name": "tnpm",
129-
"registry": " https://registry.npm.alibaba-inc.com/",
130-
"isInternal": true
125+
"isInternal": false,
126+
"recommended": true
131127
}
132128
],
133129
"browserExtensions": [

main/data/shells/install-nvm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ nvm_source() {
6868
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
6969
# NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"
7070
# use China mirror
71-
NVM_SOURCE_URL="https://gitee.com/mirrors/nvm.git"
71+
NVM_SOURCE_URL="https://gitee.com/luhengchang/nvm.git"
7272
else
7373
nvm_echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
7474
return 1

main/git/config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
removeSSHConfig,
1212
addSSHConfig,
1313
} from './ssh';
14+
import { record } from '../recorder';
1415

1516
const USER_GIT_CONFIG_FILENAME_PREFIX = '.gitconfig-';
1617
const IGNORE_CONFIG_KEYS = ['gitDir'];
@@ -24,6 +25,10 @@ export async function getGlobalGitConfig() {
2425
export async function updateGlobalGitConfig(gitConfig: object) {
2526
log.info('update-global-git-config', gitConfig);
2627
await writeGitConfig(GLOBAL_GITCONFIG_PATH, gitConfig);
28+
record({
29+
module: 'git',
30+
action: 'updateGlobalGitConfig',
31+
});
2732
}
2833

2934
export async function getExistedUserGitConfigNames() {
@@ -70,6 +75,10 @@ export async function addUserGitConfig(userGitConfig: IAddUserConfig) {
7075
delete userGitConfig.configName;
7176
await writeGitConfig(gitConfigPath, userGitConfig);
7277
await addSSHConfig({ hostName, configName, userName });
78+
record({
79+
module: 'git',
80+
action: 'addUserGitConfig',
81+
});
7382
}
7483

7584
export async function updateUserGitConfig(gitConfig: any, configName: string) {
@@ -85,6 +94,10 @@ export async function updateUserGitConfig(gitConfig: any, configName: string) {
8594
await writeGitConfig(gitConfigPath, gitConfig);
8695

8796
log.info('update-user-git-config', configName, gitConfig);
97+
record({
98+
module: 'git',
99+
action: 'updateUserGitConfig',
100+
});
88101
}
89102

90103
async function getUserGitDirs() {
@@ -125,6 +138,10 @@ export async function updateUserGitDir(
125138
await writeGitConfig(GLOBAL_GITCONFIG_PATH, globalGitConfig);
126139

127140
log.info('update-user-git-dir: ', currentIncludeIfKey, globalGitConfig[currentIncludeIfKey]);
141+
record({
142+
module: 'git',
143+
action: 'updateUserGitDir',
144+
});
128145
}
129146

130147
export async function removeUserGitDir(gitDir: string, configName: string) {
@@ -137,6 +154,10 @@ export async function removeUserGitDir(gitDir: string, configName: string) {
137154
delete globalGitConfig[includeIfKey];
138155
await writeGitConfig(GLOBAL_GITCONFIG_PATH, globalGitConfig);
139156
log.info('remove-user-git-dir: ', includeIfKey, gitConfigPath);
157+
record({
158+
module: 'git',
159+
action: 'removeUserGitDir',
160+
});
140161
} else {
141162
const error = new Error(`Can not remove ${gitDir}. The ${includeIfValue} is not found.`);
142163
log.error(error);
@@ -154,6 +175,11 @@ export async function removeUserGitConfig(configName: string, gitDirs = []) {
154175
// remove the gitconfig file
155176
const gitConfigPath = getGitConfigPath(configName);
156177
await fse.remove(gitConfigPath);
178+
179+
record({
180+
module: 'git',
181+
action: 'removeUserGitConfig',
182+
});
157183
}
158184

159185
async function parseGitConfig(gitConfigPath: string) {

main/git/ssh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as fse from 'fs-extra';
44
import SSHKeyGen = require('ssh-keygen');
55
import SSHConfig = require('ssh-config');
66
import log from '../utils/log';
7+
import { HOME_DIR } from '../constants';
78

89
const SSHKeyGenAsync = util.promisify(SSHKeyGen);
910

10-
const HOME_DIR = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
1111
export const SSHDir = path.join(HOME_DIR, '.ssh');
1212
const SSHConfigPath = path.join(SSHDir, 'config');
1313

main/ipc/checkIsAliInternal.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ipcMain } from 'electron';
2+
import checkIsAliInternal from '../utils/checkIsAliInternal';
3+
4+
export default () => {
5+
ipcMain.handle('check-is-ali-internal', async () => {
6+
return await checkIsAliInternal();
7+
});
8+
};

main/ipc/handleNpmDependency.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import * as child_process from 'child_process';
2+
import * as path from 'path';
13
import { ipcMain, IpcMainInvokeEvent } from 'electron';
4+
import { send as sendMainWindow } from '../window';
25
import {
36
getGlobalDependencies,
47
uninstallGlobalDependency,
58
updateGlobalDependency,
69
reinstallGlobalDependency,
710
searchNpmDependencies,
811
installGlobalDependency,
12+
getGlobalDependenciesInfo,
913
} from '../npm/dependency';
14+
import killChannelChildProcess from '../utils/killChannelChildProcess';
15+
import { record } from '../recorder';
16+
17+
const childProcessMap = new Map();
1018

1119
export default () => {
1220
ipcMain.handle('get-global-npm-dependencies', async (e: IpcMainInvokeEvent, force) => {
@@ -33,4 +41,31 @@ export default () => {
3341
ipcMain.handle('search-npm-dependencies', async (e: IpcMainInvokeEvent, query: string) => {
3442
return await searchNpmDependencies(query);
3543
});
44+
45+
ipcMain.handle('get-global-dependencies-info', async () => {
46+
return await getGlobalDependenciesInfo();
47+
});
48+
49+
ipcMain.handle('create-custom-global-dependencies-dir', async (e: IpcMainInvokeEvent, channel: string, currentGlobalDepsPath: string) => {
50+
const childProcess = child_process.fork(path.join(__dirname, '..', 'npm/dependency/createCustomGlobalDepsDir'));
51+
childProcessMap.set(channel, childProcess);
52+
53+
childProcess.send({ currentGlobalDepsPath, channel });
54+
55+
childProcessMap.set(channel, childProcess);
56+
57+
childProcess.on('message', ({ data }: any) => {
58+
if (data.status === 'done') {
59+
record({
60+
module: 'node',
61+
action: 'createCustomGlobalDependenciesDir',
62+
});
63+
}
64+
sendMainWindow(channel, data);
65+
});
66+
});
67+
68+
ipcMain.handle('cancel-create-custom-global-dependencies-dir', async (e: IpcMainInvokeEvent, channel: string) => {
69+
killChannelChildProcess(childProcessMap, channel);
70+
});
3671
};

main/ipc/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import handleGitConfig from './handleGitConfig';
66
import getFolderPath from './getFolderPath';
77
import handleNpmRegistry from './handleNpmRegistry';
88
import handleNpmDependency from './handleNpmDependency';
9+
import checkIsAliInternal from './checkIsAliInternal';
910

1011
export default () => {
1112
getBasePackagesInfo();
@@ -23,4 +24,6 @@ export default () => {
2324
handleNpmRegistry();
2425

2526
handleNpmDependency();
27+
28+
checkIsAliInternal();
2629
};

0 commit comments

Comments
 (0)