Skip to content

Commit c612ad8

Browse files
author
winjo
committed
feat: 使用 antcode private_token 请求
1 parent 8f7cba7 commit c612ad8

14 files changed

Lines changed: 122 additions & 43 deletions

File tree

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,31 @@
22
> Ant Codespaces 纯前端版本临时代号
33
44

5-
## 项目研发
5+
## 项目启动
66
### 准备
77
需要安装 yarn >= 1.0,使用 yarn 的 [workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) 来管理 packages,tnpm 已配置 mode 为 yarn,因此可以使用 tnpm 安装依赖
88

9-
### 安装依赖
10-
在根目录安装依赖 yarn 会 warn,需要加 -W 参数,在 packages 安装依赖会自动提升,如果不需要提升,加 --focus
9+
### 配置 antcode 私有令牌
10+
https://code.alipay.com/profile/private_tokens 找到私有临牌,在根目录新建文件 .env
11+
输入 `PRIVATE_TOKEN=<令牌>`,.env 已自动被 git 忽略,也可直接通过环境变量配置 PRIVATE_TOKEN
1112

12-
### 安装 worker 扩展
13+
### 启动项目
1314
```bash
14-
npm run ext
15+
1. yarn
16+
2. npm run init
17+
3. npm start
1518
```
1619

20+
## 项目研发
21+
### 安装依赖
22+
在根目录安装依赖 yarn 会 warn,需要加 -W 参数,在 packages 安装依赖会自动提升,如果不需要提升,加 --focus
23+
1724
### 增加 package
25+
> 以下方式任选
1826
1. 在 packages 新建文件夹,然后运行 node scripts/bootstrap 会自动为所有无 package.json 的项目初始化
1927
2. 通过命令 npm run create <package> 新建项目
2028

21-
### 构建
29+
### 构建打包
2230
```sh
2331
# 构建所有 packages
2432
npm run build

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"scripts": {
1414
"preinstall": "node scripts/preinstall",
15+
"init": "npm run clean && npm run build && npm run ext",
1516
"ext": "node packages/spacex/bin/spacex ext",
1617
"build": "node scripts/build",
1718
"create": "node scripts/create",
@@ -57,6 +58,7 @@
5758
"@types/jest": "^26.0.16",
5859
"@types/node": "^14.14.6",
5960
"chalk": "^4.1.0",
61+
"dotenv": "^8.2.0",
6062
"execa": "^4.1.0",
6163
"fs-extra": "^9.0.1",
6264
"gulp": "^4.0.2",

packages/core/src/client/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
IClientAppOpts as IBasicClientAppOpts,
77
} from '@ali/ide-core-browser';
88
import { BasicModule } from '@ali/ide-core-common';
9-
import { IRuntimeConfig, RuntimeConfig } from '@alipay/spacex-shared';
109

1110
import { FCServiceCenter, ClientPort, initFCService } from '../connection';
1211
import { KaitianExtFsProvider, KtExtFsProviderContribution } from './extension';
@@ -17,6 +16,7 @@ import { injectDebugPreferences } from './debug';
1716
import { IServerApp } from '../common';
1817
import { IServerAppOpts, ServerApp } from '../server/core/app';
1918
import { isBackServicesInBrowser } from '../common/util';
19+
import { RuntimeConfig } from '../common/types';
2020

2121
export * from './extension';
2222

@@ -38,7 +38,7 @@ export class ClientModule extends BrowserModule {
3838

3939
export interface IClientAppOpts extends IBasicClientAppOpts {
4040
serverOptions?: IServerAppOpts;
41-
runtimeConfig?: IRuntimeConfig;
41+
runtimeConfig?: RuntimeConfig;
4242
}
4343

4444
export class ClientApp extends BasicClientApp {

packages/core/src/client/textmate-language-grammar/language-grammar.service.ts

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,58 @@ import * as paths from '@ali/ide-core-common/lib/path';
1010

1111
import { ILanguageGrammarRegistrationService } from './base';
1212

13-
// TODO: 先用默认语言
13+
// TODO: 罗列所有支持的语言,对比按需加载
1414
const defaultLanguages = [
15-
'html',
16-
'css',
15+
'yaml',
16+
'bat',
17+
'clojure',
18+
'coffeescript',
19+
'c',
20+
'cpp',
21+
'csharp',
22+
'dockerfile',
23+
'fsharp',
24+
'groovy',
25+
'handlebars',
26+
'hlsl',
27+
'ini',
28+
'properties',
29+
'log',
30+
'lua',
31+
'makefile',
32+
'objective-c',
33+
'objective-cpp',
34+
'perl',
35+
'perl6',
36+
'php',
37+
'powershell',
38+
'jade',
39+
'razor',
40+
'ruby',
41+
'rust',
42+
'shaderlab',
43+
'shellscript',
44+
'sql',
45+
'swift',
46+
'vb',
47+
'xml',
48+
'xsl',
49+
'javascriptreact',
1750
'javascript',
18-
'less',
19-
'markdown',
51+
'jsx-tags',
2052
'typescript',
21-
'scss',
22-
'pug',
53+
'typescriptreact',
54+
'jsonc',
55+
'css',
56+
'go',
57+
'html',
58+
'java',
2359
'json',
60+
'jsonc',
61+
'less',
62+
'markdown',
2463
'python',
25-
'handlebars',
26-
'yaml',
64+
'scss',
2765
];
2866

2967
@Injectable()

packages/core/src/common/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@ export interface IServerApp {
88
start(): Promise<void>;
99
rootFS: RootFS;
1010
}
11+
12+
export const RuntimeConfig = Symbol('RuntimeConfig');
13+
14+
export interface RuntimeConfig {
15+
// 场景
16+
scene?: string;
17+
// git 配置
18+
git?: {
19+
project: string;
20+
branch?: string;
21+
commit?: string;
22+
};
23+
}

packages/git/src/git-api.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class GitAPIService implements IGitAPIService {
6767
// 根据 commit 和 path 获取 tree
6868
async getTree(path: string = '') {
6969
await this.ready;
70-
return request<API.ResponseGetTree>(`/webapi/projects/${this.projectId}/repository/tree`, {
70+
return request<API.ResponseGetTree>(`/api/v3/projects/${this.projectId}/repository/tree`, {
7171
params: {
7272
ref_name: this.commit,
7373
path,

packages/git/src/git.contribution.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import {
77
makeWorkspaceDir,
88
GIT_ROOT,
99
IServerApp,
10+
RuntimeConfig,
1011
} from '@alipay/spacex-core';
11-
import { RuntimeConfig } from '@alipay/spacex-shared';
12-
import type { IRuntimeConfig } from '@alipay/spacex-shared';
1312
import configureFileSystem from './file-system/configure';
1413
import { IGitAPIService } from './types';
1514

@@ -19,7 +18,7 @@ export class GitContribution implements ServerAppContribution {
1918
gitApiService: IGitAPIService;
2019

2120
@Autowired(RuntimeConfig)
22-
runtimeConfig: IRuntimeConfig;
21+
runtimeConfig: RuntimeConfig;
2322

2423
@Autowired(INJECTOR_TOKEN)
2524
injector: Injector;
@@ -47,14 +46,3 @@ export class GitContribution implements ServerAppContribution {
4746
rootFS.mount(`/${GIT_ROOT}`, gitFileSystem);
4847
}
4948
}
50-
51-
// Declaration Merging
52-
declare module '@alipay/spacex-shared' {
53-
export interface IRuntimeConfig {
54-
git?: {
55-
project: string;
56-
commit?: string;
57-
branch?: string;
58-
};
59-
}
60-
}

packages/shared/src/types/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './extension';
2-
export * from './runtime';
32
export * from './util';

packages/shared/src/types/runtime.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/spacex/src/integration/startup/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ const layoutConfig = {
4242
const GIT_PROJECT = 'ide-s/TypeScript-Node-Starter';
4343

4444
loadMonaco({
45-
monacoCDNBase: 'https://g.alicdn.com/tb-ide/monaco-editor-core/0.17.0/',
46-
// monacoCDNBase: 'https://dev.g.alicdn.com/tb-ide/monaco-editor-core/0.17.99/',
45+
// monacoCDNBase: 'https://g.alicdn.com/tb-ide/monaco-editor-core/0.17.0/',
46+
monacoCDNBase: 'https://dev.g.alicdn.com/tb-ide/monaco-editor-core/0.17.99/',
4747
});
4848

4949
createApp({

0 commit comments

Comments
 (0)