@directus/extensions-sdk 10.3.4 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { EXTENSION_LANGUAGES, EXTENSION_NAME_REGEX, EXTENSION_PKG_KEY, EXTENSION_TYPES, ExtensionManifest, HYBRID_EXTENSION_TYPES, } from '@directus/extensions';
1
+ import { EXTENSION_LANGUAGES, EXTENSION_PKG_KEY, EXTENSION_TYPES, ExtensionManifest, HYBRID_EXTENSION_TYPES, } from '@directus/extensions';
2
2
  import { isIn, isTypeIn } from '@directus/utils';
3
3
  import { pathToRelativeUrl } from '@directus/utils/node';
4
4
  import chalk from 'chalk';
@@ -129,7 +129,6 @@ export default async function add(options) {
129
129
  log(`Extension has not been modified.`, 'info');
130
130
  process.exit(1);
131
131
  }
132
- const oldName = extensionManifest.name.match(EXTENSION_NAME_REGEX)?.[1] ?? extensionManifest.name;
133
132
  const { type, name, language, convertName, extensionName, alternativeSource } = await inquirer.prompt([
134
133
  {
135
134
  type: 'list',
@@ -153,14 +152,14 @@ export default async function add(options) {
153
152
  type: 'input',
154
153
  name: 'convertName',
155
154
  message: 'Choose a name for the extension that is converted to an entry',
156
- default: oldName,
155
+ default: extensionManifest.name,
157
156
  validate: (name) => (name.length === 0 ? 'Entry name can not be empty.' : true),
158
157
  },
159
158
  {
160
159
  type: 'input',
161
160
  name: 'extensionName',
162
161
  message: 'Choose a name for the extension',
163
- default: ({ convertName }) => (convertName !== oldName ? oldName : null),
162
+ default: ({ convertName }) => convertName !== extensionManifest.name ? extensionManifest.name : null,
164
163
  validate: (name) => (name.length === 0 ? 'Extension name can not be empty.' : true),
165
164
  },
166
165
  {
@@ -218,8 +217,8 @@ export default async function add(options) {
218
217
  };
219
218
  const newExtensionManifest = {
220
219
  ...extensionManifest,
221
- name: EXTENSION_NAME_REGEX.test(extensionName) ? extensionName : `directus-extension-${extensionName}`,
222
- keywords: ['directus', 'directus-extension', `directus-custom-bundle`],
220
+ name: extensionName,
221
+ keywords: ['directus', 'directus-extension', 'directus-extension-bundle'],
223
222
  [EXTENSION_PKG_KEY]: newExtensionOptions,
224
223
  devDependencies: {
225
224
  ...extensionManifest.devDependencies,
@@ -1,12 +1,12 @@
1
- import { BUNDLE_EXTENSION_TYPES, EXTENSION_LANGUAGES, EXTENSION_NAME_REGEX, EXTENSION_PKG_KEY, EXTENSION_TYPES, HYBRID_EXTENSION_TYPES, } from '@directus/extensions';
1
+ import { BUNDLE_EXTENSION_TYPES, EXTENSION_LANGUAGES, EXTENSION_PKG_KEY, EXTENSION_TYPES, HYBRID_EXTENSION_TYPES, } from '@directus/extensions';
2
2
  import { isIn } from '@directus/utils';
3
3
  import chalk from 'chalk';
4
4
  import { execa } from 'execa';
5
5
  import fse from 'fs-extra';
6
6
  import ora from 'ora';
7
7
  import path from 'path';
8
+ import { LAST_BREAKING_RELEASE } from '../../constants/last-breaking.js';
8
9
  import getPackageManager from '../utils/get-package-manager.js';
9
- import getSdkVersion from '../utils/get-sdk-version.js';
10
10
  import { isLanguage, languageToShort } from '../utils/languages.js';
11
11
  import { log } from '../utils/logger.js';
12
12
  import copyTemplate from './helpers/copy-template.js';
@@ -36,18 +36,18 @@ export default async function create(type, name, options) {
36
36
  }
37
37
  }
38
38
  if (isIn(type, BUNDLE_EXTENSION_TYPES)) {
39
- await createPackageExtension({ type, name, targetDir, targetPath, install });
39
+ await createBundleExtension({ type, name, targetDir, targetPath, install });
40
40
  }
41
41
  else {
42
42
  const language = options.language ?? 'javascript';
43
- await createLocalExtension({ type, name, targetDir, targetPath, language, install });
43
+ await createExtension({ type, name, targetDir, targetPath, language, install });
44
44
  }
45
45
  }
46
- async function createPackageExtension({ type, name, targetDir, targetPath, install, }) {
46
+ async function createBundleExtension({ type, name, targetDir, targetPath, install, }) {
47
47
  const spinner = ora(chalk.bold('Scaffolding Directus extension...')).start();
48
48
  await fse.ensureDir(targetPath);
49
49
  await copyTemplate(type, targetPath);
50
- const host = `^${getSdkVersion()}`;
50
+ const host = `^${LAST_BREAKING_RELEASE}`;
51
51
  const options = { type, path: { app: 'dist/app.js', api: 'dist/api.js' }, entries: [], host };
52
52
  const packageManifest = getPackageManifest(name, options, await getExtensionDevDeps(type));
53
53
  await fse.writeJSON(path.join(targetPath, 'package.json'), packageManifest, { spaces: '\t' });
@@ -58,7 +58,7 @@ async function createPackageExtension({ type, name, targetDir, targetPath, insta
58
58
  spinner.succeed(chalk.bold('Done'));
59
59
  log(getDoneMessage(type, targetDir, targetPath, packageManager, install));
60
60
  }
61
- async function createLocalExtension({ type, name, targetDir, targetPath, language, install, }) {
61
+ async function createExtension({ type, name, targetDir, targetPath, language, install, }) {
62
62
  if (!isLanguage(language)) {
63
63
  log(`Language ${chalk.bold(language)} is not supported. Available languages: ${EXTENSION_LANGUAGES.map((t) => chalk.bold.magenta(t)).join(', ')}.`, 'error');
64
64
  process.exit(1);
@@ -66,7 +66,7 @@ async function createLocalExtension({ type, name, targetDir, targetPath, languag
66
66
  const spinner = ora(chalk.bold('Scaffolding Directus extension...')).start();
67
67
  await fse.ensureDir(targetPath);
68
68
  await copyTemplate(type, targetPath, 'src', language);
69
- const host = `^${getSdkVersion()}`;
69
+ const host = `^${LAST_BREAKING_RELEASE}`;
70
70
  const options = isIn(type, HYBRID_EXTENSION_TYPES)
71
71
  ? {
72
72
  type,
@@ -91,12 +91,13 @@ async function createLocalExtension({ type, name, targetDir, targetPath, languag
91
91
  }
92
92
  function getPackageManifest(name, options, deps) {
93
93
  const packageManifest = {
94
- name: EXTENSION_NAME_REGEX.test(name) ? name : `directus-extension-${name}`,
94
+ name: name,
95
95
  description: 'Please enter a description for your extension',
96
96
  icon: 'extension',
97
97
  version: '1.0.0',
98
- keywords: ['directus', 'directus-extension', `directus-custom-${options.type}`],
98
+ keywords: ['directus', 'directus-extension', `directus-extension-${options.type}`],
99
99
  type: 'module',
100
+ files: ['dist'],
100
101
  [EXTENSION_PKG_KEY]: options,
101
102
  scripts: {
102
103
  build: 'directus-extension build',
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Last release with known breaking changes to the Extensions SDK and it's output.
3
+ * This will be used as the default value for the `host` manifest field in created extensions
4
+ */
5
+ export declare const LAST_BREAKING_RELEASE = "10.10.0";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Last release with known breaking changes to the Extensions SDK and it's output.
3
+ * This will be used as the default value for the `host` manifest field in created extensions
4
+ */
5
+ export const LAST_BREAKING_RELEASE = '10.10.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/extensions-sdk",
3
- "version": "10.3.4",
3
+ "version": "11.0.1",
4
4
  "description": "A toolkit to develop extensions to extend Directus",
5
5
  "homepage": "https://directus.io",
6
6
  "repository": {
@@ -44,20 +44,20 @@
44
44
  "rollup-plugin-esbuild": "5.0.0",
45
45
  "rollup-plugin-styles": "4.0.0",
46
46
  "vite": "4.5.2",
47
- "vue": "3.4.19",
47
+ "vue": "3.4.21",
48
+ "@directus/composables": "10.1.11",
48
49
  "@directus/constants": "11.0.3",
49
- "@directus/composables": "10.1.10",
50
- "@directus/extensions": "0.3.3",
51
- "@directus/themes": "0.3.4",
52
- "@directus/types": "11.0.6",
53
- "@directus/utils": "11.0.5"
50
+ "@directus/themes": "0.3.5",
51
+ "@directus/extensions": "1.0.1",
52
+ "@directus/types": "11.0.7",
53
+ "@directus/utils": "11.0.6"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/fs-extra": "11.0.4",
57
57
  "@types/inquirer": "9.0.7",
58
58
  "@vitest/coverage-v8": "1.3.1",
59
59
  "typescript": "5.3.3",
60
- "vitest": "1.3.0",
60
+ "vitest": "1.3.1",
61
61
  "@directus/tsconfig": "1.0.1"
62
62
  },
63
63
  "engines": {