diff --git a/src/commands/apply.ts b/src/commands/apply.ts index 8ac9335..336b8f0 100644 --- a/src/commands/apply.ts +++ b/src/commands/apply.ts @@ -4,7 +4,8 @@ import chalk from 'chalk' import * as path from 'pathe' import * as customFlags from '../flags/common.js' -import {BSL_LICENSE_CTA, BSL_LICENSE_HEADLINE, BSL_LICENSE_TEXT, DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR } from '../lib/constants.js' +import {DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR } from '../lib/constants.js' +import { displayLicenseBanner } from '../lib/license/index.js' import {type ApplyFlags, validateInteractiveFlags, validateProgrammaticFlags} from '../lib/load/apply-flags.js' import apply from '../lib/load/index.js' import {animatedBunny} from '../lib/utils/animated-bunny.js' @@ -244,9 +245,7 @@ static flags = { ux.stdout(SEPARATOR) - log.warn(BSL_LICENSE_HEADLINE) - log.info(BSL_LICENSE_TEXT) - log.info(BSL_LICENSE_CTA) + await displayLicenseBanner() ux.stdout('Template applied successfully.') if (!validatedFlags.noExit) process.exit(0) @@ -337,10 +336,8 @@ static flags = { ux.stdout('Template applied successfully.') if (!validatedFlags.noExit) process.exit(0) - // Hide BSL license info if running programatically for now - // log.warn(BSL_LICENSE_HEADLINE) - // log.info(BSL_LICENSE_TEXT) - // log.info(BSL_LICENSE_CTA) + // Hide license info if running programatically for now + // await displayLicenseBanner() } /** diff --git a/src/commands/extract.ts b/src/commands/extract.ts index 773dc7c..a3008d8 100644 --- a/src/commands/extract.ts +++ b/src/commands/extract.ts @@ -6,8 +6,9 @@ import fs from 'node:fs' import path from 'pathe' import * as customFlags from '../flags/common.js' -import {BSL_LICENSE_CTA, BSL_LICENSE_HEADLINE, BSL_LICENSE_TEXT, DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR} from '../lib/constants.js' +import {DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR} from '../lib/constants.js' import extract from '../lib/extract/index.js' +import {displayLicenseBanner} from '../lib/license/index.js' import {animatedBunny} from '../lib/utils/animated-bunny.js' import {getDirectusEmailAndPassword, getDirectusToken, getDirectusUrl, initializeDirectusApi, validateAuthFlags} from '../lib/utils/auth.js' import catchError from '../lib/utils/catch-error.js' @@ -129,9 +130,7 @@ static flags = { await shutdown(); } - log.warn(BSL_LICENSE_HEADLINE) - log.info(BSL_LICENSE_TEXT) - log.info(BSL_LICENSE_CTA) + await displayLicenseBanner() ux.stdout(SEPARATOR) ux.stdout('Template extracted successfully.') diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 8bb60dc..923cf43 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -24,12 +24,23 @@ export const POSTHOG_HOST = 'https://us.i.posthog.com' export const DEFAULT_BRANCH = 'main' +export const MSCL_LICENSE_URL = 'https://directus.com/license' +export const MSCL_EMAIL = 'licensing@directus.com' + +export const MSCL_LICENSE_HEADLINE = + "Directus is licensed under MSCL-1.0-GPL. A Competing Use—making the Software available in a way that competes with Directus's paid commercial offerings—is not permitted." +export const MSCL_LICENSE_TEXT = + 'Permitted uses include internal use, non-commercial education and research, and professional services to deploy or host Directus for licensees. You must not disable or circumvent license key functionality. Four years after release, the Software is also available under GPL-3.0.' + +export const MSCL_LICENSE_CTA = `Visit ${pinkText(MSCL_LICENSE_URL)} or reach out to us at ${pinkText(MSCL_EMAIL)} for the full license terms.` export const BSL_LICENSE_URL = 'https://directus.io/bsl' export const BSL_EMAIL = 'licensing@directus.io' -export const BSL_LICENSE_HEADLINE = 'You REQUIRE a license to use Directus if your organization has more than $5MM USD a year in revenue and/or funding.' -export const BSL_LICENSE_TEXT = 'For all organizations with less than $5MM USD a year in revenue and funding, Directus is free for personal projects, hobby projects and in production. This second group does not require a license. Directus is licensed under BSL 1.1.' +export const BSL_LICENSE_HEADLINE = + 'You REQUIRE a license to use Directus if your organization has more than $5MM USD a year in revenue and/or funding.' +export const BSL_LICENSE_TEXT = + 'For all organizations with less than $5MM USD a year in revenue and funding, Directus is free for personal projects, hobby projects and in production. This second group does not require a license. Directus is licensed under BSL 1.1.' export const BSL_LICENSE_CTA = `Visit ${pinkText(BSL_LICENSE_URL)} for more information or reach out to us at ${pinkText(BSL_EMAIL)}.` diff --git a/src/lib/init/index.ts b/src/lib/init/index.ts index 61f1ac7..de62fc9 100644 --- a/src/lib/init/index.ts +++ b/src/lib/init/index.ts @@ -12,7 +12,8 @@ import type {InitFlags} from '../../commands/init.js' import ApplyCommand from '../../commands/apply.js' import {createDocker} from '../../services/docker.js' -import {BSL_LICENSE_CTA, BSL_LICENSE_HEADLINE, BSL_LICENSE_TEXT, pinkText} from '../constants.js' +import {pinkText} from '../constants.js' +import {displayLicenseBanner} from '../license/index.js' import catchError from '../utils/catch-error.js' import {createGigetString, parseGitHubUrl} from '../utils/parse-github-url.js' import {readTemplateConfig} from '../utils/template-config.js' @@ -202,9 +203,7 @@ export async function init({dir, flags}: {dir: string, flags: InitFlags}) { note(nextSteps, 'Next Steps') - clackLog.warn(BSL_LICENSE_HEADLINE) - clackLog.info(BSL_LICENSE_TEXT) - clackLog.info(BSL_LICENSE_CTA) + await displayLicenseBanner() outro(`Problems or questions? Hop into the community at ${pinkText('https://directus.chat')}`) } catch (error) { diff --git a/src/lib/license/index.ts b/src/lib/license/index.ts new file mode 100644 index 0000000..4962372 --- /dev/null +++ b/src/lib/license/index.ts @@ -0,0 +1,29 @@ +import {serverHealth} from '@directus/sdk' + +import { + BSL_LICENSE_CTA, + BSL_LICENSE_HEADLINE, + BSL_LICENSE_TEXT, + MSCL_LICENSE_CTA, + MSCL_LICENSE_HEADLINE, + MSCL_LICENSE_TEXT, +} from '../constants.js' +import {api} from '../sdk.js' + +export const displayLicenseBanner = async () => { + const {releaseId} = await api.client.request(serverHealth()) + + const mainVersion = Number(releaseId.split('.')[0]) + + const isMSCL = mainVersion >= 12 + + if (isMSCL) { + console.warn(MSCL_LICENSE_HEADLINE) + console.info(MSCL_LICENSE_TEXT) + console.info(MSCL_LICENSE_CTA) + } else { + console.warn(BSL_LICENSE_HEADLINE) + console.info(BSL_LICENSE_TEXT) + console.info(BSL_LICENSE_CTA) + } +}