Skip to content

Commit ac20a36

Browse files
authored
Fix publishing with Lerna (#93)
The previous refactor broke the publish workflows. This is an attempt to fix them. The use of `lerna publish` (which uses `lerna version` behind the scenes) means: - All packages that have changes will have their version bumped and published - All packages that have their versions bumped will be bumped to the same version - All packages will be published as npm packages, even if they don't really need to be (e.g. `packages/extension`, which is really only intended for publishing to VS Code marketplace). Because the versions of the packages should/will be equal, I've bumped them all up to 0.54.0, which is a minor bump over the highest existing version (extension at 53). It's very difficult to test, since we have to push to github.com/anz-bank/vscode-sysl first.
1 parent d685378 commit ac20a36

27 files changed

+144
-381
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"plugins": ["@typescript-eslint"],
1717
"ignorePatterns": [
18-
"out/",
18+
"dist/",
1919
"node_modules/",
2020
"extension/lsp/utils.ts",
2121
"extension/lsp/go*.ts",

.github/workflows/npm-publish-model.yaml

-33
This file was deleted.

.github/workflows/npm-publish-plugin.yaml

-33
This file was deleted.

.github/workflows/npm-publish-renderer.yaml

-33
This file was deleted.

.github/workflows/publish-extension.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ jobs:
1111
deploy:
1212
if: ${{ github.repository_owner == 'anz-bank' }}
1313
runs-on: ubuntu-latest
14-
defaults:
15-
run:
16-
working-directory: packages/extension
1714
steps:
1815
- uses: actions/checkout@v2
1916
- run: yarn install --frozen-lockfile
2017
- run: yarn vsce publish -p ${{ secrets.VSCE_TOKEN }}
18+
working-directory: packages/extension
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish packages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- ".github/**"
9+
- "docs/**"
10+
- "packages/**"
11+
12+
jobs:
13+
publish-to-npm:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: 16
21+
22+
- name: Install packages deps
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Build packages
26+
run: yarn lerna run build
27+
28+
- name: Publish packages
29+
if: ${{ github.repository_owner == 'anz-bank' }}
30+
run: yarn lerna publish --contents=dist
31+
env:
32+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
.vscode-test
44

55
# Build
6-
out
6+
dist/
77
node_modules
88
*.vsix
9-
*error.log
9+
*.log
1010
/main.js*
1111
/sysl
1212
*.tsbuildinfo

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ node_modules
44
/packages/extension/src/test/screenshots
55

66
# Production
7-
out/
87
dist/
98
/packages/renderer/build
109
main.js*

.vscode/launch.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"--extensionDevelopmentPath=${workspaceFolder}/packages/extension"
1313
],
1414
"outFiles": [
15-
"${workspaceFolder}/packages/extension/out/**/*.js",
15+
"${workspaceFolder}/packages/extension/dist/**/*.js",
1616
"${workspaceFolder}/packages/renderer/build/**",
1717
],
1818
},
@@ -25,11 +25,11 @@
2525
"${workspaceFolder}/packages/extension/test/fixtures/",
2626
"--disable-extensions",
2727
"--extensionDevelopmentPath=${workspaceFolder}/packages/extension",
28-
"--extensionTestsPath=${workspaceFolder}/packages/extension/out/test/ui/index",
28+
"--extensionTestsPath=${workspaceFolder}/packages/extension/dist/test/ui/index",
2929
"--user-data-dir=${workspaceFolder}/.vscode-test/user-data"
3030
],
3131
"outFiles": [
32-
"${workspaceFolder}/packages/extension/out/test/**/*.js",
32+
"${workspaceFolder}/packages/extension/dist/test/**/*.js",
3333
"${workspaceFolder}/packages/renderer/build/**"
3434
]
3535
},

lerna.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2-
"version": "0.1.0",
2+
"version": "0.54.0",
33
"useWorkspaces": true,
44
"npmClient": "yarn",
5-
"packages": ["extension", "model", "plugin", "renderer"],
5+
"packages": [
6+
"extension",
7+
"model",
8+
"plugin",
9+
"renderer"
10+
],
611
"useNx": true
712
}

packages/extension/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
preset: "ts-jest",
44
testEnvironment: "node",
55
setupFilesAfterEnv: ["jest-extended/all"],
6-
modulePathIgnorePatterns: ["dist", "out", "test/ui"],
6+
modulePathIgnorePatterns: ["dist", "test/ui"],
77
globalSetup: "../../scripts/setup.ts",
88
moduleNameMapper: {
99
// Help Jest resolve Sysl's subpath package exports.

packages/extension/package.json

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Write Sysl specs easily with instant visual feedback.",
55
"author": "ANZ Bank",
66
"publisher": "anz-bank",
7-
"version": "0.53.0",
7+
"version": "0.54.0",
88
"license": "Apache-2.0",
99
"repository": {
1010
"type": "git",
@@ -28,7 +28,7 @@
2828
"onCustomEditor:sysld.multiView",
2929
"workspaceContains:**/*.sysl"
3030
],
31-
"main": "./out/main.js",
31+
"main": "./dist/main.js",
3232
"contributes": {
3333
"commands": [
3434
{
@@ -153,16 +153,16 @@
153153
},
154154
"scripts": {
155155
"vscode:prepublish": "yarn build && yarn build:renderer",
156-
"esbuild-base": "esbuild ./src/main.ts --bundle --outfile=out/main.js --external:vscode --external:electron --format=cjs --platform=node",
156+
"esbuild-base": "esbuild ./src/main.ts --bundle --outfile=dist/main.js --external:vscode --external:electron --format=cjs --platform=node",
157157
"esbuild": "npm run esbuild-base -- --sourcemap",
158158
"esbuild-prod": "npm run esbuild-base -- --minify",
159159
"prebuild": "yarn install --network-timeout 300000",
160160
"build": "yarn compile && yarn schema && yarn plugins && yarn build:renderer && yarn esbuild-prod",
161-
"build:renderer": "yarn --cwd ../renderer build --network-timeout 300000 && cp -R ../renderer/build/. out/renderer",
161+
"build:renderer": "yarn --cwd ../renderer build --network-timeout 300000 && cp -R ../renderer/build/. dist/renderer",
162162
"compile": "tsc",
163-
"esbuild-erd": "esbuild ./src/plugins/erd/index.ts --bundle --outfile=out/plugins/erd/index.js --external:vscode --external:electron --format=cjs --platform=node",
164-
"esbuild-integration": "esbuild ./src/plugins/integration/index.ts --bundle --outfile=out/plugins/integration/index.js --external:vscode --external:electron --format=cjs --platform=node",
165-
"esbuild-sysld": "esbuild ./src/plugins/sysld/index.ts --bundle --outfile=out/plugins/sysld/index.js --external:vscode --external:electron --format=cjs --platform=node",
163+
"esbuild-erd": "esbuild ./src/plugins/erd/index.ts --bundle --outfile=dist/plugins/erd/index.js --external:vscode --external:electron --format=cjs --platform=node",
164+
"esbuild-integration": "esbuild ./src/plugins/integration/index.ts --bundle --outfile=dist/plugins/integration/index.js --external:vscode --external:electron --format=cjs --platform=node",
165+
"esbuild-sysld": "esbuild ./src/plugins/sysld/index.ts --bundle --outfile=dist/plugins/sysld/index.js --external:vscode --external:electron --format=cjs --platform=node",
166166
"plugins": "yarn esbuild-erd && yarn esbuild-integration && yarn esbuild-sysld",
167167
"schema": "yarn schema-ts && yarn schema-go",
168168
"schema-ts": "json2ts ./src/protocol/plugin.schema.json --output ./src/protocol/plugin.d.ts && yarn prettier --write ./src/protocol/plugin.d.ts",
@@ -172,14 +172,16 @@
172172
"tidy": "prettier --write .",
173173
"lint": "eslint . --ext .ts,.tsx",
174174
"test": "yarn test-unit",
175-
"test-ui": "node out/test/runTest",
175+
"test-ui": "node dist/test/runTest",
176176
"test-unit": "yarn jest",
177-
"test-watch": "nodemon --watch './**' --ext 'ts,json,sysl' --exec 'ts-node ./src/test/runUnitTest'"
177+
"test-watch": "nodemon --watch './**' --ext 'ts,json,sysl' --exec 'ts-node ./src/test/runUnitTest'",
178+
"pack": "pack",
179+
"prepack": "cp package.json ../../README.md ../../LICENSE dist/ && sed -i'' -e 's|dist/index|index|g' dist/package.json"
178180
},
179181
"dependencies": {
180182
"@anz-bank/sysl": "^0",
181-
"@anz-bank/vscode-sysl-model": "*",
182-
"@anz-bank/vscode-sysl-plugin": "*",
183+
"@anz-bank/vscode-sysl-model": "^0.54.0",
184+
"@anz-bank/vscode-sysl-plugin": "^0.54.0",
183185
"lodash": "^4",
184186
"memoizee": "^0",
185187
"semver": "^7",

packages/extension/src/actions/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Actions {
5252
if (doc && doc.uri.fsPath.endsWith(syslExt)) {
5353
model = await compileDoc(doc, this.sysl!).catch(() => undefined);
5454
}
55-
return commands.executeCommand(action.id, { uri: doc?.uri.toString(), model });
55+
await commands.executeCommand(action.id, { uri: doc?.uri.toString(), model });
5656
});
5757
}
5858

@@ -67,9 +67,9 @@ class Actions {
6767
actions.map((a) => [`action:${a.id}`, a]),
6868
([cmd]) => existing.includes(cmd)
6969
) as [[string, Action][], [string, Action][]];
70-
if (conflict)
70+
if (conflict.length) {
7171
output.appendLine(`addActions: ignoring existing commands: [${conflict.map(([c]) => c)}]`);
72-
72+
}
7373
const disposables = fresh.map(([cmd, a]) => {
7474
output.appendLine(`adding action ${a.id} (command ${cmd})`);
7575
this.actions[a.id] = a;

packages/extension/src/plugins/erd/diagram.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import {
88
} from "@anz-bank/sysl/model";
99
import { DiagramModel, DiagramObjectData } from "../../views/diagram/model";
1010

11-
const notIgnored = (el: Element) => !el.tags.some((t) => t.value === "ignore");
11+
const notIgnored = (el: Element) => !el.tags.some((t) => t.name === "ignore");
1212

13-
export async function buildModel(model: Model): Promise<DiagramModel> {
13+
export async function buildModel(model: Model, docUri?: string): Promise<DiagramModel> {
14+
if (docUri) {
15+
model = model.filterByFile(docUri);
16+
}
1417
const nodes: DiagramObjectData[] = [];
1518
const edges: DiagramObjectData[] = [];
1619
const groups: boolean = Object.keys(model.apps).length > 1;
@@ -39,7 +42,13 @@ export async function buildModel(model: Model): Promise<DiagramModel> {
3942
}
4043
});
4144

42-
return { nodes, edges, templates: { diagramLayout: "LayeredDigraphLayout" } };
45+
return {
46+
nodes,
47+
edges,
48+
templates: {
49+
diagramLayout: "LayeredDigraphLayout",
50+
},
51+
};
4352
}
4453

4554
function getChildReferences(type: Type): ElementRef[] {

packages/extension/src/plugins/erd/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ async function buildModelForKey(key: ViewKey): Promise<DiagramModel> {
6464
throw new Error("must have compiled model to render ERD diagram");
6565
}
6666

67-
return { meta: { ...partialMeta, key }, ...(await buildModel(model)) };
67+
return { meta: { ...partialMeta, key }, ...(await buildModel(model, key.docUri)) };
6868
}

packages/extension/src/plugins/examples/spp-typescript/example_client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Events } from "../../types";
66
const rootPath = path.join(__dirname, "..", "..", "..", "..");
77
const pluginPath = path.join(
88
rootPath,
9-
"out",
9+
"dist",
1010
"plugins",
1111
"examples",
1212
"spp-typescript",

0 commit comments

Comments
 (0)