+
Skip to content

Offer a longer trial for filling out a short survey #49

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

Merged
merged 20 commits into from
Dec 5, 2021
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
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node
16
2 changes: 0 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"amodio.tsl-problem-matcher"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 1.0.2 - 5 December 2021

### Added
- Extend the free preview for filling out a 2-minute survey. [#49](https://github.com/getlocalci/local-ci/pull/49/)

## 1.0.1 - 24 November 2021

### Added
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "local-ci",
"displayName": "Local CI",
"description": "Debug CircleCI® workflows locally, with Bash access during and after. Free preview, then paid.",
"version": "1.0.1",
"version": "1.0.2",
"publisher": "LocalCI",
"contributors": [
"Ryan Kienstra"
Expand All @@ -21,7 +21,7 @@
"qna": "https://github.com/getlocalci/local-ci/discussions",
"engines": {
"vscode": "^1.59.0",
"node": ">=16"
"node": "16"
},
"os": [
"!win32"
Expand Down Expand Up @@ -287,7 +287,7 @@
"typescript": "^4.3.2",
"util": "^0.12.4",
"vsce": "^2.5.0",
"vscode-test": "^1.5.2",
"vscode-test": "^1.6.1",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0"
},
Expand Down
6 changes: 5 additions & 1 deletion src/classes/JobProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import getAllConfigFilePaths from '../utils/getAllConfigFilePaths';
import getConfigFilePath from '../utils/getConfigFilePath';
import getDockerError from '../utils/getDockerError';
import getProcessFilePath from '../utils/getProcessFilePath';
import getTrialLength from '../utils/getTrialLength';
import isDockerRunning from '../utils/isDockerRunning';
import isLicenseValid from '../utils/isLicenseValid';
import isTrialExpired from '../utils/isTrialExpired';
Expand Down Expand Up @@ -73,7 +74,10 @@ export default class JobProvider

const shouldEnableExtension =
(await isLicenseValid(this.context)) ||
!isTrialExpired(this.context.globalState.get(TRIAL_STARTED_TIMESTAMP));
!isTrialExpired(
this.context.globalState.get(TRIAL_STARTED_TIMESTAMP),
getTrialLength(this.context)
);
const dockerRunning = isDockerRunning();

if (shouldEnableExtension && dockerRunning) {
Expand Down
32 changes: 29 additions & 3 deletions src/classes/LicenseProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import * as vscode from 'vscode';
import { LICENSE_ERROR } from '../constants';
import {
EXTENDED_TRIAL_LENGTH_IN_MILLISECONDS,
HAS_EXTENDED_TRIAL,
LICENSE_ERROR,
SURVEY_URL,
TRIAL_STARTED_TIMESTAMP,
} from '../constants';
import getLicenseErrorMessage from '../utils/getLicenseErrorMessage';
import getLicenseInformation from '../utils/getLicenseInformation';
import getPrettyPrintedTimeRemaining from '../utils/getPrettyPrintedTimeRemaining';
import isLicenseValid from '../utils/isLicenseValid';
import showLicenseInput from '../utils/showLicenseInput';

Expand Down Expand Up @@ -37,11 +44,11 @@ export default class LicenseProvider implements vscode.WebviewViewProvider {
localResourceRoots: [this.extensionUri],
};

await this.load();
this.load();

webviewView.webview.onDidReceiveMessage(async (data) => {
if (data.type === 'enterLicense') {
await showLicenseInput(
showLicenseInput(
this.context,
() => this.load(),
() => this.licenseSuccessCallback()
Expand All @@ -66,6 +73,25 @@ export default class LicenseProvider implements vscode.WebviewViewProvider {
});
}
}

if (data.type === 'takeSurvey') {
if (this.context.globalState.get(HAS_EXTENDED_TRIAL)) {
return;
}

this.load();
this.context.globalState.update(HAS_EXTENDED_TRIAL, true);
this.context.globalState.update(
TRIAL_STARTED_TIMESTAMP,
new Date().getTime()
);
vscode.env.openExternal(vscode.Uri.parse(SURVEY_URL));
vscode.window.showInformationMessage(
`Thanks, your free preview is now ${getPrettyPrintedTimeRemaining(
EXTENDED_TRIAL_LENGTH_IN_MILLISECONDS
)} longer`
);
}
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ export const LICENSE_VALIDITY = 'local-ci.license.validity';
export const LICENSE_VALIDITY_CACHE_EXPIRATION =
'local-ci.license.cache.expiration';
export const TRIAL_LENGTH_IN_MILLISECONDS = 172800000; // 2 days.
export const EXTENDED_TRIAL_LENGTH_IN_MILLISECONDS = 1296000000; // 15 days.
export const HAS_EXTENDED_TRIAL = 'local-ci.license.trial-extended.survey';
export const TRIAL_STARTED_TIMESTAMP =
'local-ci.license.trial-started.timestamp';
export const CONTAINER_STORAGE_DIRECTORY = '/tmp/local-ci';
export const HOST_TMP_DIRECTORY = '/tmp/local-ci'; // Also hard-coded in node/uninstall.js, change that if this changes.
export const PROCESS_FILE_DIRECTORY = `${HOST_TMP_DIRECTORY}/process`;
export const LOCAL_VOLUME_DIRECTORY = `${HOST_TMP_DIRECTORY}/volume`;
export const RUN_JOB_COMMAND = 'local-ci.job.run';
export const SCHEDULE_INTERVIEW_URL =
'https://tidycal.com/localci/30-minute-meeting';
export const SUPPRESS_UNCOMMITTED_FILE_WARNING =
'local-ci.suppress-warning.uncommitted';
export const SURVEY_URL = 'https://www.surveymonkey.com/r/localci';
7 changes: 4 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
JOB_TREE_VIEW_ID,
RUN_JOB_COMMAND,
SELECTED_CONFIG_PATH,
TRIAL_STARTED_TIMESTAMP,
} from './constants';
import cleanUpCommittedImages from './utils/cleanUpCommittedImages';
import disposeTerminalsForJob from './utils/disposeTerminalsForJob';
Expand All @@ -22,7 +23,6 @@ import getConfig from './utils/getConfig';
import getConfigFilePath from './utils/getConfigFilePath';
import getDebuggingTerminalName from './utils/getDebuggingTerminalName';
import getFinalTerminalName from './utils/getFinalTerminalName';
import getLicenseInformation from './utils/getLicenseInformation';
import getProcessedConfig from './utils/getProcessedConfig';
import getProcessFilePath from './utils/getProcessFilePath';
import getRepoBasename from './utils/getRepoBasename';
Expand All @@ -31,6 +31,9 @@ import showLicenseInput from './utils/showLicenseInput';
import writeProcessFile from './utils/writeProcessFile';

export function activate(context: vscode.ExtensionContext): void {
if (!context.globalState.get(TRIAL_STARTED_TIMESTAMP)) {
context.globalState.update(TRIAL_STARTED_TIMESTAMP, new Date().getTime());
}
const jobProvider = new JobProvider(context);

vscode.window.registerTreeDataProvider(JOB_TREE_VIEW_ID, jobProvider);
Expand Down Expand Up @@ -255,6 +258,4 @@ export function activate(context: vscode.ExtensionContext): void {
}
},
});

getLicenseInformation(context);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was hacky, it's replaced with the globalState.update() above

}
34 changes: 0 additions & 34 deletions src/test/suite/utils/getHoursRemainingInTrial.test.ts

This file was deleted.

50 changes: 50 additions & 0 deletions src/test/suite/utils/getMillisecondsRemainingInTrial.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as assert from 'assert';
import { TRIAL_LENGTH_IN_MILLISECONDS } from '../../../constants';
import getMillisecondsRemainingInTrial from '../../../utils/getMillisecondsRemainingInTrial';

const hourInMilliseconds = 3600000;
suite('getMillisecondsRemainingInTrial', () => {
test('entire trial remaining', () => {
const time = new Date().getTime();
assert.strictEqual(
getMillisecondsRemainingInTrial(time, time, TRIAL_LENGTH_IN_MILLISECONDS),
172800000
);
});

test('1 day remaining', () => {
const time = new Date().getTime();
assert.strictEqual(
getMillisecondsRemainingInTrial(
time,
time - 24 * hourInMilliseconds,
TRIAL_LENGTH_IN_MILLISECONDS
),
86400000
);
});

test('1 hour remaining', () => {
const time = new Date().getTime();
assert.strictEqual(
getMillisecondsRemainingInTrial(
time,
time - 47 * hourInMilliseconds,
TRIAL_LENGTH_IN_MILLISECONDS
),
3600000
);
});

test('no time remaining', () => {
const time = new Date().getTime();
assert.strictEqual(
getMillisecondsRemainingInTrial(
time,
time - 48 * hourInMilliseconds,
TRIAL_LENGTH_IN_MILLISECONDS
),
0
);
});
});
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载