Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
suyanlong committed Aug 15, 2022
1 parent 25fb82a commit 54c9a24
Show file tree
Hide file tree
Showing 26 changed files with 2,359 additions and 1,909 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*.eslintrc.js*/
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: weekly
day: sunday
time: "01:00"
time: '01:00'
labels:
- scope:dependency
target-branch: "main"
target-branch: 'main'
14 changes: 6 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: BUILD

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on: [push,pull_request]
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -13,13 +13,13 @@ jobs:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
- 'ubuntu-latest'
node:
# Run tests on minimal version we support
- "17.6.0"
- '17.6.0'
NPM_CLIENT:
# - "yarn"
- "npm"
- 'npm'
# - "pnpm"
env:
INSTALL_PACKAGE: true
Expand All @@ -34,7 +34,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: "yarn"
cache: 'yarn'

# - name: Install Dependencies
# run: yarn install --frozen-lockfile
Expand All @@ -49,11 +49,9 @@ jobs:
- name: build
run: make build

- name : Upload artifact bin
- name: Upload artifact bin
uses: actions/upload-artifact@v3
with:
name: ralph-vscode
path: |
ralph-vscode-*.vsix
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
build
public
dist
snippets/snippets.code-snippets
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"singleQuote": true,
"trailingComma": "none"
"singleQuote": true,
"trailingComma": "none"
}
22 changes: 10 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
}
]
}
55 changes: 26 additions & 29 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": ["$tsc"]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": ["$tsc-watch"]
}
]
"problemMatcher": ["$tsc"]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": ["$tsc-watch"]
}
]
}



2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

- Initial release
- Initial release
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ publish:
clean:
rm -rf ./ralph-vscode-*.vsix


fmt:
yarn run fmt
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Ralph Language for VS Code

## Overview

Ralph is the language used in alephium to create smart contracts, ralph-vscode is vscode extension.

## Features

- Highlighting ✅
- Snippet ✅
- Formatting ✅(simple format)
Expand All @@ -12,9 +14,13 @@ Ralph is the language used in alephium to create smart contracts, ralph-vscode i
- Linting / Error Checking ⏳
- Debugging ⏳
- Deploy ⏳

## Extension Settings
* seting themes

- seting themes

## FAQ

https://github.com/suyanlong/ralph-vscode/issues

## Contribution
Expand All @@ -23,7 +29,8 @@ See [CONTRIBUTING.md](https://github.com/suyanlong/ralph-vscode/blob/main/CONTRI

## License

[GNU3]([LICENSE](https://github.com/suyanlong/ralph-vscode/blob/main/LICENSE))
[GNU3](<[LICENSE](https://github.com/suyanlong/ralph-vscode/blob/main/LICENSE)>)

## References

https://github.com/alephium
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@
]
},
"scripts": {
"vscode:prepublish": "npm run package",
"vscode:prepublish": "yarn run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"test-compile": "tsc -p ./",
"test-watch": "tsc -watch -p ./",
"pretest": "npm run test-compile && npm run lint",
"pretest": "yarn run test-compile && yarn run lint",
"lint": "eslint src --ext ts",
"fmt": "yarn prettier --write .",
"test": "node ./out/test/runTest.js"
},
"dependencies": {
Expand All @@ -151,6 +152,7 @@
"@types/vscode": "^1.69.0",
"eslint": "^8.20.0",
"prettier": "^2.7.1",
"prettier-eslint": "^15.0.1",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"vsce": "^2.10.0",
Expand Down
20 changes: 10 additions & 10 deletions src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CommonOptions } from "child_process";
'use strict';

import { CommonOptions } from 'child_process';

interface Command {
command: string,
title: string,
command: string;
title: string;
}


const commands: Command[] = [
{
"command": "format-code.format.ralph",
"title": "Format Ralph"
}
]
{
command: 'format-code.format.ralph',
title: 'Format Ralph'
}
];

export default commands;

37 changes: 20 additions & 17 deletions src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
import * as vscode from 'vscode';
import { Downloader } from './downloader';
import * as logger from './logger';
Expand All @@ -8,38 +9,40 @@ export class Complier {
log: logger.Logger;
constructor() {
this.log = new logger.Logger('Complier');
this.cmd = vscode.workspace.getConfiguration().get('ralph.compiler.command');
this.cmd = vscode.workspace
.getConfiguration()
.get('ralph.compiler.command');
}

complier(editor: vscode.TextEditor){
complier(editor: vscode.TextEditor) {
let fullFileName = editor.document.fileName;
if (!fullFileName.endsWith('.ral')) {
return;
return;
}
if (editor.document.isDirty) {
editor.document.save();
editor.document.save();
}

if (!this.cmd && vscode.workspace.rootPath){
const d = new Downloader();
d.showQuickPick();
const jar = path.join(vscode.workspace.rootPath, d.config.target);
this.cmd = `java -jar ${jar} -f ${fullFileName}`
if (!this.cmd && vscode.workspace.rootPath) {
const d = new Downloader();
d.showQuickPick();
const jar = path.join(vscode.workspace.rootPath, d.config.target);
this.cmd = `java -jar ${jar} -f ${fullFileName}`;
}

this.log.info(`Complier.cmd: ${this.cmd}`);
let exec = require('child_process').exec;

vscode.window.setStatusBarMessage(`Execute command: ${this.cmd}`);

exec(this.cmd,(_error: any, stdout: string, stderr: string) =>{
if (stderr) {
this.log.info(stderr);
console.log(stderr);
} else if (stdout) {
this.log.info(stdout);
console.log(stderr);
}
exec(this.cmd, (_error: any, stdout: string, stderr: string) => {
if (stderr) {
this.log.info(stderr);
console.log(stderr);
} else if (stdout) {
this.log.info(stdout);
console.log(stderr);
}
});
}
}
16 changes: 8 additions & 8 deletions src/downloader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"use strict";
'use strict';

import * as vscode from 'vscode';
import * as path from 'path';
import {createWriteStream} from 'node:fs';
import { createWriteStream } from 'node:fs';
import fetch from 'node-fetch';
import * as logger from './logger';
import { existsSync } from 'fs';


type Config = {
name: string;
url: string;
Expand All @@ -24,7 +23,8 @@ export class Downloader {

private loadConfig() {
const config = vscode.workspace
.getConfiguration().get('ralph.downloader.config') as Config;
.getConfiguration()
.get('ralph.downloader.config') as Config;
this.config = config;
}

Expand All @@ -36,12 +36,12 @@ export class Downloader {
async download() {
const dir = vscode.workspace.rootPath;
if (dir) {
const targetPath = path.join(dir, this.config.target);
if (!existsSync(targetPath) ){
this.log.info("download :" + this.config.url)
const targetPath = path.join(dir, this.config.target);
if (!existsSync(targetPath)) {
this.log.info('download :' + this.config.url);
const targetStream = createWriteStream(targetPath);
const response = await fetch(this.config.url);
response.body?.pipe(targetStream)
response.body?.pipe(targetStream);
}
}
}
Expand Down
Loading

0 comments on commit 54c9a24

Please sign in to comment.