Skip to content

Commit 609f8e9

Browse files
authored
Merge pull request microsoft#3966 from TheLarkInn/issue/3965
Setup default dev container for rushstack with Rust and Node (v16) toolchains.
2 parents 770a3ca + 2d190b6 commit 609f8e9

File tree

4 files changed

+150
-47
lines changed

4 files changed

+150
-47
lines changed

.devcontainer/devcontainer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
3+
{
4+
"name": "Node.js & TypeScript",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-16",
7+
"features": {
8+
"ghcr.io/devcontainers/features/github-cli:1": {},
9+
"ghcr.io/devcontainers/features/rust:1": {},
10+
"devwasm.azurecr.io/dev-wasm/dev-wasm-feature/rust-wasi:0": {}
11+
},
12+
13+
// Features to add to the dev container. More info: https://containers.dev/features.
14+
// "features": {},
15+
16+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
17+
// "forwardPorts": [],
18+
19+
// Use 'postCreateCommand' to run commands after the container is created.
20+
"onCreateCommand": "/bin/bash ./.devcontainer/setup.sh",
21+
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"rust-lang.rust-analyzer",
27+
"bungcip.better-toml",
28+
"ms-vscode.cpptools",
29+
"GitHub.copilot",
30+
"dustypomerleau.rust-syntax",
31+
"serayuzgur.crates",
32+
"esbenp.prettier-vscode",
33+
"dbaeumer.vscode-eslint",
34+
"mutantdino.resourcemonitor",
35+
"DavidAnson.vscode-markdownlint"
36+
]
37+
}
38+
}
39+
40+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
41+
// "remoteUser": "root"
42+
}

.devcontainer/setGitConfigUserName.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const child_process = require('child_process');
2+
const https = require('https');
3+
4+
const buildRequestOptionsForGetUser = (username) => {
5+
if (!username) {
6+
throw new Error('Username is required');
7+
}
8+
9+
const requestOptions = {
10+
host: 'api.github.com',
11+
path: `/users/${username}`,
12+
headers: {
13+
'User-Agent': '@microsoft/rushstack Codespaces Setup Script'
14+
}
15+
};
16+
17+
return requestOptions;
18+
};
19+
20+
const main = (username) => {
21+
const requestOptions = buildRequestOptionsForGetUser(username);
22+
const request = https.request(requestOptions, (response) => {
23+
let data = '';
24+
response.on('data', (chunk) => {
25+
data += chunk;
26+
});
27+
28+
response.on('end', () => {
29+
const user = JSON.parse(data);
30+
const { name } = user;
31+
32+
// Execute git config command
33+
console.log(`git config --local user.email "${username}@users.noreply.github.com"`);
34+
child_process.execSync(`git config --local user.email "${username}@users.noreply.github.com"`);
35+
36+
console.log(`git config --local user.name "${name}"`);
37+
child_process.execSync(`git config --local user.name "${name}"`);
38+
});
39+
});
40+
41+
request.end();
42+
};
43+
44+
main(process.argv[2]);

.devcontainer/setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
echo "🚀 Setting up Rushstack codespace..."
4+
5+
echo "🔑 Setting up GitHub user config..."
6+
node ./.devcontainer/setGitConfigUserName.js ${GITHUB_USER}
7+
8+
# Install Rush and Heft Dependencies
9+
echo "📦 Installing Rush, Heft, & Prettier dependencies..."
10+
npm install -g @microsoft/rush @rushstack/heft prettier
11+
12+
# Install Rush Dependencies
13+
echo "📦 Installing monorepo dependencies..."
14+
rush install
15+
16+
echo "🚀 Codespace setup complete! "
17+
echo "🙏 Thank you for contributing to Rushstack! "

build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml

Lines changed: 47 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)