Skip to content

Commit

Permalink
Merge branch dev into published
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Jul 13, 2024
2 parents a4f8ac7 + 059ff9a commit 23710cb
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ output.calva-repl
clojure.tmLanguage.json
.cpcache/
backup/
bundled/drams-menu/drams-local.edn

# Calva grammars (running the atom-ci docker image locally)
src/calva-fmt/atom-language-clojure/.cache/
Expand All @@ -101,4 +102,4 @@ src/calva-fmt/atom-language-clojure/.bash_history
.portal

# Emacs
*~
*~
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes to Calva.

## [Unreleased]

## [2.0.466] - 2024-07-13

- Internal: Move drams-menu configuration to the Drams repository. Preparing for ways to contribute drams to Calva.

## [2.0.465] - 2024-07-10

- [Only alert if the Jack-in process is interrupted before the repl is started](https://github.com/BetterThanTomorrow/calva/issues/2600)
Expand Down
14 changes: 0 additions & 14 deletions bundled/drams-local.edn

This file was deleted.

6 changes: 3 additions & 3 deletions bundled/drams-dev.edn → bundled/drams-menu/drams-dev.edn
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[{:title "Create a Getting Started REPL project",
[{:title "Create a Getting Started REPL project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/dev/drams/v2/calva_getting_started",
:description "An interactive guide introducing you to Calva and Clojure.",
:extraDetail "Requires Java"}
{:title "Create a ClojureScript Quick Start Browser Project",
{:title "Create a ClojureScript Quick Start Browser Project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/dev/drams/v2/calva_cljs_browser_quick_start",
:extraDetail "Requires Java"}
{:title "Create a ClojureScript Quick Start Node Project",
{:title "Create a ClojureScript Quick Start Node Project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/dev/drams/v2/calva_cljs_node_quick_start",
:extraDetail "Requires Java & Node.js"}
{:title "Create a mini Clojure project",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[{:title "Create a Getting Started REPL project",
[{:title "Create a Getting Started REPL project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/published/drams/v2/calva_getting_started",
:description "An interactive guide introducing you to Calva and Clojure.",
:extraDetail "Requires Java"}
{:title "Create a ClojureScript Quick Start Browser Project",
{:title "Create a ClojureScript Quick Start Browser Project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/published/drams/v2/calva_cljs_browser_quick_start",
:extraDetail "Requires Java"}
{:title "Create a ClojureScript Quick Start Node Project",
{:title "Create a ClojureScript Quick Start Node Project",
:src "https://raw.githubusercontent.com/BetterThanTomorrow/dram/published/drams/v2/calva_cljs_node_quick_start",
:extraDetail "Requires Java & Node.js"}
{:title "Create a mini Clojure project",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Calva: Clojure & ClojureScript Interactive Programming",
"description": "Integrated REPL, formatter, Paredit, and more. Powered by cider-nrepl and clojure-lsp.",
"icon": "assets/calva.png",
"version": "2.0.465",
"version": "2.0.466",
"publisher": "betterthantomorrow",
"author": {
"name": "Better Than Tomorrow",
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async function activate(context: vscode.ExtensionContext) {
state.setExtensionContext(context);
state.initDepsEdnJackInExecutable();
const isDramStart = await drams.dramStartConfigExists();
void drams.refreshDramConfigs();

const inspectorDataProvider = eval.initInspectorDataProvider();
const inspectorTreeView = vscode.window.createTreeView('calva.inspector', {
Expand Down
66 changes: 48 additions & 18 deletions src/nrepl/drams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,47 +90,77 @@ async function putStoreDocInPlace(
return destUri;
}

const dramsUrl = () => {
const dramsBasePath = () => {
const calva = vscode.extensions.getExtension('betterthantomorrow.calva');
return path.join(calva.extensionPath, 'bundled', 'drams-menu');
};

const dramsPath = () => {
const { isDevBuild, isDebug } = devBuild();
return `file://${path.join(calva.extensionPath)}/bundled/drams-${
isDebug ? 'local' : isDevBuild ? 'dev' : 'published'
}.edn`;
return path.join(
dramsBasePath(),
`drams-${isDebug ? 'local' : isDevBuild ? 'dev' : 'published'}.edn`
);
};

export const dramUrl = (slug: string) => {
export const dramBaseUrl = () => {
const calva = vscode.extensions.getExtension('betterthantomorrow.calva');
const { isDevBuild, isDebug } = devBuild();
return isDebug
? `file://${path.join(calva.extensionPath)}/../dram/drams/v2/${slug}`
: `${DRAM_REPO_URL}/${isDevBuild ? 'dev' : 'published'}/drams/v2/${slug}`;
? `file://${path.join(calva.extensionPath)}/../dram/drams/v2`
: `${DRAM_REPO_URL}/${isDevBuild ? 'dev' : 'published'}/drams/v2`;
};

type DramSourceConfig = {
export const dramUrl = (name: string) => {
return `${dramBaseUrl()}/${name}`;
};

type DramMenuItemConfig = {
title: string;
src: string;
description?: string;
extraDetail?: string;
};

async function fetchDramConfigs(src: string): Promise<DramSourceConfig[]> {
export function refreshDramConfigs() {
for (const slug of ['local', 'dev', 'published']) {
utilities
.fetchFromUrl(`${dramBaseUrl()}/calva/drams-${slug}.edn`)
.then(async (dramConfigs) => {
await utilities.writeTextToFile(
vscode.Uri.file(path.join(dramsBasePath(), `drams-${slug}.edn`)),
dramConfigs
);
})
.catch((err) => {
console.error(`Error fetching dram configs: ${err.message}`);
});
}
}

async function readDramMenuConfig(filePath: string): Promise<DramMenuItemConfig[]> {
const calva = vscode.extensions.getExtension('betterthantomorrow.calva');
const configsEdn = await utilities.fetchFromUrl(`${src}`);
const config: DramSourceConfig[] = cljsLib.parseEdn(configsEdn);
const configsEdn = await utilities.getFileContents(filePath);
const config: DramMenuItemConfig[] = cljsLib.parseEdn(configsEdn);
return config.map((c) => ({
...c,
src: c.src.replace(/^LOCAL-REPO/, `file://${path.join(calva.extensionPath)}/../dram`),
}));
}

export async function createProjectMenuItems(): Promise<replMenu.MenuItem[]> {
return (await fetchDramConfigs(dramsUrl())).map((config) => ({
label: config.title,
description: config.extraDetail,
detail: config.description,
command: 'calva.createAndOpenProjectFromDram',
dramSrc: config.src,
}));
try {
return (await readDramMenuConfig(dramsPath())).map((config) => ({
label: config.title,
description: config.extraDetail,
detail: config.description,
command: 'calva.createAndOpenProjectFromDram',
dramSrc: config.src,
}));
} catch (e) {
console.error('Error reading dram configs:', e);
return [];
}
}

export async function createAndOpenDram(
Expand Down

0 comments on commit 23710cb

Please sign in to comment.