@directus/extensions-sdk 9.25.0 → 9.25.2

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.
package/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import './dist/esm/cli/run.js';
2
+ import './dist/cli/run.js';
@@ -1,25 +1,34 @@
1
1
  import { API_SHARED_DEPS, APP_EXTENSION_TYPES, APP_SHARED_DEPS, EXTENSION_PKG_KEY, EXTENSION_TYPES, ExtensionManifest, ExtensionOptionsBundleEntries, HYBRID_EXTENSION_TYPES, } from '@directus/constants';
2
2
  import { isIn, isTypeIn } from '@directus/utils';
3
- import commonjs from '@rollup/plugin-commonjs';
4
- import json from '@rollup/plugin-json';
3
+ import commonjsDefault from '@rollup/plugin-commonjs';
4
+ import jsonDefault from '@rollup/plugin-json';
5
5
  import { nodeResolve } from '@rollup/plugin-node-resolve';
6
- import replace from '@rollup/plugin-replace';
7
- import terser from '@rollup/plugin-terser';
8
- import virtual from '@rollup/plugin-virtual';
6
+ import replaceDefault from '@rollup/plugin-replace';
7
+ import terserDefault from '@rollup/plugin-terser';
8
+ import virtualDefault from '@rollup/plugin-virtual';
9
9
  import chalk from 'chalk';
10
10
  import fse from 'fs-extra';
11
11
  import ora from 'ora';
12
12
  import path from 'path';
13
13
  import { rollup, watch as rollupWatch, } from 'rollup';
14
- import esbuild from 'rollup-plugin-esbuild';
15
- import styles from 'rollup-plugin-styles';
16
- import vue from 'rollup-plugin-vue';
14
+ import esbuildDefault from 'rollup-plugin-esbuild';
15
+ import stylesDefault from 'rollup-plugin-styles';
16
+ import vueDefault from 'rollup-plugin-vue';
17
17
  import { getLanguageFromPath, isLanguage } from '../utils/languages.js';
18
18
  import { clear, log } from '../utils/logger.js';
19
19
  import tryParseJson from '../utils/try-parse-json.js';
20
20
  import generateBundleEntrypoint from './helpers/generate-bundle-entrypoint.js';
21
21
  import loadConfig from './helpers/load-config.js';
22
22
  import { validateSplitEntrypointOption } from './helpers/validate-cli-options.js';
23
+ // Workaround for https://github.com/rollup/plugins/issues/1329
24
+ const virtual = virtualDefault;
25
+ const vue = vueDefault;
26
+ const esbuild = esbuildDefault;
27
+ const styles = stylesDefault;
28
+ const commonjs = commonjsDefault;
29
+ const json = jsonDefault;
30
+ const replace = replaceDefault;
31
+ const terser = terserDefault;
23
32
  export default async function build(options) {
24
33
  const watch = options.watch ?? false;
25
34
  const sourcemap = options.sourcemap ?? false;
@@ -385,21 +394,21 @@ function getRollupOptions({ mode, input, language, sourcemap, minify, plugins, }
385
394
  input: typeof input !== 'string' ? 'entry' : input,
386
395
  external: mode === 'browser' ? APP_SHARED_DEPS : API_SHARED_DEPS,
387
396
  plugins: [
388
- typeof input !== 'string' ? virtual.default(input) : null,
389
- mode === 'browser' ? vue.default({ preprocessStyles: true }) : null,
390
- languages.includes('typescript') ? esbuild.default({ include: /\.tsx?$/, sourceMap: sourcemap }) : null,
391
- mode === 'browser' ? styles.default() : null,
397
+ typeof input !== 'string' ? virtual(input) : null,
398
+ mode === 'browser' ? vue({ preprocessStyles: true }) : null,
399
+ languages.includes('typescript') ? esbuild({ include: /\.tsx?$/, sourceMap: sourcemap }) : null,
400
+ mode === 'browser' ? styles() : null,
392
401
  ...plugins,
393
402
  nodeResolve({ browser: mode === 'browser' }),
394
- commonjs.default({ esmExternals: mode === 'browser', sourceMap: sourcemap }),
395
- json.default(),
396
- replace.default({
403
+ commonjs({ esmExternals: mode === 'browser', sourceMap: sourcemap }),
404
+ json(),
405
+ replace({
397
406
  values: {
398
407
  'process.env.NODE_ENV': JSON.stringify('production'),
399
408
  },
400
409
  preventAssignment: true,
401
410
  }),
402
- minify ? terser.default() : null,
411
+ minify ? terser() : null,
403
412
  ],
404
413
  };
405
414
  }
@@ -1,2 +1,3 @@
1
1
  import type { Config } from '../../types.js';
2
+ export declare const CONFIG_FILE_NAMES: string[];
2
3
  export default function loadConfig(): Promise<Config>;
@@ -1,9 +1,11 @@
1
1
  import { pathToRelativeUrl } from '@directus/utils/node';
2
2
  import fse from 'fs-extra';
3
3
  import path from 'path';
4
- const CONFIG_FILE_NAMES = ['extension.config.js', 'extension.config.mjs', 'extension.config.cjs'];
4
+ import { fileURLToPath } from 'url';
5
+ export const CONFIG_FILE_NAMES = ['extension.config.js', 'extension.config.mjs', 'extension.config.cjs'];
5
6
  // This is needed to work around Typescript always transpiling import() to require() for CommonJS targets.
6
7
  const _import = new Function('url', 'return import(url)');
8
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
9
  export default async function loadConfig() {
8
10
  for (const fileName of CONFIG_FILE_NAMES) {
9
11
  if (await fse.pathExists(fileName)) {
package/dist/cli/run.js CHANGED
@@ -3,10 +3,10 @@ import add from './commands/add.js';
3
3
  import build from './commands/build.js';
4
4
  import create from './commands/create.js';
5
5
  import link from './commands/link.js';
6
- const pkg = require('../../../package.json');
6
+ import getSdkVersion from './utils/get-sdk-version.js';
7
7
  const program = new Command();
8
8
  program.name('directus-extension').usage('[command] [options]');
9
- program.version(pkg.version, '-v, --version');
9
+ program.version(getSdkVersion(), '-v, --version');
10
10
  program
11
11
  .command('create')
12
12
  .arguments('<type> <name>')
@@ -1,8 +1,7 @@
1
- import { dirname } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { resolve } from 'node:path';
4
1
  import { readFileSync } from 'node:fs';
5
- const pkg = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../../../package.json'), 'utf8'));
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const pkg = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../../package.json'), 'utf8'));
6
5
  export default function getSdkVersion() {
7
6
  return pkg.version;
8
7
  }
@@ -1,4 +1,5 @@
1
- import path from 'path';
1
+ import { dirname, resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
2
3
  export default function getTemplatePath() {
3
- return path.resolve(__dirname, '..', '..', '..', '..', 'templates');
4
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'templates');
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/extensions-sdk",
3
- "version": "9.25.0",
3
+ "version": "9.25.2",
4
4
  "description": "A toolkit to develop extensions to extend Directus",
5
5
  "homepage": "https://directus.io",
6
6
  "type": "module",
@@ -20,21 +20,20 @@
20
20
  "./package.json": "./package.json"
21
21
  },
22
22
  "main": "dist/index.js",
23
- "types": "dist/index.d.ts",
24
23
  "bin": {
25
24
  "directus-extension": "cli.js"
26
25
  },
27
26
  "files": [
28
27
  "dist",
29
28
  "templates",
30
- "!**/*.d.ts.map"
29
+ "!**/*.test.{js,d.ts}"
31
30
  ],
32
31
  "dependencies": {
33
- "@rollup/plugin-commonjs": "23.0.4",
32
+ "@rollup/plugin-commonjs": "24.1.0",
34
33
  "@rollup/plugin-json": "6.0.0",
35
34
  "@rollup/plugin-node-resolve": "15.0.1",
36
35
  "@rollup/plugin-replace": "5.0.2",
37
- "@rollup/plugin-terser": "0.4.0",
36
+ "@rollup/plugin-terser": "0.4.1",
38
37
  "@rollup/plugin-virtual": "3.0.1",
39
38
  "@vue/compiler-sfc": "3.2.47",
40
39
  "chalk": "4.1.2",
@@ -48,10 +47,10 @@
48
47
  "rollup-plugin-esbuild": "5.0.0",
49
48
  "rollup-plugin-styles": "4.0.0",
50
49
  "rollup-plugin-vue": "6.0.0",
51
- "@directus/composables": "9.25.0",
52
- "@directus/constants": "9.25.0",
53
- "@directus/types": "9.25.0",
54
- "@directus/utils": "9.25.0"
50
+ "@directus/composables": "9.25.2",
51
+ "@directus/constants": "9.25.2",
52
+ "@directus/types": "9.25.2",
53
+ "@directus/utils": "9.25.2"
55
54
  },
56
55
  "devDependencies": {
57
56
  "@directus/tsconfig": "0.0.6",
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { afterEach, expect, test } from 'vitest';
2
- import getPackageManagerAgent from './get-package-manager-agent.js';
3
- const envCopy = { ...process.env };
4
- afterEach(() => {
5
- process.env = envCopy;
6
- });
7
- test('Returns null if user agent cannot be extracted from env', () => {
8
- delete process.env['npm_config_user_agent'];
9
- expect(getPackageManagerAgent()).toBe(null);
10
- });
11
- test('Returns information object from parsed user agent', () => {
12
- process.env['npm_config_user_agent'] = 'pnpm/7.16.0 npm/? node/v18.12.1 darwin arm64';
13
- expect(getPackageManagerAgent()).toStrictEqual({
14
- node: 'v18.12.1',
15
- npm: '?',
16
- os: 'darwin (arm64)',
17
- pnpm: '7.16.0',
18
- });
19
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import { afterEach, expect, test, vi } from 'vitest';
2
- import getPackageManagerAgent from './get-package-manager-agent.js';
3
- import getPackageManager from './get-package-manager.js';
4
- vi.mock('./get-package-manager-agent');
5
- afterEach(() => {
6
- vi.clearAllMocks();
7
- });
8
- test('Returns npm is agent data is unavailable', () => {
9
- vi.mocked(getPackageManagerAgent).mockReturnValueOnce(null);
10
- expect(getPackageManager()).toBe('npm');
11
- });
12
- test('Returns pnpm if pnpm exists in agent and is not ?', () => {
13
- vi.mocked(getPackageManagerAgent).mockReturnValueOnce({
14
- node: 'v18.12.1',
15
- npm: '?',
16
- os: 'darwin (arm64)',
17
- pnpm: '7.16.0',
18
- });
19
- expect(getPackageManager()).toBe('pnpm');
20
- });
21
- test('Returns yarn if yarn exists in agent and is not ?', () => {
22
- vi.mocked(getPackageManagerAgent).mockReturnValueOnce({
23
- node: 'v18.12.1',
24
- npm: '?',
25
- os: 'darwin (arm64)',
26
- yarn: '2',
27
- });
28
- expect(getPackageManager()).toBe('yarn');
29
- });
30
- test('Returns npm is neither pnpm or yarn exist', () => {
31
- vi.mocked(getPackageManagerAgent).mockReturnValueOnce({
32
- node: 'v18.12.1',
33
- npm: '8.19.2',
34
- os: 'darwin (arm64)',
35
- });
36
- expect(getPackageManager()).toBe('npm');
37
- });