-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: version * fix: icon size * fix: icon file size * Feat: record DAU (#25) * fix: stdout match (#38) * fix: fail to install nvm (#29) * Fix: fail to install code to path (#37) * Feat: auto download package (#31) * Fix: vscode cli command not found (#36) * fix: nvm has installed but actually not installed (#39) * fix: managerVersion not found (#40) * Fix: electron not found in prod env (#41)
- Loading branch information
Showing
36 changed files
with
2,501 additions
and
1,474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as path from 'path'; | ||
import * as fse from 'fs-extra'; | ||
import { TOOLKIT_PACKAGES_DIR } from '../constants'; | ||
import downloadFile from '../utils/downloadFile'; | ||
import log from '../utils/log'; | ||
|
||
class AutoDownloader { | ||
async checkForDownloadAvailable(sourceFileName: string) { | ||
const sourceFilePath = path.join(TOOLKIT_PACKAGES_DIR, sourceFileName); | ||
const sourceFileExists = await fse.pathExists(sourceFilePath); | ||
log.info(sourceFileExists ? `${sourceFileName} has already existed in ${sourceFilePath}` : `${sourceFileName} is available to download.`); | ||
return !sourceFileExists; | ||
} | ||
|
||
async downloadPackage({ downloadUrl, sourceFileName }) { | ||
await downloadFile(downloadUrl, TOOLKIT_PACKAGES_DIR, sourceFileName); | ||
} | ||
|
||
async start(data) { | ||
const { sourceFileName } = data; | ||
const downloadAvailable = await this.checkForDownloadAvailable(sourceFileName); | ||
if (downloadAvailable) { | ||
await this.downloadPackage(data); | ||
} | ||
} | ||
} | ||
|
||
export default AutoDownloader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { IBasePackageInfo, Platform } from '../types'; | ||
import store, { packagesDataKey } from '../store'; | ||
import getPackageFileName from '../utils/getPackageFileName'; | ||
import AutoDownloader from './AutoDownloader'; | ||
|
||
const packageTypes = ['bases']; | ||
|
||
export async function autoDownloadPackages() { | ||
const data = store.get(packagesDataKey); | ||
// the packages which should be checked for available downloading | ||
const packageDatas = []; | ||
|
||
packageTypes.forEach((packageType: string) => { | ||
const packagesInfo: IBasePackageInfo[] = data[packageType] || []; | ||
|
||
for (const packageInfo of packagesInfo) { | ||
const { downloadUrl, platforms } = packageInfo; | ||
const currentPlatform = process.platform as Platform; | ||
if (!downloadUrl || !platforms.includes(currentPlatform)) { | ||
continue; | ||
} | ||
const packageFileName = getPackageFileName(packageInfo); | ||
packageDatas.push({ sourceFileName: packageFileName, downloadUrl }); | ||
} | ||
}); | ||
|
||
await Promise.all(packageDatas.map((packageData) => { | ||
const autoDownloader = new AutoDownloader(); | ||
return autoDownloader.start(packageData); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
\. "$NVM_DIR/nvm.sh" | ||
|
||
echo "$(command -v nvm 2>/dev/null)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
import * as path from 'path'; | ||
import * as fse from 'fs-extra'; | ||
import { ipcMain } from 'electron'; | ||
import { IpcMainInvokeEvent } from 'electron/main'; | ||
import getNodeVersions from '../utils/getNodeVersions'; | ||
import { getPackageInfo } from '../packageInfo'; | ||
import { IBasePackageInfo } from '../types'; | ||
import store, { packagesDataKey } from '../store'; | ||
|
||
export default () => { | ||
ipcMain.handle('get-node-info', async () => { | ||
// TODO: get data.json from OSS and save it in the storage when app starts first | ||
const data = await fse.readJSON(path.join(__dirname, '../data', 'data.json')); | ||
ipcMain.handle('get-node-info', () => { | ||
const data = store.get(packagesDataKey); | ||
const { bases = [] }: { bases: IBasePackageInfo[] } = data; | ||
const nodeBasicInfo = bases.find((base: IBasePackageInfo) => base.name === 'node'); | ||
const nodeInfo = getPackageInfo(nodeBasicInfo); | ||
|
||
return nodeInfo; | ||
}); | ||
|
||
ipcMain.handle('get-node-versions', async (event: IpcMainInvokeEvent) => { | ||
ipcMain.handle('get-node-versions', async () => { | ||
return await getNodeVersions(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.