Skip to content

Commit 488424e

Browse files
jonathanyeungkevinslin
authored andcommitted
chore: updated enterprise build (#3804)
* support enterprise build * add enterprise build * update name * add license * update readme * add license check * update build step * track extension version * spike: rebase fixes * spike: adding create enterprise image workflow * spike: build fix * spike: fix type in buildPatch Co-authored-by: Kevin <[email protected]>
1 parent d47160d commit 488424e

File tree

10 files changed

+203
-24
lines changed

10 files changed

+203
-24
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Generates an enterprise image. This image differs by requiring the user to
2+
# enter an enterprise license on startup.
3+
name: Create Enterprise Image
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
environment: plugin-development
11+
strategy:
12+
fail-fast: true
13+
14+
timeout-minutes: 30
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Gather environment data
20+
run: |
21+
node --version
22+
npm --version
23+
yarn --version
24+
25+
- name: Configure Git user
26+
run: |
27+
git config --global user.name github-actions
28+
git config --global user.email [email protected]
29+
30+
- name: Checkout source
31+
uses: actions/checkout@v3
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 16.x
37+
38+
- name: Yarn Setup
39+
run: yarn setup
40+
41+
- name: Set Up Yarn Local Registry
42+
run: yarn config set registry http://localhost:4873
43+
44+
- name: Set Up NPM Local Registry
45+
run: npm set registry http://localhost:4873/
46+
47+
- name: Set Environment Variables
48+
run: |
49+
echo "DENDRON_RELEASE_VERSION=`cat ./packages/plugin-core/package.json | jq ".version" -r | awk -F. -v OFS=. 'NF>1{$(NF-1)=sprintf("%0*d", length($(NF-1)), ($(NF-1)+1)); $NF=0; print}'`" >> $GITHUB_ENV
50+
echo "GOOGLE_OAUTH_CLIENT_SECRET=${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}" >> $GITHUB_ENV
51+
echo "GOOGLE_OAUTH_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}" >> $GITHUB_ENV
52+
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> $GITHUB_ENV
53+
echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
54+
55+
- name: Build the VSIX
56+
run: |
57+
yarn build:patch:local:ci:enterprise
58+
59+
- name: Check for VSIX
60+
run: |
61+
vsixCount=`ls ./packages/plugin-core/*.vsix | wc -l | awk '{print $1}'`
62+
if [ $vsixCount = 1 ]; then
63+
vsix=$(ls ./packages/plugin-core/*.vsix | tail -1)
64+
echo "found a single .vsix file named $vsix"
65+
echo "VSIX_FILE_NAME=$(basename $vsix)" >> $GITHUB_ENV
66+
echo "VSIX_RELATIVE_PATH=$vsix" >> $GITHUB_ENV
67+
else
68+
echo "error: expected 1 .vsix file, found $vsixCount"
69+
exit 1
70+
fi
71+
72+
- name: Upload VSIX Artifact
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: vsix
76+
path: ${{ env.VSIX_RELATIVE_PATH }}
77+
if-no-files-found: error

bootstrap/scripts/buildNightly.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ echo "$FOO_PID"
88
sleep 10
99

1010
SCRIPT_BUILD_ENV=${BUILD_ENV:-local}
11-
SCRIPT_EXT_TYPE=${EXT_TYPE:-dendron}
1211
echo "building... upgrade: patch, endpoint: local build environment: $SCRIPT_BUILD_ENV"
1312

1413
DENDRON_CLI=./packages/dendron-cli/lib/bin/dendron-cli.js

bootstrap/scripts/buildPatch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ EXT_TYPE=dendron
3131
if [ $SCRIPT_EXT_TYPE = "nightly" ]; then
3232
EXT_TYPE=nightly
3333
fi
34+
if [ $SCRIPT_EXT_TYPE = "enterprise" ]; then
35+
EXT_TYPE=enterprise
36+
fi
3437

3538
if [ -z $FAST ]; then
3639
LOG_LEVEL=info $DENDRON_CLI dev build --upgradeType $UPGRADE_TYPE --publishEndpoint $PUBLISH_ENDPOINT --extensionType $EXT_TYPE

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"build:patch:local": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=local USE_IN_MEMORY_REGISTRY=1 ./bootstrap/scripts/buildPatch.sh",
6565
"build:patch:local:ci": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=local BUILD_ENV=ci USE_IN_MEMORY_REGISTRY=1 ./bootstrap/scripts/buildPatch.sh",
6666
"build:patch:local:ci:nightly": "./bootstrap/scripts/buildNightly.sh",
67+
"build:patch:local:ci:enterprise": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=local BUILD_ENV=ci USE_IN_MEMORY_REGISTRY=1 EXT_TYPE=enterprise ./bootstrap/scripts/buildPatch.sh",
6768
"build:patch:remote": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=remote ./bootstrap/scripts/buildPatch.sh",
6869
"build:patch:remote:ci": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=remote BUILD_ENV=ci ./bootstrap/scripts/buildPatch.sh",
6970
"build:minor:local": "cross-env UPGRADE_TYPE=minor PUBLISH_ENDPOINT=local ./bootstrap/scripts/buildPatch.sh",

packages/dendron-cli/src/commands/devCLICommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export class DevCLICommand extends CLICommand<CommandOpts, CommandOutput> {
455455
this.print("sync assets...");
456456
await this.syncAssets(opts);
457457

458-
this.print("prep repo...");
458+
this.print(`prep repo... extensionType: ${opts.extensionType}`);
459459
await BuildUtils.prepPluginPkg(opts.extensionType);
460460

461461
if (!shouldPublishLocal) {

packages/dendron-cli/src/utils/build.ts

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* eslint-disable no-console */
2-
import { DendronError, error2PlainObject } from "@dendronhq/common-all";
2+
import {
3+
assertUnreachable,
4+
DendronError,
5+
error2PlainObject,
6+
} from "@dendronhq/common-all";
37
import { createLogger, findUpTo } from "@dendronhq/common-server";
48
import execa from "execa";
59
import fs from "fs-extra";
@@ -16,6 +20,7 @@ type PkgJson = {
1620
repository: PkgRepository;
1721
devDependencies: { [key: string]: string };
1822
icon: string;
23+
license: string;
1924
};
2025

2126
type PkgRepository = {
@@ -39,6 +44,7 @@ export enum PublishEndpoint {
3944
export enum ExtensionType {
4045
DENDRON = "dendron",
4146
NIGHTLY = "nightly",
47+
ENTERPRISE = "enterprise",
4248
}
4349

4450
const LOCAL_NPM_ENDPOINT = "http://localhost:4873";
@@ -201,18 +207,39 @@ export class BuildUtils {
201207
let version;
202208
let description;
203209
let icon;
204-
205-
if (target === ExtensionType.NIGHTLY) {
206-
version = await this.getIncrementedVerForNightly();
207-
description =
208-
"This is a prerelease version of Dendron that may be unstable. Please install the main dendron extension instead.";
209-
icon = "media/logo-bw.png";
210+
let license: string = "GPLv3";
211+
let name: string;
212+
switch (target) {
213+
case ExtensionType.DENDRON: {
214+
name = target.toString();
215+
break;
216+
}
217+
case ExtensionType.NIGHTLY: {
218+
name = target.toString();
219+
version = await this.getIncrementedVerForNightly();
220+
description =
221+
"This is a prerelease version of Dendron that may be unstable. Please install the main dendron extension instead.";
222+
icon = "media/logo-bw.png";
223+
break;
224+
}
225+
case ExtensionType.ENTERPRISE: {
226+
name = `dendron-enterprise`;
227+
version = await this.getIncrementedVerForNightly();
228+
description = "Dendron - Enterprise Version";
229+
license =
230+
"see license in https://github.com/dendronhq/dendron/wiki/Enterprise-EULA";
231+
break;
232+
}
233+
default: {
234+
assertUnreachable(target);
235+
}
210236
}
211237

212238
this.updatePkgMeta({
213239
pkgPath,
214-
name: target.toString(),
215-
displayName: target.toString(),
240+
name,
241+
license,
242+
displayName: name,
216243
description,
217244
main: "./dist/extension.js",
218245
repository: {
@@ -471,11 +498,13 @@ export class BuildUtils {
471498
main,
472499
repository,
473500
version,
501+
license,
474502
icon,
475503
}: {
476504
pkgPath: string;
477505
name: string;
478506
displayName: string;
507+
license: string;
479508
} & Partial<PkgJson>) {
480509
const pkg = fs.readJSONSync(pkgPath) as PkgJson;
481510
pkg.name = name;
@@ -498,6 +527,7 @@ export class BuildUtils {
498527
pkg.icon = icon;
499528
}
500529
pkg.main = "dist/extension.js";
530+
pkg.license = license;
501531
fs.writeJSONSync(pkgPath, pkg, { spaces: 4 });
502532
}
503533

packages/plugin-core/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Dendron sends out a weekly newsletter highlighting:
175175

176176
There are a variety of ways to connect with Dendron devs, contributors, and other members of the Dendron community:
177177

178-
- Join the [Dendron on Discord](https://link.dendron.so/discord)
178+
- Join the [Dendron on Discord](https://link.dendron.so/discord)
179179
- Follow [Dendron on Twitter (`@dendronhq`)](https://link.dendron.so/twitter)
180180
- Checkout [Dendron on GitHub](https://link.dendron.so/github)
181181
- Read the [Dendron Blog](https://blog.dendron.so/)
@@ -363,3 +363,5 @@ This project follows the [all-contributors](https://github.com/all-contributors/
363363
Dendron is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3.
364364

365365
See [LICENSE](https://github.com/dendronhq/dendron/blob/master/LICENSE.md) and [NOTICE](https://github.com/dendronhq/dendron/blob/master/NOTICE.md) for more information.
366+
367+
Dendron Enterprise is distributed and licensed separately under the [Dendron Enterprise END-USER LICENSE AGREEMENT](https://github.com/dendronhq/dendron/wiki/Enterprise-EULA)

packages/plugin-core/src/_extension.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ import {
2727
} from "@dendronhq/engine-server";
2828
import * as Sentry from "@sentry/node";
2929
import fs from "fs-extra";
30+
import _ from "lodash";
3031
import os from "os";
3132
import path from "path";
33+
import semver from "semver";
3234
import * as vscode from "vscode";
3335
import { ALL_COMMANDS } from "./commands";
3436
import { ConfigureWithUICommand } from "./commands/ConfigureWithUICommand";
37+
import { GotoNoteCommand } from "./commands/GotoNote";
3538
import { GoToSiblingCommand } from "./commands/GoToSiblingCommand";
3639
import { ReloadIndexCommand } from "./commands/ReloadIndex";
3740
import { SeedAddCommand } from "./commands/SeedAddCommand";
@@ -41,9 +44,9 @@ import {
4144
} from "./commands/SeedBrowseCommand";
4245
import { SeedRemoveCommand } from "./commands/SeedRemoveCommand";
4346
import { ShowNoteGraphCommand } from "./commands/ShowNoteGraph";
47+
import { ShowSchemaGraphCommand } from "./commands/ShowSchemaGraph";
4448
import { TogglePreviewCommand } from "./commands/TogglePreview";
4549
import { TogglePreviewLockCommand } from "./commands/TogglePreviewLock";
46-
import { ShowSchemaGraphCommand } from "./commands/ShowSchemaGraph";
4750
import { ConfigureUIPanelFactory } from "./components/views/ConfigureUIPanelFactory";
4851
import { NoteGraphPanelFactory } from "./components/views/NoteGraphViewFactory";
4952
import { PreviewPanelFactory } from "./components/views/PreviewViewFactory";
@@ -58,12 +61,14 @@ import setupRecentWorkspacesTreeView from "./features/RecentWorkspacesTreeview";
5861
import ReferenceHoverProvider from "./features/ReferenceHoverProvider";
5962
import ReferenceProvider from "./features/ReferenceProvider";
6063
import RenameProvider from "./features/RenameProvider";
61-
import { KeybindingUtils } from "./KeybindingUtils";
6264
import { setupLocalExtContainer } from "./injection-providers/setupLocalExtContainer";
65+
import { KeybindingUtils } from "./KeybindingUtils";
6366
import { Logger } from "./logger";
6467
import { StateService } from "./services/stateService";
6568
import { Extensions } from "./settings";
69+
import { CreateScratchNoteKeybindingTip } from "./showcase/CreateScratchNoteKeybindingTip";
6670
import { FeatureShowcaseToaster } from "./showcase/FeatureShowcaseToaster";
71+
import { SurveyUtils } from "./survey";
6772
import { AnalyticsUtils, sentryReportingCallback } from "./utils/analytics";
6873
import { ExtensionUtils } from "./utils/ExtensionUtils";
6974
import { StartupPrompts } from "./utils/StartupPrompts";
@@ -74,10 +79,6 @@ import { DendronExtension, getDWorkspace, getExtension } from "./workspace";
7479
import { TutorialInitializer } from "./workspace/tutorialInitializer";
7580
import { WorkspaceActivator } from "./workspace/workspaceActivator";
7681
import { WSUtils } from "./WSUtils";
77-
import { CreateScratchNoteKeybindingTip } from "./showcase/CreateScratchNoteKeybindingTip";
78-
import semver from "semver";
79-
import _ from "lodash";
80-
import { GotoNoteCommand } from "./commands/GotoNote";
8182

8283
const MARKDOWN_WORD_PATTERN = new RegExp("([\\w\\.]+)");
8384
// === Main
@@ -416,6 +417,24 @@ export async function _activate(
416417
}
417418
}, ONE_MINUTE_IN_MS);
418419
}
420+
if (ExtensionUtils.isEnterprise(context)) {
421+
let resp: boolean | undefined | string = true;
422+
while (!ExtensionUtils.hasValidLicense() && resp !== undefined) {
423+
// eslint-disable-next-line no-await-in-loop
424+
resp = await SurveyUtils.showEnterpriseLicenseSurvey();
425+
}
426+
if (resp === undefined) {
427+
vscode.window.showInformationMessage(
428+
"Please reload to enter your license key",
429+
{
430+
modal: true,
431+
detail:
432+
"Dendron will be inactive until you enter a license key. You can reload your vscode instance to be prompted again",
433+
}
434+
);
435+
return false;
436+
}
437+
}
419438
} else {
420439
// ws not active
421440
Logger.info({ ctx, msg: "dendron not active" });

packages/plugin-core/src/survey.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { ConfirmStatus, getStage, SurveyEvents } from "@dendronhq/common-all";
2-
import { AnalyticsUtils } from "./utils/analytics";
3-
import * as vscode from "vscode";
4-
import _ from "lodash";
5-
import { Logger } from "./logger";
6-
import { resolve } from "path";
7-
import { VSCodeUtils } from "./vsCodeUtils";
82
import {
93
InactvieUserMsgStatusEnum,
104
InitialSurveyStatusEnum,
115
LapsedUserSurveyStatusEnum,
126
MetadataService,
137
PriorTools,
148
} from "@dendronhq/engine-server";
9+
import _ from "lodash";
10+
import { resolve } from "path";
11+
import * as vscode from "vscode";
12+
import { Logger } from "./logger";
13+
import { AnalyticsUtils } from "./utils/analytics";
14+
import { VSCodeUtils } from "./vsCodeUtils";
1515

1616
export class DendronQuickInputSurvey {
1717
opts: {
@@ -491,6 +491,37 @@ export class LapsedUserPlugDiscordSurvey extends DendronQuickPickSurvey {
491491
}
492492

493493
export class SurveyUtils {
494+
static async showEnterpriseLicenseSurvey() {
495+
AnalyticsUtils.track("EnterpriseLicenseSurveyPrompted");
496+
return vscode.window
497+
.showInformationMessage(
498+
"Welcome to Dendron! 🌱",
499+
{
500+
modal: true,
501+
detail: "Please enter your enterprise license key to proceed",
502+
},
503+
{ title: "Enter" }
504+
)
505+
.then(async (resp) => {
506+
if (resp === undefined) {
507+
return undefined;
508+
}
509+
const licenseKey = await vscode.window.showInputBox({
510+
ignoreFocusOut: true,
511+
placeHolder: "license key",
512+
prompt: "Please paste your license key here",
513+
title: "License key",
514+
});
515+
const meta = MetadataService.instance();
516+
if (licenseKey !== undefined) {
517+
// @ts-ignore
518+
meta.setMeta("enterpriseLicense", licenseKey);
519+
return true;
520+
}
521+
return undefined;
522+
});
523+
}
524+
494525
/**
495526
* Asks three questions about background, use case, and prior tools used.
496527
*/

packages/plugin-core/src/utils/ExtensionUtils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ export class ExtensionUtils {
160160
return ext as vscode.Extension<any>;
161161
}
162162

163+
static isEnterprise(context: vscode.ExtensionContext) {
164+
return context.extension.id === "dendron.dendron-enterprise";
165+
}
166+
167+
static hasValidLicense() {
168+
// @ts-ignore
169+
const enterpriseLicense = MetadataService.instance().getMeta()[
170+
"enterpriseLicense"
171+
] as string;
172+
// TODO
173+
if (!enterpriseLicense) {
174+
return false;
175+
}
176+
return true;
177+
}
178+
163179
static _TUTORIAL_IDS: Set<string> | undefined;
164180
static getTutorialIds(): Set<string> {
165181
if (_.isUndefined(ExtensionUtils._TUTORIAL_IDS)) {
@@ -405,6 +421,7 @@ export class ExtensionUtils {
405421
const dendronConfigChanged = configDiff.length > 0;
406422

407423
const trackProps = {
424+
extensionId: ext.context.extension.id,
408425
duration: durationReloadWorkspace,
409426
numNotes,
410427
numNoteRefs,

0 commit comments

Comments
 (0)