@jee-r/astro-decap-cms 1.0.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
+ ## [1.1.0](https://github.com/jee-r/astro-decap-cms/compare/v1.0.0...v1.1.0) (2026-01-19)
2
+
3
+ ### Features
4
+
5
+ * **cache:** implement unpkg fetch and cache system ([4e667a2](https://github.com/jee-r/astro-decap-cms/commit/4e667a2bf0bb6e49fd3b2c4e3a8e6a02342c2ccd))
6
+ * **config:** add cmsVersion option for custom CMS versions ([7d11121](https://github.com/jee-r/astro-decap-cms/commit/7d111217c974b463682eb14f916339c865f4b272))
7
+
8
+ ### Bug Fixes
9
+
10
+ * **admin:** implement dynamic CMS loading with proper timing ([d9c0ee3](https://github.com/jee-r/astro-decap-cms/commit/d9c0ee3abdf4236921c117f5de87567a1d8fc5cd))
11
+ * **server:** use dynamic import instead of spawn for decap-server ([66f1c1d](https://github.com/jee-r/astro-decap-cms/commit/66f1c1d9a7859d2cd0ed4062f07f4269bfe54425))
12
+
13
+ ### Documentation
14
+
15
+ * add breaking change notice and cross-references ([4c040a6](https://github.com/jee-r/astro-decap-cms/commit/4c040a6907e1b7625a3890112161f83ea3410d83))
16
+ * **readme:** add cmsVersion option documentation ([6567400](https://github.com/jee-r/astro-decap-cms/commit/65674005151f1b952fa16760fab3638ce79367fa))
17
+
18
+ ### Chores
19
+
20
+ * **config:** update ignore files for npm package ([4abd232](https://github.com/jee-r/astro-decap-cms/commit/4abd2325519174d7c15090ee2d67e0df185dde8c))
21
+ * **config:** update TypeScript to ES2020 for import.meta support ([b7b5fb2](https://github.com/jee-r/astro-decap-cms/commit/b7b5fb28ca1d8a1d4450b1cb49850a761dd73eb2))
22
+ * **deps:** remove unused React and decap-cms-app dependencies ([429f2ce](https://github.com/jee-r/astro-decap-cms/commit/429f2cefffe0e484dc47cf247c0e1e5a492ad5d7))
23
+
24
+ ### Code Refactoring
25
+
26
+ * **types:** centralize types and add global declarations ([8d408e9](https://github.com/jee-r/astro-decap-cms/commit/8d408e9030f2cae5f84c3508bf65bda65d98123d))
27
+ * **vite:** implement unpkg-based CMS loading ([15ba88f](https://github.com/jee-r/astro-decap-cms/commit/15ba88f3707f0429fae37c75f8fe16925efe897e))
1
28
  ## [1.0.0](https://github.com/jee-r/astro-decap-cms/compare/v0.6.1...v1.0.0) (2026-01-18)
2
29
 
30
+ ### ⚠ BREAKING CHANGES
31
+
32
+ * **core:** The main export has been renamed from `NetlifyCMS` to `DecapCMS` to reflect the project's migration from Netlify CMS to Decap CMS. Users must update their imports:
33
+ ```diff
34
+ - import NetlifyCMS from '@jee-r/astro-decap-cms';
35
+ + import DecapCMS from '@jee-r/astro-decap-cms';
36
+ ```
37
+ The TypeScript interface has also been renamed from `NetlifyCMSOptions` to `DecapCMSOptions`. See the [README](./README.md#adding-the-integration) for updated usage examples.
38
+
3
39
  ### Features
4
40
 
5
41
  * add editorconfig and VSCode settings ([b72176f](https://github.com/jee-r/astro-decap-cms/commit/b72176f925aa7df5091ac735079e59e8dfa74d14))
package/README.md CHANGED
@@ -35,6 +35,8 @@ Usually each of these requires individual set up and configuration. Using this i
35
35
  To add Decap CMS to your project, import and use the integration in your
36
36
  Astro config file, adding it to the `integrations` array.
37
37
 
38
+ > **Note:** If you're upgrading from version 0.x, the integration has been renamed from `NetlifyCMS` to `DecapCMS`. See the [CHANGELOG](./CHANGELOG.md#100) for migration details.
39
+
38
40
  ```js
39
41
  // astro.config.mjs
40
42
 
@@ -71,6 +73,27 @@ Determines the route where the Decap CMS admin dashboard will be available on yo
71
73
 
72
74
  Feeling nostalgic for WordPress? You could set this to `'/wp-admin'`!
73
75
 
76
+ #### `cmsVersion`
77
+
78
+ **Type:** `string`
79
+ **Default:** `'3.10.0'`
80
+
81
+ Specifies which version of Decap CMS to use. The CMS is automatically fetched from unpkg and cached locally for optimal performance.
82
+
83
+ Supports:
84
+ - Exact versions: `'3.10.0'`
85
+ - Semver ranges: `'^3.0.0'`
86
+ - Latest: `'latest'`
87
+
88
+ ```js
89
+ DecapCMS({
90
+ cmsVersion: '^3.0.0', // Use latest 3.x version
91
+ config: { /* ... */ }
92
+ })
93
+ ```
94
+
95
+ The CMS file is automatically cached in `node_modules/.cache/` after the first build, enabling offline development and faster subsequent builds.
96
+
74
97
  #### `config`
75
98
 
76
99
  **Type:** `CmsConfig`
@@ -9,10 +9,25 @@
9
9
  content="Admin dashboard for managing website content"
10
10
  />
11
11
  <title>Content Manager</title>
12
+ <script is:inline>window.CMS_MANUAL_INIT = true;</script>
12
13
  <script>
13
14
  import options from 'virtual:astro-decap-cms/user-config';
14
15
  import initCMS from './dist/cms';
15
- initCMS(options);
16
+
17
+ // Wait for decap-cms.js to load
18
+ const script = document.createElement('script');
19
+ script.src = '/_decap-cms/decap-cms.js';
20
+ script.onload = () => {
21
+ if (window.CMS) {
22
+ initCMS({ cms: window.CMS, ...options });
23
+ } else {
24
+ console.error('DecapCMS failed to load');
25
+ }
26
+ };
27
+ script.onerror = () => {
28
+ console.error('Failed to load DecapCMS script');
29
+ };
30
+ document.head.appendChild(script);
16
31
  </script>
17
32
  <style is:global>
18
33
  /* Workaround for https://github.com/netlify/netlify-cms/issues/5092 */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Get or fetch decap-cms.js from cache
3
+ * @param rootDir - The root directory of the user's project (from Vite config)
4
+ * @param version - The version to fetch (e.g., '3.10.0', '^3.0.0', 'latest')
5
+ */
6
+ export declare function getDecapCmsJs(rootDir: string, version: string): Promise<string>;
7
+ /**
8
+ * Resolve version (supports 'latest', semver ranges, exact versions)
9
+ * For now, we just use the provided version as-is and let unpkg resolve it
10
+ */
11
+ export declare function resolveVersion(version?: string): string;
package/dist/cache.js ADDED
@@ -0,0 +1,62 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ /**
4
+ * Get the cache directory path in the user's project
5
+ * Uses node_modules/.cache/@jee-r/astro-decap-cms/
6
+ */
7
+ function getCacheDir(rootDir) {
8
+ return join(rootDir, 'node_modules', '.cache', '@jee-r', 'astro-decap-cms');
9
+ }
10
+ /**
11
+ * Generate cache filename based on version
12
+ */
13
+ function getCacheFilename(version) {
14
+ return `decap-cms-${version}.js`;
15
+ }
16
+ /**
17
+ * Fetch decap-cms.js from unpkg
18
+ */
19
+ async function fetchFromUnpkg(version) {
20
+ const url = `https://unpkg.com/decap-cms@${version}/dist/decap-cms.js`;
21
+ console.log(`📦 Fetching Decap CMS ${version} from unpkg...`);
22
+ const response = await fetch(url);
23
+ if (!response.ok) {
24
+ throw new Error(`Failed to fetch decap-cms@${version} from unpkg: ${response.status} ${response.statusText}`);
25
+ }
26
+ const content = await response.text();
27
+ console.log(`✓ Downloaded decap-cms.js (${(content.length / 1024 / 1024).toFixed(2)} MB)`);
28
+ return content;
29
+ }
30
+ /**
31
+ * Get or fetch decap-cms.js from cache
32
+ * @param rootDir - The root directory of the user's project (from Vite config)
33
+ * @param version - The version to fetch (e.g., '3.10.0', '^3.0.0', 'latest')
34
+ */
35
+ export async function getDecapCmsJs(rootDir, version) {
36
+ const cacheDir = getCacheDir(rootDir);
37
+ const filename = getCacheFilename(version);
38
+ const cachePath = join(cacheDir, filename);
39
+ // Check if already cached
40
+ if (existsSync(cachePath)) {
41
+ console.log(`✓ Using cached Decap CMS ${version}`);
42
+ return readFileSync(cachePath, 'utf-8');
43
+ }
44
+ // Fetch from unpkg
45
+ const content = await fetchFromUnpkg(version);
46
+ // Save to cache
47
+ mkdirSync(cacheDir, { recursive: true });
48
+ writeFileSync(cachePath, content, 'utf-8');
49
+ console.log(`✓ Cached to ${cachePath}`);
50
+ return content;
51
+ }
52
+ /**
53
+ * Resolve version (supports 'latest', semver ranges, exact versions)
54
+ * For now, we just use the provided version as-is and let unpkg resolve it
55
+ */
56
+ export function resolveVersion(version) {
57
+ // If no version specified, use a safe default
58
+ if (!version) {
59
+ return '3.10.0';
60
+ }
61
+ return version;
62
+ }
package/dist/cms.js CHANGED
@@ -4,11 +4,14 @@ export default function initCMS({ cms, config, previewStyles = [], }) {
4
4
  ? { media_folder: 'public', public_folder: '/' }
5
5
  : {};
6
6
  cms.init({
7
- config: Object.assign(Object.assign({
7
+ config: {
8
8
  // Don’t try to load config.yml as we’re providing the config below
9
- load_config_file: false,
9
+ load_config_file: false,
10
10
  // Enable use of the Netlify CMS proxy server when working locally
11
- local_backend: true }, mediaDefaults), config),
11
+ local_backend: true,
12
+ ...mediaDefaults,
13
+ ...config,
14
+ },
12
15
  });
13
16
  /**
14
17
  * One drawback of using Netlify CMS is that it registers all preview
package/dist/index.d.ts CHANGED
@@ -1,21 +1,10 @@
1
1
  import type { AstroIntegration } from 'astro';
2
- import type { CmsConfig } from 'decap-cms-core';
3
- import type { PreviewStyle } from './types.js';
4
- interface DecapCMSOptions {
5
- /**
6
- * Path at which the Decap CMS admin dashboard should be served.
7
- * @default '/admin'
8
- */
9
- adminPath?: string;
10
- config: Omit<CmsConfig, 'load_config_file' | 'local_backend'>;
11
- disableIdentityWidgetInjection?: boolean;
12
- previewStyles?: PreviewStyle[];
13
- }
2
+ import type { DecapCMSOptions } from './types.js';
3
+ export type { DecapCMSOptions, CmsConfig, CMS } from './types.js';
14
4
  /**
15
5
  * Creates an Astro integration for Decap CMS.
16
6
  *
17
7
  * @param options - Configuration options for the Decap CMS integration
18
8
  * @returns An Astro integration that adds Decap CMS to your project
19
9
  */
20
- export default function DecapCMS({ disableIdentityWidgetInjection, adminPath, config: cmsConfig, previewStyles, }: DecapCMSOptions): AstroIntegration;
21
- export {};
10
+ export default function DecapCMS({ disableIdentityWidgetInjection, adminPath, cmsVersion, config: cmsConfig, previewStyles, }: DecapCMSOptions): AstroIntegration;
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { spawn } from 'node:child_process';
2
1
  import AdminDashboard from './vite-plugin-admin-dashboard.js';
3
2
  const widgetPath = '@jee-r/astro-decap-cms/identity-widget';
4
3
  /**
@@ -7,14 +6,13 @@ const widgetPath = '@jee-r/astro-decap-cms/identity-widget';
7
6
  * @param options - Configuration options for the Decap CMS integration
8
7
  * @returns An Astro integration that adds Decap CMS to your project
9
8
  */
10
- export default function DecapCMS({ disableIdentityWidgetInjection = false, adminPath = '/admin', config: cmsConfig, previewStyles = [], }) {
9
+ export default function DecapCMS({ disableIdentityWidgetInjection = false, adminPath = '/admin', cmsVersion = '3.10.0', config: cmsConfig, previewStyles = [], }) {
11
10
  if (!adminPath.startsWith('/')) {
12
11
  throw new Error(`'adminPath' option must be a root-relative pathname, starting with "/", got "${adminPath}"`);
13
12
  }
14
13
  if (adminPath.endsWith('/')) {
15
14
  adminPath = adminPath.slice(0, -1);
16
15
  }
17
- let proxy;
18
16
  const DecapCMSIntegration = {
19
17
  name: 'decap-cms',
20
18
  hooks: {
@@ -27,6 +25,7 @@ export default function DecapCMS({ disableIdentityWidgetInjection = false, admin
27
25
  vite: {
28
26
  plugins: [
29
27
  AdminDashboard({
28
+ cmsVersion,
30
29
  config: cmsConfig,
31
30
  previewStyles,
32
31
  identityWidget: disableIdentityWidgetInjection
@@ -45,15 +44,8 @@ export default function DecapCMS({ disableIdentityWidgetInjection = false, admin
45
44
  }
46
45
  },
47
46
  'astro:server:start': () => {
48
- proxy = spawn('decap-server', {
49
- stdio: 'inherit',
50
- // Run in shell on Windows to make sure the npm package can be found.
51
- shell: process.platform === 'win32',
52
- });
53
- process.on('exit', () => proxy.kill());
54
- },
55
- 'astro:server:done': () => {
56
- proxy.kill();
47
+ // @ts-ignore - Import decap-server to start the proxy server
48
+ import('decap-server');
57
49
  },
58
50
  },
59
51
  };
package/dist/types.d.ts CHANGED
@@ -1,11 +1,27 @@
1
- import type CMS from 'decap-cms-app';
2
- import type { CmsConfig } from 'decap-cms-core';
1
+ import type { CmsConfig, CMS } from 'decap-cms-core';
2
+ export type { CmsConfig, CMS };
3
3
  export type NormalizedPreviewStyle = [pathOrUrl: string] | [rawCSS: string, meta: {
4
4
  raw: boolean;
5
5
  }];
6
6
  export type PreviewStyle = string | NormalizedPreviewStyle;
7
7
  export interface InitCmsOptions {
8
- cms: typeof CMS;
8
+ cms: CMS;
9
9
  config: CmsConfig;
10
10
  previewStyles?: NormalizedPreviewStyle[];
11
11
  }
12
+ export interface DecapCMSOptions {
13
+ /**
14
+ * Path at which the Decap CMS admin dashboard should be served.
15
+ * @default '/admin'
16
+ */
17
+ adminPath?: string;
18
+ /**
19
+ * Version of Decap CMS to use.
20
+ * Supports exact versions ('3.10.0'), semver ranges ('^3.0.0'), or 'latest'.
21
+ * @default '3.10.0'
22
+ */
23
+ cmsVersion?: string;
24
+ config: Omit<CmsConfig, 'load_config_file' | 'local_backend'>;
25
+ disableIdentityWidgetInjection?: boolean;
26
+ previewStyles?: PreviewStyle[];
27
+ }
@@ -1,7 +1,8 @@
1
1
  import type { CmsConfig } from 'decap-cms-core';
2
2
  import type { Plugin } from 'vite';
3
3
  import type { PreviewStyle } from './types';
4
- export default function AdminDashboardPlugin({ config, previewStyles, identityWidget, }: {
4
+ export default function AdminDashboardPlugin({ cmsVersion, config, previewStyles, identityWidget, }: {
5
+ cmsVersion: string;
5
6
  config: Omit<CmsConfig, 'load_config_file' | 'local_backend'>;
6
7
  previewStyles: PreviewStyle[];
7
8
  identityWidget: string;
@@ -1,3 +1,4 @@
1
+ import { getDecapCmsJs, resolveVersion } from './cache.js';
1
2
  const virtualModuleId = 'virtual:astro-decap-cms/user-config';
2
3
  const resolvedVirtualModuleId = '\0' + virtualModuleId;
3
4
  function generateVirtualConfigModule({ config, previewStyles = [], identityWidget, }) {
@@ -7,7 +8,7 @@ function generateVirtualConfigModule({ config, previewStyles = [], identityWidge
7
8
  if (!Array.isArray(entry))
8
9
  entry = [entry];
9
10
  const [style, opts] = entry;
10
- if ((opts === null || opts === void 0 ? void 0 : opts.raw) || style.startsWith('http')) {
11
+ if (opts?.raw || style.startsWith('http')) {
11
12
  styles.push(JSON.stringify([style, opts]));
12
13
  }
13
14
  else {
@@ -17,23 +18,62 @@ function generateVirtualConfigModule({ config, previewStyles = [], identityWidge
17
18
  }
18
19
  });
19
20
  return `${imports.join('\n')}
20
- import CMS from 'decap-cms-app';
21
21
  ${identityWidget}
22
22
  export default {
23
- cms: CMS,
24
23
  config: JSON.parse('${JSON.stringify(config)}'),
25
24
  previewStyles: [${styles.join(',')}],
26
25
  };
27
26
  `;
28
27
  }
29
- export default function AdminDashboardPlugin({ config, previewStyles, identityWidget, }) {
28
+ export default function AdminDashboardPlugin({ cmsVersion, config, previewStyles, identityWidget, }) {
29
+ const version = resolveVersion(cmsVersion);
30
+ let decapCmsContent;
31
+ let rootDir;
30
32
  return {
31
33
  name: 'vite-plugin-decap-cms-admin-dashboard',
34
+ config(_, { command }) {
35
+ // Dynamically set local_backend based on dev/build mode
36
+ config.local_backend = command === 'serve';
37
+ // Don't try to load config.yml
38
+ config.load_config_file = false;
39
+ },
40
+ configResolved(resolvedConfig) {
41
+ // Get the root directory of the user's project
42
+ rootDir = resolvedConfig.root;
43
+ },
44
+ async buildStart() {
45
+ // Fetch/cache the decap-cms.js file at build start
46
+ if (!decapCmsContent) {
47
+ decapCmsContent = await getDecapCmsJs(rootDir, version);
48
+ }
49
+ },
50
+ async configureServer(server) {
51
+ // Fetch/cache the decap-cms.js file on server start
52
+ if (!decapCmsContent) {
53
+ decapCmsContent = await getDecapCmsJs(rootDir, version);
54
+ }
55
+ // Serve it at /_decap-cms/decap-cms.js
56
+ server.middlewares.use('/_decap-cms/decap-cms.js', (_req, res) => {
57
+ res.setHeader('Content-Type', 'application/javascript');
58
+ res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
59
+ res.end(decapCmsContent);
60
+ });
61
+ },
32
62
  resolveId(id) {
63
+ if (id === '/_decap-cms/decap-cms.js') {
64
+ return id;
65
+ }
33
66
  if (id === virtualModuleId)
34
67
  return resolvedVirtualModuleId;
35
68
  },
36
- load(id) {
69
+ async load(id) {
70
+ if (id === '/_decap-cms/decap-cms.js') {
71
+ // Return the cached content for build
72
+ if (!decapCmsContent) {
73
+ decapCmsContent = await getDecapCmsJs(rootDir, version);
74
+ }
75
+ return decapCmsContent;
76
+ }
37
77
  if (id === resolvedVirtualModuleId)
38
78
  return generateVirtualConfigModule({
39
79
  config,
@@ -41,5 +81,16 @@ export default function AdminDashboardPlugin({ config, previewStyles, identityWi
41
81
  identityWidget,
42
82
  });
43
83
  },
84
+ async generateBundle() {
85
+ // Emit the decap-cms.js file as a static asset during build
86
+ if (!decapCmsContent) {
87
+ decapCmsContent = await getDecapCmsJs(rootDir, version);
88
+ }
89
+ this.emitFile({
90
+ type: 'asset',
91
+ fileName: '_decap-cms/decap-cms.js',
92
+ source: decapCmsContent,
93
+ });
94
+ },
44
95
  };
45
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jee-r/astro-decap-cms",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Add Decap CMS’s admin dashboard to your Astro project",
5
5
  "repository": "jee-r/astro-decap-cms",
6
6
  "homepage": "https://github.com/jee-r/astro-decap-cms",
@@ -35,12 +35,8 @@
35
35
  "netlify-cms"
36
36
  ],
37
37
  "dependencies": {
38
- "@types/react": "^19.1.0",
39
- "decap-cms-app": "^3.10.0",
40
38
  "decap-server": "^3.5.0",
41
- "netlify-identity-widget": "^1.9.2",
42
- "react": "^19.1.0",
43
- "react-dom": "^19.1.0"
39
+ "netlify-identity-widget": "^1.9.2"
44
40
  },
45
41
  "peerDependencies": {
46
42
  "astro": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
@@ -53,6 +49,7 @@
53
49
  "astro": "^5.16.11",
54
50
  "conventional-changelog-cli": "^5.0.0",
55
51
  "conventional-changelog-conventionalcommits": "^9.1.0",
52
+ "decap-cms-core": "^3.10.0",
56
53
  "typescript": "^5.7.2",
57
54
  "vite": "^6.4.1"
58
55
  },
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- indent_size = 2
7
- indent_style = tab
8
- insert_final_newline = false
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- indent_style = space
13
- insert_final_newline = true
@@ -1,36 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- # Automatically cancel in-progress actions on the same branch
10
- concurrency:
11
- group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
12
- cancel-in-progress: true
13
-
14
- jobs:
15
- test:
16
- runs-on: ubuntu-latest
17
- steps:
18
- - name: Checkout
19
- uses: actions/checkout@v4
20
-
21
- - name: Install pnpm
22
- uses: pnpm/action-setup@v4
23
- with:
24
- version: 10
25
-
26
- - name: Setup Node.js 20.x
27
- uses: actions/setup-node@v4
28
- with:
29
- node-version: 20.x
30
- cache: 'pnpm'
31
-
32
- - name: Install Dependencies
33
- run: pnpm install --frozen-lockfile
34
-
35
- - name: Test
36
- run: pnpm test
@@ -1,117 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- tags:
6
- - 'v*'
7
-
8
- permissions:
9
- contents: write
10
- packages: write
11
-
12
- jobs:
13
- release:
14
- name: Create Release
15
- runs-on: ubuntu-latest
16
- steps:
17
- - name: Checkout
18
- uses: actions/checkout@v4
19
-
20
- - name: Install pnpm
21
- uses: pnpm/action-setup@v4
22
- with:
23
- version: 10
24
-
25
- - name: Setup Node.js
26
- uses: actions/setup-node@v4
27
- with:
28
- node-version: 20.x
29
- cache: 'pnpm'
30
-
31
- - name: Install Dependencies
32
- run: pnpm install --frozen-lockfile
33
-
34
- - name: Build
35
- run: pnpm run build
36
-
37
- - name: Generate Changelog
38
- run: pnpm exec conventional-changelog --config ./changelog-config.mjs -r 2 > RELEASE_NOTES.md
39
-
40
- - name: Create GitHub Release
41
- uses: softprops/action-gh-release@v2
42
- with:
43
- body_path: RELEASE_NOTES.md
44
- draft: false
45
- prerelease: false
46
- env:
47
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
-
49
- publish-npm:
50
- name: Publish to npm
51
- runs-on: ubuntu-latest
52
- needs: release
53
- permissions:
54
- id-token: write
55
- contents: read
56
- steps:
57
- - name: Checkout
58
- uses: actions/checkout@v4
59
-
60
- - name: Install pnpm
61
- uses: pnpm/action-setup@v4
62
- with:
63
- version: 10
64
-
65
- - name: Setup Node.js
66
- uses: actions/setup-node@v4
67
- with:
68
- node-version: 20.x
69
- cache: 'pnpm'
70
- registry-url: 'https://registry.npmjs.org'
71
-
72
- - name: Install Dependencies
73
- run: pnpm install --frozen-lockfile
74
-
75
- - name: Build
76
- run: pnpm run build
77
-
78
- - name: Update npm to latest for OIDC support
79
- run: npm install -g npm@latest
80
-
81
- - name: Publish to npm (Trusted Publishing)
82
- run: npm publish --provenance
83
-
84
- publish-gpr:
85
- name: Publish to GitHub Packages
86
- runs-on: ubuntu-latest
87
- needs: release
88
- permissions:
89
- packages: write
90
- contents: read
91
- steps:
92
- - name: Checkout
93
- uses: actions/checkout@v4
94
-
95
- - name: Install pnpm
96
- uses: pnpm/action-setup@v4
97
- with:
98
- version: 10
99
-
100
- - name: Setup Node.js
101
- uses: actions/setup-node@v4
102
- with:
103
- node-version: 20.x
104
- cache: 'pnpm'
105
- registry-url: 'https://npm.pkg.github.com'
106
- scope: '@jee-r'
107
-
108
- - name: Install Dependencies
109
- run: pnpm install --frozen-lockfile
110
-
111
- - name: Build
112
- run: pnpm run build
113
-
114
- - name: Publish to GitHub Packages
115
- run: pnpm publish --no-git-checks
116
- env:
117
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,9 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "astro",
4
- "astrojs",
5
- "decap",
6
- "NCMS",
7
- "netlify"
8
- ]
9
- }
package/DecAp.svg DELETED
@@ -1,67 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
-
4
- <svg
5
- width="481.47726mm"
6
- height="179.94118mm"
7
- viewBox="0 0 481.47727 179.94118"
8
- version="1.1"
9
- id="svg1"
10
- xml:space="preserve"
11
- xmlns="http://www.w3.org/2000/svg"
12
- xmlns:svg="http://www.w3.org/2000/svg"><defs
13
- id="defs1"><linearGradient
14
- id="swatch9"><stop
15
- style="stop-color:#000000;stop-opacity:1;"
16
- offset="0"
17
- id="stop9" /></linearGradient><style
18
- id="style1">.cls-1{fill:#ff0082;}</style><linearGradient
19
- id="paint0_linear_1_59"
20
- x1="22.4702"
21
- y1="107"
22
- x2="69.145103"
23
- y2="84.9468"
24
- gradientUnits="userSpaceOnUse"><stop
25
- stop-color="#D83333"
26
- id="stop3" /><stop
27
- offset="1"
28
- stop-color="#F041FF"
29
- id="stop4" /></linearGradient></defs><g
30
- id="layer1"
31
- transform="translate(-60.600167,-44.834473)"><g
32
- id="g1"
33
- transform="matrix(1.2846588,0,0,1.2846588,23.524914,28.312615)"><g
34
- class="name"
35
- id="g7"><path
36
- d="m 168.38393,85.306005 7.9375,9.016802 c -4.78977,5.702023 -11.96693,8.712643 -21.24224,8.712643 -17.79016,0 -29.37677,-11.723288 -29.37677,-27.749786 0,-16.026484 11.67752,-27.749849 27.55193,-27.749849 14.53667,0 26.50302,10.020377 26.59442,27.248073 l -38.07422,7.709115 c 2.20458,5.306691 6.97943,8.013236 13.68485,8.013236 5.4587,0 9.38162,-1.70299 12.92453,-5.215448 z M 140.34528,73.689091 165.41902,68.58008 c -1.42926,-5.504343 -5.93019,-9.214464 -12.14921,-9.214464 -7.46584,0 -12.63573,5.215471 -12.92453,14.323475 z"
37
- id="path4"
38
- style="stroke-width:1.52062" /><path
39
- d="m 183.34119,75.285664 c 0,-16.22418 11.96636,-27.749849 28.70749,-27.749849 10.81128,0 19.32623,4.911368 23.06687,13.715281 l -11.57161,6.507901 c -2.78264,-5.109008 -6.88795,-7.405022 -11.57133,-7.405022 -7.5568,0 -13.48697,5.504347 -13.48697,14.91648 0,9.412145 5.93018,14.916491 13.48697,14.916491 4.68338,0 8.80412,-2.204768 11.57133,-7.405018 l 11.57161,6.614357 c -3.72566,8.621424 -12.24061,13.624095 -23.06687,13.624095 -16.74113,0 -28.70749,-11.525782 -28.70749,-27.749925 z"
40
- id="path5"
41
- style="stroke-width:1.52062" /><g
42
- style="fill:none"
43
- id="g2"
44
- transform="matrix(1.2435478,0,0,1.2435478,238.60797,19.870519)"><path
45
- d="m 27.5894,91.1365 c -4.8339,-4.4187 -6.245,-13.703 -4.2311,-20.4293 3.492,4.2408 8.3305,5.5842 13.3422,6.3425 7.737,1.1702 15.3354,0.7325 22.5227,-2.8038 0.8222,-0.4049 1.582,-0.9432 2.4804,-1.4885 0.6744,1.9566 0.8499,3.9318 0.6144,5.9422 -0.5728,4.8961 -3.0094,8.6782 -6.8848,11.5452 -1.5497,1.1468 -3.1895,2.1719 -4.79,3.2531 -4.917,3.3234 -6.2473,7.2201 -4.3997,12.8881 0.0439,0.139 0.0832,0.277 0.1825,0.614 -2.5105,-1.124 -4.3443,-2.76 -5.7415,-4.911 -1.4758,-2.2697 -2.1779,-4.7809 -2.2149,-7.4981 -0.0185,-1.3223 -0.0185,-2.6564 -0.1963,-3.96 -0.4342,-3.1782 -1.9262,-4.6012 -4.7369,-4.6831 -2.8846,-0.0842 -5.1664,1.6991 -5.7715,4.5076 -0.0462,0.2153 -0.1132,0.4283 -0.1802,0.6787 z"
46
- fill="url(#paint0_linear_1_59)"
47
- id="path2-7"
48
- style="fill:url(#paint0_linear_1_59)" /><path
49
- d="m 0,69.5866 c 0,0 14.3139,-6.9729 28.6678,-6.9729 L 39.4901,29.1204 c 0.4052,-1.6197 1.5882,-2.7205 2.9238,-2.7205 1.3356,0 2.5186,1.1008 2.9238,2.7205 l 10.8224,33.4933 c 17,0 28.6677,6.9729 28.6677,6.9729 0,0 -24.3133,-66.23427 -24.3608,-66.36716 C 59.7692,1.2612 58.5911,0 57.0029,0 H 27.8274 C 26.2392,0 25.1087,1.2612 24.3634,3.21944 24.3108,3.34983 0,69.5866 0,69.5866 Z"
50
- class="astro-logo"
51
- id="path3-5" /></g><path
52
- d="m 403.64999,73.654032 c 0,16.923602 -11.19105,27.749788 -25.63625,27.749788 -6.41671,0 -11.67766,-2.098272 -15.49422,-6.507879 v 25.134549 h -14.9317 V 46.710056 h 14.26274 v 6.203805 c 3.72517,-4.71367 9.27528,-7.009678 16.16318,-7.009678 14.4452,0 25.63625,10.811039 25.63625,27.749849 z m -15.11416,0 c 0,-9.320898 -5.64097,-14.916473 -13.1068,-14.916473 -7.46583,0 -13.10741,5.610788 -13.10741,14.916473 0,9.305694 5.64158,14.91649 13.10741,14.91649 7.46583,0 13.1068,-5.610796 13.1068,-14.91649 z"
53
- id="path7"
54
- style="stroke-width:1.52062" /><g
55
- id="g9"><path
56
- class="cls-1"
57
- d="m 59.59,13.02 -30.73,2.8 3.67,40.21 20.03,-1.83 -1.99,-21.86 10.71,-0.98 c 10.61,-0.97 19.14,7.53 20.29,20.19 v 0 c 0,0 19.67,-1.79 19.67,-1.79 C 99.22,27.59 80.52,11.11 59.61,13.01 Z"
58
- id="path1" /><path
59
- class="cls-1"
60
- d="m 102.46,62.38 c 0,12.72 -7.73,21.95 -18.37,21.95 H 73.34 V 62.34 H 53.23 v 40.42 h 30.86 c 21.02,0 38.12,-18.11 38.12,-40.38 0,-0.01 0,-0.02 0,-0.04 h -19.75 c 0,0 0,0.02 0,0.04 z"
61
- id="path2" /></g></g></g></g><style
62
- id="style7">
63
- @media (prefers-color-scheme: dark) {g.name {fill: #ffffff;}}
64
- @media (prefers-color-scheme: light) {g.name {fill: #000000;}}
65
- @media (prefers-color-scheme: dark) {.astro-logo {fill: #ffffff;}}
66
- @media (prefers-color-scheme: light) {.astro-logo {fill: #000000;}}
67
- </style></svg>
@@ -1,20 +0,0 @@
1
- 'use strict'
2
-
3
- import config from 'conventional-changelog-conventionalcommits'
4
-
5
- export default config({
6
- types: [
7
- { type: 'feat', section: 'Features' },
8
- { type: 'feature', section: 'Features' },
9
- { type: 'fix', section: 'Bug Fixes' },
10
- { type: 'perf', section: 'Performance Improvements' },
11
- { type: 'revert', section: 'Reverts' },
12
- { type: 'docs', section: 'Documentation' },
13
- { type: 'style', section: 'Styles' },
14
- { type: 'chore', section: 'Chores'},
15
- { type: 'refactor', section: 'Code Refactoring' },
16
- { type: 'test', section: 'Tests' },
17
- { type: 'build', section: 'Build System' },
18
- { type: 'ci', section: 'Continuous Integration' }
19
- ],
20
- })
package/renovate.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:recommended"
5
- ],
6
- "packageRules": [
7
- {
8
- "matchUpdateTypes": ["minor", "patch"],
9
- "automerge": true
10
- }
11
- ]
12
- }
package/src/cms.ts DELETED
@@ -1,36 +0,0 @@
1
- import { InitCmsOptions } from './types';
2
-
3
- export default function initCMS({
4
- cms,
5
- config,
6
- previewStyles = [],
7
- }: InitCmsOptions) {
8
- // Provide default values given we can make a reasonable guess
9
- const mediaDefaults = !config.media_folder
10
- ? { media_folder: 'public', public_folder: '/' }
11
- : {};
12
-
13
- cms.init({
14
- config: {
15
- // Don’t try to load config.yml as we’re providing the config below
16
- load_config_file: false,
17
- // Enable use of the Netlify CMS proxy server when working locally
18
- local_backend: true,
19
- ...mediaDefaults,
20
- ...config,
21
- },
22
- });
23
-
24
- /**
25
- * One drawback of using Netlify CMS is that it registers all preview
26
- * styles globally — not scoped to a specific collection.
27
- * You lose Astro components’ scoped styling anyway by being forced
28
- * to use React, but just be extra careful.
29
- *
30
- * The (undocumented?) `raw: true` setting treats the first argument as
31
- * a raw CSS string to inject instead of as a URL to load a stylesheet from.
32
- */
33
- previewStyles.forEach(([style, opts]) =>
34
- cms.registerPreviewStyle(style, opts)
35
- );
36
- }
@@ -1,13 +0,0 @@
1
- import identity from 'netlify-identity-widget';
2
-
3
- export function initIdentity(adminPath: string) {
4
- identity.on('init', (user) => {
5
- if (!user) {
6
- identity.on('login', () => {
7
- document.location.href = adminPath;
8
- });
9
- }
10
- });
11
-
12
- identity.init();
13
- }
package/src/index.ts DELETED
@@ -1,95 +0,0 @@
1
- import type { AstroIntegration } from 'astro';
2
- import type { CmsConfig } from 'decap-cms-core';
3
- import { spawn } from 'node:child_process';
4
- import type { PreviewStyle } from './types.js';
5
- import AdminDashboard from './vite-plugin-admin-dashboard.js';
6
-
7
- const widgetPath = '@jee-r/astro-decap-cms/identity-widget';
8
-
9
- interface DecapCMSOptions {
10
- /**
11
- * Path at which the Decap CMS admin dashboard should be served.
12
- * @default '/admin'
13
- */
14
- adminPath?: string;
15
- config: Omit<CmsConfig, 'load_config_file' | 'local_backend'>;
16
- disableIdentityWidgetInjection?: boolean;
17
- previewStyles?: PreviewStyle[];
18
- }
19
-
20
- /**
21
- * Creates an Astro integration for Decap CMS.
22
- *
23
- * @param options - Configuration options for the Decap CMS integration
24
- * @returns An Astro integration that adds Decap CMS to your project
25
- */
26
- export default function DecapCMS({
27
- disableIdentityWidgetInjection = false,
28
- adminPath = '/admin',
29
- config: cmsConfig,
30
- previewStyles = [],
31
- }: DecapCMSOptions) {
32
- if (!adminPath.startsWith('/')) {
33
- throw new Error(
34
- `'adminPath' option must be a root-relative pathname, starting with "/", got "${adminPath}"`
35
- );
36
- }
37
- if (adminPath.endsWith('/')) {
38
- adminPath = adminPath.slice(0, -1);
39
- }
40
-
41
- let proxy: ReturnType<typeof spawn>;
42
-
43
- const DecapCMSIntegration: AstroIntegration = {
44
- name: 'decap-cms',
45
- hooks: {
46
- 'astro:config:setup': ({
47
- config,
48
- injectRoute,
49
- injectScript,
50
- updateConfig,
51
- }) => {
52
- const identityWidgetScript = `import { initIdentity } from '${widgetPath}'; initIdentity('${adminPath}');`;
53
- updateConfig({
54
- // Default to the URL provided by Netlify when building there. See:
55
- // https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata
56
- site: config.site || process.env.URL,
57
- vite: {
58
- plugins: [
59
- AdminDashboard({
60
- config: cmsConfig,
61
- previewStyles,
62
- identityWidget: disableIdentityWidgetInjection
63
- ? identityWidgetScript
64
- : '',
65
- }),
66
- ],
67
- },
68
- });
69
-
70
- injectRoute({
71
- pattern: adminPath,
72
- entrypoint: '@jee-r/astro-decap-cms/admin-dashboard.astro',
73
- });
74
-
75
- if (!disableIdentityWidgetInjection) {
76
- injectScript('page', identityWidgetScript);
77
- }
78
- },
79
-
80
- 'astro:server:start': () => {
81
- proxy = spawn('decap-server', {
82
- stdio: 'inherit',
83
- // Run in shell on Windows to make sure the npm package can be found.
84
- shell: process.platform === 'win32',
85
- });
86
- process.on('exit', () => proxy.kill());
87
- },
88
-
89
- 'astro:server:done': () => {
90
- proxy.kill();
91
- },
92
- },
93
- };
94
- return DecapCMSIntegration;
95
- }
package/src/types.ts DELETED
@@ -1,14 +0,0 @@
1
- import type CMS from 'decap-cms-app';
2
- import type { CmsConfig } from 'decap-cms-core';
3
-
4
- export type NormalizedPreviewStyle =
5
- | [pathOrUrl: string]
6
- | [rawCSS: string, meta: { raw: boolean }];
7
-
8
- export type PreviewStyle = string | NormalizedPreviewStyle;
9
-
10
- export interface InitCmsOptions {
11
- cms: typeof CMS;
12
- config: CmsConfig;
13
- previewStyles?: NormalizedPreviewStyle[];
14
- }
package/src/virtual.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare module 'virtual:astro-decap-cms/user-config' {
2
- import type { InitCmsOptions } from './types';
3
- const CmsOptions: InitCmsOptions;
4
- export default CmsOptions;
5
- }
@@ -1,68 +0,0 @@
1
- import type { CmsConfig } from 'decap-cms-core';
2
- import type { Plugin } from 'vite';
3
- import type { PreviewStyle } from './types';
4
-
5
- const virtualModuleId = 'virtual:astro-decap-cms/user-config';
6
- const resolvedVirtualModuleId = '\0' + virtualModuleId;
7
-
8
- function generateVirtualConfigModule({
9
- config,
10
- previewStyles = [],
11
- identityWidget,
12
- }: {
13
- config: CmsConfig;
14
- previewStyles: Array<string | [string] | [string, { raw: boolean }]>;
15
- identityWidget: string;
16
- }) {
17
- const imports: string[] = [];
18
- const styles: string[] = [];
19
-
20
- previewStyles.forEach((entry, index) => {
21
- if (!Array.isArray(entry)) entry = [entry];
22
- const [style, opts] = entry;
23
- if (opts?.raw || style.startsWith('http')) {
24
- styles.push(JSON.stringify([style, opts]));
25
- } else {
26
- const name = `style__${index}`;
27
- imports.push(`import ${name} from '${style}?raw';`);
28
- styles.push(`[${name}, { raw: true }]`);
29
- }
30
- });
31
-
32
- return `${imports.join('\n')}
33
- import CMS from 'decap-cms-app';
34
- ${identityWidget}
35
- export default {
36
- cms: CMS,
37
- config: JSON.parse('${JSON.stringify(config)}'),
38
- previewStyles: [${styles.join(',')}],
39
- };
40
- `;
41
- }
42
-
43
- export default function AdminDashboardPlugin({
44
- config,
45
- previewStyles,
46
- identityWidget,
47
- }: {
48
- config: Omit<CmsConfig, 'load_config_file' | 'local_backend'>;
49
- previewStyles: PreviewStyle[];
50
- identityWidget: string;
51
- }): Plugin {
52
- return {
53
- name: 'vite-plugin-decap-cms-admin-dashboard',
54
-
55
- resolveId(id) {
56
- if (id === virtualModuleId) return resolvedVirtualModuleId;
57
- },
58
-
59
- load(id) {
60
- if (id === resolvedVirtualModuleId)
61
- return generateVirtualConfigModule({
62
- config,
63
- previewStyles,
64
- identityWidget,
65
- });
66
- },
67
- };
68
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "target": "es6",
5
- "moduleResolution": "node",
6
- "outDir": "./dist",
7
- "skipLibCheck": true
8
- },
9
- "include": ["src/**/*.ts"]
10
- }