diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 8214674f..12a88a6f 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -24,7 +24,7 @@ jobs: run: node scripts/beta-release.js $GITHUB_RUN_ID - name: Publish - run: npx vsce publish -p ${{ secrets.VSCE_PAT }} --baseImagesUrl https://raw.githubusercontent.com/estruyf/vscode-front-matter/dev + run: npx @vscode/vsce publish -p ${{ secrets.VSCE_PAT }} --baseImagesUrl https://raw.githubusercontent.com/estruyf/vscode-front-matter/dev - name: Publish to open-vsx.org run: npx ovsx publish -p ${{ secrets.OPEN_VSX_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10f6d950..ec3ae27f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: run: node scripts/main-release.js - name: Publish - run: npx vsce publish -p ${{ secrets.VSCE_PAT }} + run: npx @vscode/vsce publish -p ${{ secrets.VSCE_PAT }} - name: Publish to open-vsx.org run: npx ovsx publish -p ${{ secrets.OPEN_VSX_PAT }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 482c901d..4aa454c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## [8.3.0] - 2022-xx-xx + +### ✨ New features + +- [#407](https://github.com/estruyf/vscode-front-matter/issues/407): External config support + +### 🎨 Enhancements + +- [#474](https://github.com/estruyf/vscode-front-matter/issues/474): Allow to define the file prefix on content types +- [#484](https://github.com/estruyf/vscode-front-matter/issues/484): Support for overriding scripts per environment type +- [#494](https://github.com/estruyf/vscode-front-matter/issues/494): Support for external image URLs in previews +- [#497](https://github.com/estruyf/vscode-front-matter/issues/497): Support for movie media previews in the content dashboard + +### ⚡️ Optimizations + +### 🐞 Fixes + +- [#469](https://github.com/estruyf/vscode-front-matter/issues/469): Fix for using the root folder as content folder +- [#470](https://github.com/estruyf/vscode-front-matter/issues/470): Fix `initialize project` dashboard description +- [#482](https://github.com/estruyf/vscode-front-matter/issues/482): Update the description when you want to overwrite the default content type description +- [#493](https://github.com/estruyf/vscode-front-matter/issues/493): Fix an issue where a custom placeholder value is replaced by an `array` instead of a `string` + ## [8.2.0] - 2022-12-08 - [Release notes](https://beta.frontmatter.codes/updates/v8.2.0) ### ✨ New features diff --git a/README.beta.md b/README.beta.md index 42b5c509..578eca12 100644 --- a/README.beta.md +++ b/README.beta.md @@ -10,12 +10,12 @@

- Visual Studio Marketplace + Visual Studio Marketplace - Number of installs + Number of installs - Ratings + Ratings Sponsor the project diff --git a/README.md b/README.md index 08ce0bf5..b02a9877 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@

- Visual Studio Marketplace + Visual Studio Marketplace - Number of installs + Number of installs - Ratings + Ratings Sponsor the project @@ -163,21 +163,29 @@ You can open showcase issues for the following things:

- + Front Matter contributors

## 🖤 Backers & Sponsors 👇 🤘

- + Front Matter sponsors +

+ +
+ +

+ + Powered by Vercel +


- - + + Supported by the BEJS Community

@@ -190,6 +198,6 @@ You can open showcase issues for the following things:

- + Front Matter visitors

\ No newline at end of file diff --git a/package.json b/package.json index ab6d919a..724c6fe4 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Front Matter CMS", "description": "Front Matter is a CMS that runs within Visual Studio Code. It gives you the power and control of a full-blown CMS while also providing you the flexibility and speed of the static site generator of your choice like: Hugo, Jekyll, Docusaurus, NextJs, Gatsby, and many more...", "icon": "assets/frontmatter-teal-128x128.png", - "version": "8.2.0", + "version": "8.3.0", "preview": false, "publisher": "eliostruyf", "galleryBanner": { @@ -79,6 +79,14 @@ "configuration": { "title": "Front Matter: use frontmatter.json for shared team settings", "properties": { + "frontMatter.extends": { + "type": "array", + "markdownDescription": "Specify the list of paths/URLs to extend the Front Matter CMS config. [Check in the docs](https://frontmatter.codes/docs/settings#frontmatter.extends)", + "default": [], + "items": { + "type": "string" + } + }, "frontMatter.content.autoUpdateDate": { "type": "boolean", "default": false, @@ -454,6 +462,30 @@ "type": "boolean", "description": "Hide the action from the UI", "default": false + }, + "environments": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "macos", + "linux", + "windows" + ], + "description": "The environment type for which the script needs to be used" + }, + "script": { + "type": "string", + "description": "Path to the script to execute" + }, + "command": { + "$ref": "#scriptCommand" + } + } + } } }, "additionalProperties": false, @@ -1260,6 +1292,13 @@ "type": "string", "default": "", "description": "An optional post script that can be used after new content creation." + }, + "filePrefix": { + "type": [ + "null", + "string" + ], + "description": "Defines a prefix for the file name." } }, "additionalProperties": false, diff --git a/scripts/settings-export.js b/scripts/settings-export.js new file mode 100644 index 00000000..047b8f06 --- /dev/null +++ b/scripts/settings-export.js @@ -0,0 +1,43 @@ +const packageJson = require('../package.json'); + +for (const key of Object.keys(packageJson.contributes.configuration.properties)) { + const type = packageJson.contributes.configuration.properties[key].type; + + if (type.includes('object') || type.includes('array')) { + console.log(`${key} - ${packageJson.contributes.configuration.properties[key].type}`); + } +} + +// TO IGNORE +// frontMatter.extends - array +// frontMatter.dashboard.mediaSnippet - array + +// TO PROCESS AS A WHOLE OBJECT +// frontMatter.content.draftField - object +// frontMatter.content.supportedFileTypes - array +// frontMatter.global.notifications - array +// frontMatter.global.disabledNotificaitons - array +// frontMatter.media.supportedMimeTypes - array +// frontMatter.taxonomy.commaSeparatedFields - array + +// MERGE ARRAYS +// frontMatter.taxonomy.categories - array +// frontMatter.taxonomy.tags - array +// frontMatter.taxonomy.noPropertyValueQuotes - array + +// PROCESS ITEM BY ITEM +// frontMatter.custom.scripts - array - id +// frontMatter.taxonomy.contentTypes - array,null - name +// frontMatter.data.files - array - id +// frontMatter.data.folders - array - id +// frontMatter.data.types - array - id +// frontMatter.content.pageFolders - array - path +// frontMatter.content.placeholders - array - id +// frontMatter.content.sorting - array - id +// frontMatter.global.modes - array - id +// frontMatter.taxonomy.fieldGroups - array - id +// frontMatter.taxonomy.customTaxonomy - array - id + + + +// frontMatter.content.snippets - object \ No newline at end of file diff --git a/src/commands/Article.ts b/src/commands/Article.ts index 9b3f3370..8baec070 100644 --- a/src/commands/Article.ts +++ b/src/commands/Article.ts @@ -198,7 +198,6 @@ export class Article { Telemetry.send(TelemetryEvent.generateSlug); const updateFileName = Settings.get(SETTING_SLUG_UPDATE_FILE_NAME) as string; - let filePrefix = Settings.get(SETTING_TEMPLATES_PREFIX); const editor = vscode.window.activeTextEditor; if (!editor) { @@ -210,13 +209,10 @@ export class Article { return; } - // Retrieve the file prefix from the folder - const filePrefixOnFolder = Folders.getFilePrefixBeFilePath(editor.document.uri.fsPath); - if (typeof filePrefixOnFolder !== "undefined") { - filePrefix = filePrefixOnFolder; - } - + let filePrefix = Settings.get(SETTING_TEMPLATES_PREFIX); const contentType = ArticleHelper.getContentType(article.data); + filePrefix = ArticleHelper.getFilePrefix(editor.document.uri.fsPath, contentType); + const titleField = "title"; const articleTitle: string = article.data[titleField]; const slugInfo = Article.generateSlug(articleTitle); @@ -259,7 +255,7 @@ export class Article { let newFileName = `${slugName}${ext}`; if (filePrefix && typeof filePrefix === "string") { - newFileName = `${format(new Date(), DateHelper.formatUpdate(filePrefix) as string)}-${newFileName}`; + newFileName = `${filePrefix}-${newFileName}`; } const newPath = editor.document.uri.fsPath.replace(fileName, newFileName); diff --git a/src/commands/Cache.ts b/src/commands/Cache.ts index 5175f5b8..67b6b387 100644 --- a/src/commands/Cache.ts +++ b/src/commands/Cache.ts @@ -13,11 +13,22 @@ export class Cache { ); } + public static async get(key: string, type: "workspace" | "global"): Promise { + const ext = Extension.getInstance(); + const cache = await ext.getState(key, type); + return cache || undefined; + } + + public static async set(key: string, data: any, type: "workspace" | "global") { + await Extension.getInstance().setState(key, data, "workspace"); + } + private static async clear() { const ext = Extension.getInstance(); await ext.setState(ExtensionState.Dashboard.Pages.Cache, undefined, "workspace"); await ext.setState(ExtensionState.Dashboard.Pages.Index, undefined, "workspace"); + await ext.setState(ExtensionState.Settings.Extends, undefined, "workspace"); Notifications.info("Cache cleared"); } diff --git a/src/commands/Dashboard.ts b/src/commands/Dashboard.ts index e9ee8da0..c6057b1f 100644 --- a/src/commands/Dashboard.ts +++ b/src/commands/Dashboard.ts @@ -199,7 +199,8 @@ export class Dashboard { const csp = [ `default-src 'none';`, - `img-src ${`vscode-file://vscode-app`} ${webView.cspSource} https://api.visitorbadge.io 'self' 'unsafe-inline'`, + `img-src ${`vscode-file://vscode-app`} ${webView.cspSource} https://api.visitorbadge.io 'self' 'unsafe-inline' https://*`, + `media-src ${`vscode-file://vscode-app`} ${webView.cspSource} 'self' 'unsafe-inline' https://*`, `script-src ${isProd ? `'nonce-${nonce}'` : `http://${localServerUrl} http://0.0.0.0:${localPort}`} 'unsafe-eval'`, `style-src ${webView.cspSource} 'self' 'unsafe-inline'`, `font-src ${webView.cspSource}`, diff --git a/src/commands/Folders.ts b/src/commands/Folders.ts index 48f40470..d1ee95f9 100644 --- a/src/commands/Folders.ts +++ b/src/commands/Folders.ts @@ -253,14 +253,19 @@ export class Folders { try { let projectStart = parseWinPath(folder.path).replace(wsFolder, ""); - if (projectStart) { + if (typeof projectStart === 'string') { projectStart = projectStart.replace(/\\/g, '/'); projectStart = projectStart.startsWith('/') ? projectStart.substring(1) : projectStart; let files: Uri[] = []; for (const fileType of (supportedFiles || DEFAULT_FILE_TYPES)) { - const filePath = join(projectStart, folder.excludeSubdir ? '/' : '**', `*${fileType.startsWith('.') ? '' : '.'}${fileType}`); + let filePath = join(projectStart, folder.excludeSubdir ? '/' : '**', `*${fileType.startsWith('.') ? '' : '.'}${fileType}`); + + if (projectStart === '' && folder.excludeSubdir) { + filePath = `*${fileType.startsWith('.') ? '' : '.'}${fileType}`; + } + const foundFiles = await workspace.findFiles(filePath, '**/node_modules/**'); files = [...files, ...foundFiles]; } diff --git a/src/constants/ExtensionState.ts b/src/constants/ExtensionState.ts index 76aad254..c72eac71 100644 --- a/src/constants/ExtensionState.ts +++ b/src/constants/ExtensionState.ts @@ -19,6 +19,10 @@ export const ExtensionState = { } }, + Settings: { + Extends: `frontMatter:Settings:Extends`, + }, + Updates: { v7_0_0: { dateFields: `frontMatter:Updates:v7.0.0:dateFields` diff --git a/src/constants/settings.ts b/src/constants/settings.ts index ca046281..740aac2b 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -2,6 +2,8 @@ export const EXTENSION_NAME = "Front Matter"; export const CONFIG_KEY = "frontMatter"; +export const SETTING_EXTENDS = "extends"; + export const SETTING_GLOBAL_NOTIFICATIONS = "global.notifications"; export const SETTING_GLOBAL_NOTIFICATIONS_DISABLED = "global.disabledNotifications"; export const SETTING_GLOBAL_MODES = "global.modes"; diff --git a/src/dashboardWebView/components/Media/Item.tsx b/src/dashboardWebView/components/Media/Item.tsx index 6435b82b..3ade9e88 100644 --- a/src/dashboardWebView/components/Media/Item.tsx +++ b/src/dashboardWebView/components/Media/Item.tsx @@ -321,10 +321,14 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi }, [media, isImageFile, isVideoFile, isAudioFile]); const renderMedia = useMemo(() => { - if (isVideoFile || isAudioFile) { + if (isAudioFile) { return null; } + if (isVideoFile) { + return