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

enhance: updated enterprise build #3804

Merged
merged 12 commits into from
Nov 28, 2022
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
77 changes: 77 additions & 0 deletions .github/workflows/create-enterprise-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Generates an enterprise image. This image differs by requiring the user to
# enter an enterprise license on startup.
name: Create Enterprise Image

on:
workflow_dispatch:

jobs:
build:
environment: plugin-development
strategy:
fail-fast: true

timeout-minutes: 30

runs-on: ubuntu-latest

steps:
- name: Gather environment data
run: |
node --version
npm --version
yarn --version

- name: Configure Git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]

- name: Checkout source
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Yarn Setup
run: yarn setup

- name: Set Up Yarn Local Registry
run: yarn config set registry http://localhost:4873

- name: Set Up NPM Local Registry
run: npm set registry http://localhost:4873/

- name: Set Environment Variables
run: |
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
echo "GOOGLE_OAUTH_CLIENT_SECRET=${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}" >> $GITHUB_ENV
echo "GOOGLE_OAUTH_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}" >> $GITHUB_ENV
echo "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" >> $GITHUB_ENV
echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV

- name: Build the VSIX
run: |
yarn build:patch:local:ci:enterprise

- name: Check for VSIX
run: |
vsixCount=`ls ./packages/plugin-core/*.vsix | wc -l | awk '{print $1}'`
if [ $vsixCount = 1 ]; then
vsix=$(ls ./packages/plugin-core/*.vsix | tail -1)
echo "found a single .vsix file named $vsix"
echo "VSIX_FILE_NAME=$(basename $vsix)" >> $GITHUB_ENV
echo "VSIX_RELATIVE_PATH=$vsix" >> $GITHUB_ENV
else
echo "error: expected 1 .vsix file, found $vsixCount"
exit 1
fi

- name: Upload VSIX Artifact
uses: actions/upload-artifact@v2
with:
name: vsix
path: ${{ env.VSIX_RELATIVE_PATH }}
if-no-files-found: error
1 change: 0 additions & 1 deletion bootstrap/scripts/buildNightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ echo "$FOO_PID"
sleep 10

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

DENDRON_CLI=./packages/dendron-cli/lib/bin/dendron-cli.js
Expand Down
3 changes: 3 additions & 0 deletions bootstrap/scripts/buildPatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ EXT_TYPE=dendron
if [ $SCRIPT_EXT_TYPE = "nightly" ]; then
EXT_TYPE=nightly
fi
if [ $SCRIPT_EXT_TYPE = "enterprise" ]; then
EXT_TYPE=enterprise
fi

if [ -z $FAST ]; then
LOG_LEVEL=info $DENDRON_CLI dev build --upgradeType $UPGRADE_TYPE --publishEndpoint $PUBLISH_ENDPOINT --extensionType $EXT_TYPE
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"build:patch:local": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=local USE_IN_MEMORY_REGISTRY=1 ./bootstrap/scripts/buildPatch.sh",
"build:patch:local:ci": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=local BUILD_ENV=ci USE_IN_MEMORY_REGISTRY=1 ./bootstrap/scripts/buildPatch.sh",
"build:patch:local:ci:nightly": "./bootstrap/scripts/buildNightly.sh",
"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",
"build:patch:remote": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=remote ./bootstrap/scripts/buildPatch.sh",
"build:patch:remote:ci": "cross-env UPGRADE_TYPE=patch PUBLISH_ENDPOINT=remote BUILD_ENV=ci ./bootstrap/scripts/buildPatch.sh",
"build:minor:local": "cross-env UPGRADE_TYPE=minor PUBLISH_ENDPOINT=local ./bootstrap/scripts/buildPatch.sh",
Expand Down
2 changes: 1 addition & 1 deletion packages/dendron-cli/src/commands/devCLICommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export class DevCLICommand extends CLICommand<CommandOpts, CommandOutput> {
this.print("sync assets...");
await this.syncAssets(opts);

this.print("prep repo...");
this.print(`prep repo... extensionType: ${opts.extensionType}`);
await BuildUtils.prepPluginPkg(opts.extensionType);

if (!shouldPublishLocal) {
Expand Down
48 changes: 39 additions & 9 deletions packages/dendron-cli/src/utils/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable no-console */
import { DendronError, error2PlainObject } from "@dendronhq/common-all";
import {
assertUnreachable,
DendronError,
error2PlainObject,
} from "@dendronhq/common-all";
import { createLogger, findUpTo } from "@dendronhq/common-server";
import execa from "execa";
import fs from "fs-extra";
Expand All @@ -16,6 +20,7 @@ type PkgJson = {
repository: PkgRepository;
devDependencies: { [key: string]: string };
icon: string;
license: string;
};

type PkgRepository = {
Expand All @@ -39,6 +44,7 @@ export enum PublishEndpoint {
export enum ExtensionType {
DENDRON = "dendron",
NIGHTLY = "nightly",
ENTERPRISE = "enterprise",
}

const LOCAL_NPM_ENDPOINT = "http://localhost:4873";
Expand Down Expand Up @@ -201,18 +207,39 @@ export class BuildUtils {
let version;
let description;
let icon;

if (target === ExtensionType.NIGHTLY) {
version = await this.getIncrementedVerForNightly();
description =
"This is a prerelease version of Dendron that may be unstable. Please install the main dendron extension instead.";
icon = "media/logo-bw.png";
let license: string = "GPLv3";
let name: string;
switch (target) {
case ExtensionType.DENDRON: {
name = target.toString();
break;
}
case ExtensionType.NIGHTLY: {
name = target.toString();
version = await this.getIncrementedVerForNightly();
description =
"This is a prerelease version of Dendron that may be unstable. Please install the main dendron extension instead.";
icon = "media/logo-bw.png";
break;
}
case ExtensionType.ENTERPRISE: {
name = `dendron-enterprise`;
version = await this.getIncrementedVerForNightly();
description = "Dendron - Enterprise Version";
license =
"see license in https://github.com/dendronhq/dendron/wiki/Enterprise-EULA";
break;
}
default: {
assertUnreachable(target);
}
}

this.updatePkgMeta({
pkgPath,
name: target.toString(),
displayName: target.toString(),
name,
license,
displayName: name,
description,
main: "./dist/extension.js",
repository: {
Expand Down Expand Up @@ -471,11 +498,13 @@ export class BuildUtils {
main,
repository,
version,
license,
icon,
}: {
pkgPath: string;
name: string;
displayName: string;
license: string;
} & Partial<PkgJson>) {
const pkg = fs.readJSONSync(pkgPath) as PkgJson;
pkg.name = name;
Expand All @@ -498,6 +527,7 @@ export class BuildUtils {
pkg.icon = icon;
}
pkg.main = "dist/extension.js";
pkg.license = license;
fs.writeJSONSync(pkgPath, pkg, { spaces: 4 });
}

Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Dendron sends out a weekly newsletter highlighting:

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

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

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.

Dendron Enterprise is distributed and licensed separately under the [Dendron Enterprise END-USER LICENSE AGREEMENT](https://github.com/dendronhq/dendron/wiki/Enterprise-EULA)
31 changes: 25 additions & 6 deletions packages/plugin-core/src/_extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ import {
} from "@dendronhq/engine-server";
import * as Sentry from "@sentry/node";
import fs from "fs-extra";
import _ from "lodash";
import os from "os";
import path from "path";
import semver from "semver";
import * as vscode from "vscode";
import { ALL_COMMANDS } from "./commands";
import { ConfigureWithUICommand } from "./commands/ConfigureWithUICommand";
import { GotoNoteCommand } from "./commands/GotoNote";
import { GoToSiblingCommand } from "./commands/GoToSiblingCommand";
import { ReloadIndexCommand } from "./commands/ReloadIndex";
import { SeedAddCommand } from "./commands/SeedAddCommand";
Expand All @@ -41,9 +44,9 @@ import {
} from "./commands/SeedBrowseCommand";
import { SeedRemoveCommand } from "./commands/SeedRemoveCommand";
import { ShowNoteGraphCommand } from "./commands/ShowNoteGraph";
import { ShowSchemaGraphCommand } from "./commands/ShowSchemaGraph";
import { TogglePreviewCommand } from "./commands/TogglePreview";
import { TogglePreviewLockCommand } from "./commands/TogglePreviewLock";
import { ShowSchemaGraphCommand } from "./commands/ShowSchemaGraph";
import { ConfigureUIPanelFactory } from "./components/views/ConfigureUIPanelFactory";
import { NoteGraphPanelFactory } from "./components/views/NoteGraphViewFactory";
import { PreviewPanelFactory } from "./components/views/PreviewViewFactory";
Expand All @@ -58,12 +61,14 @@ import setupRecentWorkspacesTreeView from "./features/RecentWorkspacesTreeview";
import ReferenceHoverProvider from "./features/ReferenceHoverProvider";
import ReferenceProvider from "./features/ReferenceProvider";
import RenameProvider from "./features/RenameProvider";
import { KeybindingUtils } from "./KeybindingUtils";
import { setupLocalExtContainer } from "./injection-providers/setupLocalExtContainer";
import { KeybindingUtils } from "./KeybindingUtils";
import { Logger } from "./logger";
import { StateService } from "./services/stateService";
import { Extensions } from "./settings";
import { CreateScratchNoteKeybindingTip } from "./showcase/CreateScratchNoteKeybindingTip";
import { FeatureShowcaseToaster } from "./showcase/FeatureShowcaseToaster";
import { SurveyUtils } from "./survey";
import { AnalyticsUtils, sentryReportingCallback } from "./utils/analytics";
import { ExtensionUtils } from "./utils/ExtensionUtils";
import { StartupPrompts } from "./utils/StartupPrompts";
Expand All @@ -74,10 +79,6 @@ import { DendronExtension, getDWorkspace, getExtension } from "./workspace";
import { TutorialInitializer } from "./workspace/tutorialInitializer";
import { WorkspaceActivator } from "./workspace/workspaceActivator";
import { WSUtils } from "./WSUtils";
import { CreateScratchNoteKeybindingTip } from "./showcase/CreateScratchNoteKeybindingTip";
import semver from "semver";
import _ from "lodash";
import { GotoNoteCommand } from "./commands/GotoNote";

const MARKDOWN_WORD_PATTERN = new RegExp("([\\w\\.]+)");
// === Main
Expand Down Expand Up @@ -416,6 +417,24 @@ export async function _activate(
}
}, ONE_MINUTE_IN_MS);
}
if (ExtensionUtils.isEnterprise(context)) {
let resp: boolean | undefined | string = true;
while (!ExtensionUtils.hasValidLicense() && resp !== undefined) {
// eslint-disable-next-line no-await-in-loop
resp = await SurveyUtils.showEnterpriseLicenseSurvey();
}
if (resp === undefined) {
vscode.window.showInformationMessage(
"Please reload to enter your license key",
{
modal: true,
detail:
"Dendron will be inactive until you enter a license key. You can reload your vscode instance to be prompted again",
}
);
return false;
}
}
} else {
// ws not active
Logger.info({ ctx, msg: "dendron not active" });
Expand Down
43 changes: 37 additions & 6 deletions packages/plugin-core/src/survey.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ConfirmStatus, getStage, SurveyEvents } from "@dendronhq/common-all";
import { AnalyticsUtils } from "./utils/analytics";
import * as vscode from "vscode";
import _ from "lodash";
import { Logger } from "./logger";
import { resolve } from "path";
import { VSCodeUtils } from "./vsCodeUtils";
import {
InactvieUserMsgStatusEnum,
InitialSurveyStatusEnum,
LapsedUserSurveyStatusEnum,
MetadataService,
PriorTools,
} from "@dendronhq/engine-server";
import _ from "lodash";
import { resolve } from "path";
import * as vscode from "vscode";
import { Logger } from "./logger";
import { AnalyticsUtils } from "./utils/analytics";
import { VSCodeUtils } from "./vsCodeUtils";

export class DendronQuickInputSurvey {
opts: {
Expand Down Expand Up @@ -491,6 +491,37 @@ export class LapsedUserPlugDiscordSurvey extends DendronQuickPickSurvey {
}

export class SurveyUtils {
static async showEnterpriseLicenseSurvey() {
AnalyticsUtils.track("EnterpriseLicenseSurveyPrompted");
return vscode.window
.showInformationMessage(
"Welcome to Dendron! 🌱",
{
modal: true,
detail: "Please enter your enterprise license key to proceed",
},
{ title: "Enter" }
)
.then(async (resp) => {
if (resp === undefined) {
return undefined;
}
const licenseKey = await vscode.window.showInputBox({
ignoreFocusOut: true,
placeHolder: "license key",
prompt: "Please paste your license key here",
title: "License key",
});
const meta = MetadataService.instance();
if (licenseKey !== undefined) {
// @ts-ignore
meta.setMeta("enterpriseLicense", licenseKey);
return true;
}
return undefined;
});
}

/**
* Asks three questions about background, use case, and prior tools used.
*/
Expand Down
17 changes: 17 additions & 0 deletions packages/plugin-core/src/utils/ExtensionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ export class ExtensionUtils {
return ext as vscode.Extension<any>;
}

static isEnterprise(context: vscode.ExtensionContext) {
return context.extension.id === "dendron.dendron-enterprise";
}

static hasValidLicense() {
// @ts-ignore
const enterpriseLicense = MetadataService.instance().getMeta()[
"enterpriseLicense"
] as string;
// TODO
if (!enterpriseLicense) {
return false;
}
return true;
}

static _TUTORIAL_IDS: Set<string> | undefined;
static getTutorialIds(): Set<string> {
if (_.isUndefined(ExtensionUtils._TUTORIAL_IDS)) {
Expand Down Expand Up @@ -405,6 +421,7 @@ export class ExtensionUtils {
const dendronConfigChanged = configDiff.length > 0;

const trackProps = {
extensionId: ext.context.extension.id,
duration: durationReloadWorkspace,
numNotes,
numNoteRefs,
Expand Down