@attributech/nuxt-drupal-utils 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @attributech/nuxt-drupal-utils
2
2
 
3
+ [![Tests](https://github.com/attributech/nuxt-drupal-utils/actions/workflows/tests.yml/badge.svg)](https://github.com/attributech/nuxt-drupal-utils/actions/workflows/tests.yml)
4
+
3
5
  Shared utilities for Nuxt projects with Drupal backend.
4
6
 
5
7
  ## Installation
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,10 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ModuleOptions } from 'nuxt/schema';
3
+ export { getApiUrl } from '../dist/runtime/utils/getApiUrl.js';
4
+ export { getAppUrl } from '../dist/runtime/utils/getAppUrl.js';
5
+ export { getServerUrl } from '../dist/runtime/utils/getServerUrl.js';
6
+ export { getLagoonDevelopmentDomain } from '../dist/runtime/utils/getLagoonDevelopmentDomain.js';
7
+
8
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
9
+
10
+ export { _default as default };
package/dist/module.d.ts CHANGED
@@ -1,2 +1,10 @@
1
- declare const _default: import("@nuxt/schema").NuxtModule<any, any, false>;
2
- export default _default;
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ModuleOptions } from 'nuxt/schema';
3
+ export { getApiUrl } from '../dist/runtime/utils/getApiUrl.js';
4
+ export { getAppUrl } from '../dist/runtime/utils/getAppUrl.js';
5
+ export { getServerUrl } from '../dist/runtime/utils/getServerUrl.js';
6
+ export { getLagoonDevelopmentDomain } from '../dist/runtime/utils/getLagoonDevelopmentDomain.js';
7
+
8
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
9
+
10
+ export { _default as default };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@attributech/nuxt-drupal-utils",
3
+ "configKey": "drupalUtils",
4
+ "compatibility": {
5
+ "nuxt": "^2.16.0 || ^3.0.0"
6
+ },
7
+ "version": "0.1.0",
8
+ "builder": {
9
+ "@nuxt/module-builder": "0.8.4",
10
+ "unbuild": "2.0.0"
11
+ }
12
+ }
@@ -0,0 +1,25 @@
1
+ import { defineNuxtModule, createResolver, addPlugin, addImportsDir } from '@nuxt/kit';
2
+ export { getApiUrl } from '../dist/runtime/utils/getApiUrl.js';
3
+ export { getAppUrl } from '../dist/runtime/utils/getAppUrl.js';
4
+ export { getServerUrl } from '../dist/runtime/utils/getServerUrl.js';
5
+ export { getLagoonDevelopmentDomain } from '../dist/runtime/utils/getLagoonDevelopmentDomain.js';
6
+
7
+ const module = defineNuxtModule({
8
+ meta: {
9
+ name: "@attributech/nuxt-drupal-utils",
10
+ configKey: "drupalUtils",
11
+ compatibility: {
12
+ // Compatible with Nuxt 2.16+ (with Bridge) and Nuxt 3
13
+ nuxt: "^2.16.0 || ^3.0.0"
14
+ }
15
+ },
16
+ defaults: {},
17
+ setup(options, nuxt) {
18
+ const resolver = createResolver(import.meta.url);
19
+ addPlugin(resolver.resolve("./runtime/plugin"));
20
+ addImportsDir(resolver.resolve("./runtime/utils"));
21
+ nuxt.options.alias["#nuxt-drupal-utils/utils"] = resolver.resolve("./runtime/utils");
22
+ }
23
+ });
24
+
25
+ export { module as default };
@@ -1,12 +1,10 @@
1
- import getApiUrl from '../getApiUrl';
2
- import getAppUrl from '../getAppUrl';
3
- import getServerUrl from '../getServerUrl';
4
- import getLagoonDevelopmentDomain from '../getLagoonDevelopmentDomain';
5
- // Plugin works with both Nuxt 2 + Bridge and Nuxt 3
1
+ import { getApiUrl } from "./utils/getApiUrl.js";
2
+ import { getAppUrl } from "./utils/getAppUrl.js";
3
+ import { getServerUrl } from "./utils/getServerUrl.js";
4
+ import { getLagoonDevelopmentDomain } from "./utils/getLagoonDevelopmentDomain.js";
6
5
  export default (context, inject) => {
7
- // Inject utilities into the context
8
- inject('getApiUrl', getApiUrl);
9
- inject('getAppUrl', getAppUrl);
10
- inject('getServerUrl', getServerUrl);
11
- inject('getLagoonDevelopmentDomain', getLagoonDevelopmentDomain);
6
+ inject("getApiUrl", getApiUrl);
7
+ inject("getAppUrl", getAppUrl);
8
+ inject("getServerUrl", getServerUrl);
9
+ inject("getLagoonDevelopmentDomain", getLagoonDevelopmentDomain);
12
10
  };
@@ -0,0 +1 @@
1
+ export declare const getApiUrl: (defaultServerUrl: string) => string;
@@ -0,0 +1,5 @@
1
+ import { getServerUrl } from "./getServerUrl.js";
2
+ export const getApiUrl = function(defaultServerUrl) {
3
+ const serverUrl = getServerUrl(defaultServerUrl);
4
+ return `${serverUrl}/api`;
5
+ };
@@ -0,0 +1 @@
1
+ export declare const getAppUrl: (defaultUrl: string) => string;
@@ -0,0 +1,13 @@
1
+ import { getLagoonDevelopmentDomain } from "./getLagoonDevelopmentDomain.js";
2
+ export const getAppUrl = function(defaultUrl) {
3
+ if (process.env.APP_URL !== void 0 && process.env.APP_URL !== "") {
4
+ return process.env.APP_URL;
5
+ }
6
+ if (process.env.LAGOON_ENVIRONMENT_TYPE !== void 0 && process.env.LAGOON_ENVIRONMENT_TYPE === "development") {
7
+ const lagoonDevelopmentDomain = getLagoonDevelopmentDomain();
8
+ if (lagoonDevelopmentDomain !== null) {
9
+ return `https://frontend.${lagoonDevelopmentDomain}`;
10
+ }
11
+ }
12
+ return defaultUrl;
13
+ };
@@ -0,0 +1 @@
1
+ export declare const getLagoonDevelopmentDomain: () => string | null;
@@ -0,0 +1,6 @@
1
+ export const getLagoonDevelopmentDomain = function() {
2
+ if (process.env.LAGOON_ENVIRONMENT !== void 0 && process.env.LAGOON_PROJECT !== void 0 && process.env.LAGOON_KUBERNETES !== void 0) {
3
+ return `${process.env.LAGOON_ENVIRONMENT}.${process.env.LAGOON_PROJECT}.${process.env.LAGOON_KUBERNETES}`;
4
+ }
5
+ return null;
6
+ };
@@ -0,0 +1 @@
1
+ export declare const getServerUrl: (defaultUrl: string) => string;
@@ -0,0 +1,13 @@
1
+ import { getLagoonDevelopmentDomain } from "./getLagoonDevelopmentDomain.js";
2
+ export const getServerUrl = function(defaultUrl) {
3
+ if (process.env.API_SERVER !== void 0 && process.env.API_SERVER !== "") {
4
+ return process.env.API_SERVER;
5
+ }
6
+ if (process.env.LAGOON_ENVIRONMENT_TYPE !== void 0 && process.env.LAGOON_ENVIRONMENT_TYPE === "development") {
7
+ const lagoonDevelopmentDomain = getLagoonDevelopmentDomain();
8
+ if (lagoonDevelopmentDomain !== null) {
9
+ return `https://nginx.${lagoonDevelopmentDomain}`;
10
+ }
11
+ }
12
+ return defaultUrl;
13
+ };
@@ -0,0 +1,4 @@
1
+ export { getApiUrl } from "./getApiUrl.js";
2
+ export { getAppUrl } from "./getAppUrl.js";
3
+ export { getServerUrl } from "./getServerUrl.js";
4
+ export { getLagoonDevelopmentDomain } from "./getLagoonDevelopmentDomain.js";
@@ -0,0 +1,4 @@
1
+ export { getApiUrl } from "./getApiUrl.js";
2
+ export { getAppUrl } from "./getAppUrl.js";
3
+ export { getServerUrl } from "./getServerUrl.js";
4
+ export { getLagoonDevelopmentDomain } from "./getLagoonDevelopmentDomain.js";
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.js'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { type getApiUrl } from './module.js'
@@ -0,0 +1,7 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { type getApiUrl } from './module'
package/package.json CHANGED
@@ -1,30 +1,29 @@
1
1
  {
2
2
  "name": "@attributech/nuxt-drupal-utils",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Shared utilities for Nuxt 3 projects with Drupal backend",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
6
  "exports": {
9
7
  ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
12
- },
13
- "./module": {
14
- "import": "./dist/module.js",
8
+ "import": "./dist/module.mjs",
15
9
  "types": "./dist/module.d.ts"
16
10
  }
17
11
  },
12
+ "main": "./dist/module.mjs",
13
+ "types": "dist/types.d.ts",
18
14
  "files": [
19
15
  "dist"
20
16
  ],
21
17
  "scripts": {
22
- "build": "tsc",
23
- "prepublishOnly": "npm run build",
18
+ "build": "nuxt-module-build build",
19
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
20
+ "lint": "eslint .",
21
+ "lint:fix": "eslint . --fix",
24
22
  "test": "vitest run",
25
23
  "test:watch": "vitest",
26
24
  "test:coverage": "vitest run --coverage",
27
- "test:ui": "vitest --ui"
25
+ "test:ui": "vitest --ui",
26
+ "release": "release-it"
28
27
  },
29
28
  "keywords": [
30
29
  "nuxt",
@@ -40,16 +39,30 @@
40
39
  "@nuxt/kit": "^3.14.0"
41
40
  },
42
41
  "devDependencies": {
42
+ "@nuxt/eslint-config": "^1.1.0",
43
+ "@nuxt/module-builder": "^0.8.4",
43
44
  "@nuxt/types": "^2.16.0",
44
45
  "@types/node": "^20.11.0",
45
46
  "@vitest/coverage-v8": "^3.0.7",
46
47
  "@vitest/ui": "^3.0.7",
47
48
  "c8": "^10.1.3",
49
+ "eslint": "^9.21.0",
50
+ "eslint-plugin-vitest": "^0.5.4",
48
51
  "happy-dom": "^17.2.2",
52
+ "release-it": "^18.1.2",
49
53
  "typescript": "^5.6.3",
50
54
  "vitest": "^3.0.7"
51
55
  },
52
56
  "publishConfig": {
53
57
  "access": "public"
58
+ },
59
+ "engines": {
60
+ "node": ">=20.10.0"
61
+ },
62
+ "release-it": {
63
+ "$schema": "https://unpkg.com/release-it/schema/release-it.json",
64
+ "github": {
65
+ "release": true
66
+ }
54
67
  }
55
68
  }
@@ -1 +0,0 @@
1
- export default function (defaultServerUrl: string): string;
package/dist/getApiUrl.js DELETED
@@ -1,6 +0,0 @@
1
- import getServerUrl from './getServerUrl';
2
- // Provides a function to determin the API endpoint to use
3
- export default function (defaultServerUrl) {
4
- const serverUrl = getServerUrl(defaultServerUrl);
5
- return `${serverUrl}/api`;
6
- }
@@ -1 +0,0 @@
1
- export default function (defaultUrl: string): string;
package/dist/getAppUrl.js DELETED
@@ -1,17 +0,0 @@
1
- import getLagoonDevelopmentDomain from './getLagoonDevelopmentDomain';
2
- // Provides a function to determin the app url
3
- export default function (defaultUrl) {
4
- // Override app url in case APP_URL env variable is set
5
- if (process.env.APP_URL !== undefined && process.env.APP_URL !== '') {
6
- return process.env.APP_URL;
7
- }
8
- // Build app url in case we are on a lagoon development environment
9
- if (process.env.LAGOON_ENVIRONMENT_TYPE !== undefined &&
10
- process.env.LAGOON_ENVIRONMENT_TYPE === 'development') {
11
- const lagoonDevelopmentDomain = getLagoonDevelopmentDomain();
12
- if (lagoonDevelopmentDomain !== null) {
13
- return `https://frontend.${lagoonDevelopmentDomain}`;
14
- }
15
- }
16
- return defaultUrl;
17
- }
@@ -1 +0,0 @@
1
- export default function (): string | null;
@@ -1,9 +0,0 @@
1
- // Provides a function to build a lagoon domain for development enivronments
2
- export default function () {
3
- if (process.env.LAGOON_ENVIRONMENT !== undefined &&
4
- process.env.LAGOON_PROJECT !== undefined &&
5
- process.env.LAGOON_KUBERNETES !== undefined) {
6
- return `${process.env.LAGOON_ENVIRONMENT}.${process.env.LAGOON_PROJECT}.${process.env.LAGOON_KUBERNETES}`;
7
- }
8
- return null;
9
- }
@@ -1 +0,0 @@
1
- export default function (defaultUrl: string): string;
@@ -1,17 +0,0 @@
1
- import getLagoonDevelopmentDomain from './getLagoonDevelopmentDomain';
2
- // Provides a function to determine the API endpoint to use
3
- export default function (defaultUrl) {
4
- // Override API endpoint in case API_SERVER env variable is set
5
- if (process.env.API_SERVER !== undefined && process.env.API_SERVER !== '') {
6
- return process.env.API_SERVER;
7
- }
8
- // Set API endpoint to nginx service in case we are on lagoon and not in production
9
- if (process.env.LAGOON_ENVIRONMENT_TYPE !== undefined &&
10
- process.env.LAGOON_ENVIRONMENT_TYPE === 'development') {
11
- const lagoonDevelopmentDomain = getLagoonDevelopmentDomain();
12
- if (lagoonDevelopmentDomain !== null) {
13
- return `https://nginx.${lagoonDevelopmentDomain}`;
14
- }
15
- }
16
- return defaultUrl;
17
- }
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import getApiUrl from './getApiUrl';
2
- import getAppUrl from './getAppUrl';
3
- import getServerUrl from './getServerUrl';
4
- import getLagoonDevelopmentDomain from './getLagoonDevelopmentDomain';
5
- export { getApiUrl, getAppUrl, getServerUrl, getLagoonDevelopmentDomain };
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- import getApiUrl from './getApiUrl';
2
- import getAppUrl from './getAppUrl';
3
- import getServerUrl from './getServerUrl';
4
- import getLagoonDevelopmentDomain from './getLagoonDevelopmentDomain';
5
- export { getApiUrl, getAppUrl, getServerUrl, getLagoonDevelopmentDomain };
package/dist/module.js DELETED
@@ -1,17 +0,0 @@
1
- import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit';
2
- export default defineNuxtModule({
3
- meta: {
4
- name: '@attributech/nuxt-drupal-utils',
5
- configKey: 'drupalUtils',
6
- compatibility: {
7
- // Compatible with Nuxt 2.16+ (with Bridge) and Nuxt 3
8
- nuxt: '^2.16.0 || ^3.0.0'
9
- }
10
- },
11
- defaults: {},
12
- setup(options, nuxt) {
13
- const resolver = createResolver(import.meta.url);
14
- // Add plugin to make utilities available
15
- addPlugin(resolver.resolve('./runtime/plugin'));
16
- }
17
- });