Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Fix Arduino CLI: Upload command #1708

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Use the official Node.js 16 base image
FROM node:16-alpine3.15

# needs to be alpine 3.15 to get python 2.7 and python 3.10 — 3.11 does not work with node-gyp
RUN apk add curl python2 python3 make build-base eudev-dev

RUN mkdir -p /app/assets && chmod 777 /app && chmod 777 /app/assets

WORKDIR /app

# Copy the application code to the working directory
COPY ./src /app/src
COPY ./package*.json /app/
COPY ./build /app/build

# Install dependencies
RUN npm install

COPY ./images /app/images
COPY ./misc /app/misc
COPY ./snippets /app/snippets
COPY ./syntaxes /app/syntaxes
COPY ./typings /app/typings
COPY gulpfile.js /app/
COPY tsconfig.json /app/
COPY webpack.config.js /app/
COPY cgmanifest.json /app/
COPY .vscodeignore /app/
COPY LICENSE.txt /app/

RUN mkdir -p /app/out

RUN npm run package



14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ You can find the full list of issues on the [Issue Tracker](https://github.com/M

Installation prerequisites:

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/) (>= 12.x)
- [Npm](https://www.npmjs.com/) (>= 6.x)
* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) (>= 16.x)
* [Npm](https://www.npmjs.com/) (>= 8.x)

To *run and develop*, do the following:
- `git clone https://github.com/microsoft/vscode-arduino`
Expand All @@ -228,6 +228,14 @@ To *run and develop*, do the following:
- Open in Visual Studio Code (`code .`)
- Press <kbd>F5</kbd> to debug.


In order to create the .vsix file:

* Run `npm run package` (you may want to comment out the platforms you don't want to build in ./build/package.js for during local testing)

If you'd like to test a build without setting up your environment, just install [Docker](https://www.docker.com)
and run `npm run dockerbuild`, which will output the .vsix files in the `./out` directory.

To *test*, press <kbd>F5</kbd> in VS Code with the "Launch Tests" debug configuration.

## Code of Conduct
Expand Down
2 changes: 2 additions & 0 deletions build/downloadAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ for (const asset in config.assets) {
const directory = resolve(__dirname, "..", "assets", "platform", platform);
const destination = resolve(directory, asset);

mkdirSync(directory, { recursive: true });

// Download the asset.
run([
"curl",
Expand Down
4 changes: 3 additions & 1 deletion build/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ const platforms = [
"darwin-arm64",
];

mkdirSync(resolve(__dirname, "..", "out", "vsix"), { recursive: true });

// We include different files for each platform, so we need to build a custom
// .vscodeignore file based on common file and platform-specific path.
const ignoreFile = readFileSync(resolve(__dirname, "..", ".vscodeignore"), "utf8");
const customIgnoreFilePath = resolve(__dirname, "..", "out", ".vscodeignore");

execSync('npm run build', { cwd: resolve(__dirname, ".."), stdio: "inherit" });
mkdirSync(resolve(__dirname, "..", "out", "vsix"), { recursive: true });
for (const platform of platforms) {
writeFileSync(
customIgnoreFilePath,
ignoreFile + `!assets/platform/${platform}/**`
);
mkdirSync(resolve(__dirname, "..", "out", "vsix"), { recursive: true });
const command = `vsce package --target ${platform} --out out/vsix/vscode-arduino-${platform}.vsix ${flags}`;
execSync(command, {
cwd: resolve(__dirname, ".."),
Expand Down
3,701 changes: 2,882 additions & 819 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@
]
},
"scripts": {
"dockerbuild": "docker build -t vscode-arduino-builder . && docker cp $(docker create vscode-arduino-builder):/app/out/vsix/. ./out",
"build": "gulp build --mode=production",
"package": "node build/package.js",
"postinstall": "node ./build/downloadAssets.js && cd ./src/views && npm install",
"test": "gulp test"
},
Expand All @@ -344,6 +346,7 @@
"@types/winreg": "^1.2.30",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@vscode/vsce": "^2.23.0",
"acorn": "^7.4.0",
"ajv": "^6.12.3",
"babel-loader": "^8.2.2",
Expand All @@ -365,7 +368,7 @@
"gulp-typescript": "^5.0.1",
"minimist": "^1.2.6",
"mocha": "^6.2.3",
"node-gyp": "^6.1.0",
"node-gyp": "^10.0.1",
"plugin-error": "^1.0.1",
"tslint": "^5.20.1",
"typemoq": "^1.6.0",
Expand Down Expand Up @@ -393,11 +396,10 @@
},
"overrides": {
"async": "~3.2.3",
"node-sass": "^7.0.0",
"es5-ext": "0.10.53",
"string_decoder": "https://github.com/microsoft/vscode-arduino/releases/download/v0.4.12-rc2/string_decoder-10.0.0.tgz"
},
"vsce": {
"ignoreFile": "out/.vscodeignore"
}
}
}
4 changes: 3 additions & 1 deletion src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export class ArduinoApp {
return false;
}

args.push("upload");
args.push("compile", "--upload");

if (dc.port) {
args.push("--port", dc.port);
Expand Down Expand Up @@ -842,6 +842,8 @@ export class ArduinoApp {
arduinoChannel.channel.append(line);
});

arduinoChannel.info(`Running: ${this._settings.commandPath} ${args.join(" ")}`);

const run = (...args: any[]) =>
this.useArduinoCli() ?
this.spawnCli(...(args.slice(1))) :
Expand Down
Loading