Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve packacing #304

Merged
merged 4 commits into from
Jun 17, 2023
Merged
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
21 changes: 20 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,24 @@ jobs:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.publishToOpenVSX.outputs.vsixPath }}
packagePath: ''
yarn: true

- name: Compute pre-release versions
id: pre-release-versions
run: |
echo MARKETPLACE=`node -e "console.log(JSON.parse(require('child_process').execFileSync(process.execPath, ['node_modules/vsce/vsce', 'show', 'gregoire.dance', '--json'], { encoding: 'utf8' })).versions[0].version)"` >> "$GITHUB_OUTPUT"
echo LOCAL=`node -e "console.log(/[0-9]+.[0-9]+.[0-9]+/.exec(require('./package.json').scripts['package:pre'])[0])"` >> "$GITHUB_OUTPUT"

- name: Build pre-release .vsix
run: yarn run package:pre
if: ${{ steps.pre-release-versions.outputs.MARKETPLACE != steps.pre-release-versions.outputs.LOCAL }}

- name: Publish pre-release to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@8dd35ed51f326dfb0a3e9cfc6baeca81781229fc
if: ${{ steps.pre-release-versions.outputs.MARKETPLACE != steps.pre-release-versions.outputs.LOCAL }}
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: dance-${{ steps.pre-release-versions.outputs.LOCAL }}.vsix
yarn: true
preRelease: true
24 changes: 11 additions & 13 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
.github/**
.vscode/**
.vscode-test*/**
assets/dance.afdesign
src/**
test/**
.gitignore
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
**/*.lock
out/**/*.build.js
*
*/
assets/*
out/*

!LICENSE
!README.md
!package.json
!assets/*.{svg,png}
!out/extension.js
!out/web-extension.js
14 changes: 4 additions & 10 deletions meta.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from "assert";
import * as fs from "fs/promises";
import * as G from "glob";
import * as path from "path";
import assert from "assert";
import G from "glob";
import * as fs from "fs/promises";
import * as path from "path";

const verbose = process.argv.includes("--verbose");

Expand Down Expand Up @@ -290,12 +290,6 @@ function parseDocComments(code: string, modulePath: string) {
} as Builder.ParsedModule;
}

/**
* Keys available for binding as the system clipboard register.
* These are available in addition to the default `"` and `null`
*/
export const availableClipboardRegisters = [..."befgijklmnopqrtvwxyz", "*", "+"];

/**
* Mapping from character to corresponding VS Code keybinding.
*/
Expand Down
36 changes: 22 additions & 14 deletions package.build.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import type { Builder } from "./meta";
import { availableClipboardRegisters } from "./meta";
import { availableClipboardRegisters } from "./src/utils/constants";

// Shared values
// ============================================================================

const esbuildBase = "esbuild src/extension.ts --bundle --external:vscode --external:child_process --target=es2021 --format=cjs --minify --keep-names";
const esbuildNode = `${esbuildBase} --outfile=out/extension.js`;
const esbuildWeb = `${esbuildBase} --outfile=out/web-extension.js --define:process.platform=\\"web\\" --define:process.env={}`;

const commandType = {
type: "array",
items: {
Expand All @@ -18,8 +22,6 @@ const commandType = {
},
};



const builtinModesAreDeprecatedMessage =
"Built-in modes are deprecated. Use `#dance.modes#` instead.";

Expand Down Expand Up @@ -80,7 +82,7 @@ const selectionDecorationType = {
// ============================================================================

const version = "0.5.12",
preRelease = 2;
preRelease = 4;

export const pkg = (modules: Builder.ParsedModule[]) => ({

Expand All @@ -102,26 +104,32 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
url: "https://github.com/71/dance.git",
},

main: "./out/src/extension.js",
browser: "./out/web/extension.js",
main: "./out/extension.js",
browser: "./out/web-extension.js",

engines: {
vscode: "^1.63.0",
},

scripts: {
"check": "eslint . && depcruise -v .dependency-cruiser.js src",
"check": "tsc -p ./ && eslint . && depcruise -v .dependency-cruiser.js src",
"format": "eslint . --fix",

"generate": "ts-node ./meta.ts",
"generate:watch": "ts-node ./meta.ts --watch",

"compile": esbuildNode,
"compile:watch": `${esbuildNode} --watch --sourcemap`,
"compile-web": esbuildWeb,
"compile-web:watch": `${esbuildWeb} --watch --sourcemap`,
"compile-tests": "glob-exec {src,test}/**/*.ts -- \"esbuild {{files.join(' ')}} --target=es2021 --format=cjs --outdir=out --outbase=. --sourcemap\"",

"test": "yarn run compile --sourcemap && yarn run compile-tests && node ./out/test/run.js",

"vscode:prepublish": "yarn run generate && yarn run compile && yarn run compile-web",
"compile": "tsc -p ./",
"compile:watch": "tsc -watch -p ./",
"compile-web": "webpack --mode production --devtool hidden-source-map --config ./webpack.web.config.js",
"compile-web:watch": "webpack --watch --config ./webpack.web.config.js",
"test": "yarn run compile && node ./out/test/run.js",
"package": "vsce package --allow-star-activation",
"publish": "vsce publish --allow-star-activation",
"package:pre": `vsce package --allow-star-activation --pre-release --no-git-tag-version --no-update-package-json ${version.replace(/\d+$/, "$&" + preRelease.toString().padStart(3, "0"))}`,
"publish:pre": `vsce publish --allow-star-activation --pre-release --no-git-tag-version --no-update-package-json ${version.replace(/\d+$/, "$&" + preRelease.toString().padStart(3, "0"))}`,
},

Expand All @@ -135,8 +143,10 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
"@vscode/test-electron": "^2.1.3",
"chokidar": "^3.5.3",
"dependency-cruiser": "^11.7.0",
"esbuild": "^0.18.4",
"eslint": "^8.15.0",
"glob": "^8.0.3",
"glob-exec": "^0.1.1",
"mocha": "^10.0.0",
"source-map-support": "^0.5.21",
"ts-loader": "^9.3.1",
Expand All @@ -145,8 +155,6 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
"unexpected": "^13.0.0",
"vsce": "^2.7.0",
"web-tree-sitter": "^0.20.8",
"webpack": "^5.72.1",
"webpack-cli": "^4.9.2",
"yaml": "^2.1.1",
},

Expand Down
24 changes: 13 additions & 11 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/api/edit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function insert(
);
}

export declare namespace insert {
export /* enum */ namespace insert {
/**
* Insertion flags for {@link insert}.
*/
Expand Down Expand Up @@ -218,7 +218,9 @@ export declare namespace insert {
*/
Extend = 0b10_00_1,
}
}

export declare namespace insert {
/**
* The result of a callback passed to {@link insert} or
* {@link insertByIndex}.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class CommandDescriptor<Flags extends CommandDescriptor.Flags = CommandDe
}
}

export declare namespace CommandDescriptor {
export /* enum */ namespace CommandDescriptor {
/**
* Flags describing the behavior of some commands.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/commands/load-all.build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import assert from "assert";
import { Builder, unindent } from "../../meta";

export async function build(builder: Builder) {
Expand Down Expand Up @@ -207,7 +207,7 @@ function determineFunctionExpression(f: Builder.ParsedFunction) {
`_.extension.treeSitterOrThrow().withDocumentTree(_.document, (documentTree) => ${call})`;
}

return `(${inputParameters.join(", ")}) => _.runAsync((_) => ${call})`;
return `(${inputParameters.join(", ")}) => _.runAsync(async (_) => await ${call})`;
}

function determineFunctionFlags(f: Builder.ParsedFunction) {
Expand Down
Loading