@strifeapp/astro 1.0.3 → 1.0.5
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/dist/index.d.ts +1 -0
- package/dist/index.js +22 -29
- package/dist/vite-plugin-strife-store-entry.js +1 -1
- package/dist/vite-plugin-strife-store.js +31 -5
- package/package.json +11 -5
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,46 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { loadEnv } from "vite";
|
|
2
|
+
// Import the vite plugin directly from the file
|
|
2
3
|
import { vitePluginStrifeStore } from './vite-plugin-strife-store.js';
|
|
3
|
-
|
|
4
4
|
const defaultClientConfig = {
|
|
5
5
|
type: 'pfx',
|
|
6
6
|
};
|
|
7
|
-
|
|
8
7
|
export default function strifeIntegration(options = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
throw new Error('[@yourcms/astro]: The `apiKey` option is required')
|
|
12
|
-
} */
|
|
8
|
+
let mode;
|
|
9
|
+
let env;
|
|
13
10
|
return {
|
|
14
11
|
name: '@strife/astro',
|
|
15
12
|
hooks: {
|
|
16
|
-
'astro:config:setup': ({
|
|
17
|
-
|
|
13
|
+
'astro:config:setup': ({ command, config, updateConfig }) => {
|
|
14
|
+
mode = command;
|
|
15
|
+
env = loadEnv(mode, config.vite.envDir ?? '', '');
|
|
16
|
+
const envOptions = {
|
|
17
|
+
urls: env.STRIFE_DATABASE_URLS?.split(','),
|
|
18
|
+
database: env.STRIFE_DATABASE,
|
|
19
|
+
certificate: env.STRIFE_CERTIFICATE,
|
|
20
|
+
password: env.STRIFE_CERTIFICATE_PASSWORD
|
|
21
|
+
};
|
|
22
|
+
// Filter out undefined values from env
|
|
23
|
+
const filteredEnvOptions = Object.fromEntries(Object.entries(envOptions).filter(([_, value]) => value !== undefined));
|
|
24
|
+
const mergedOptions = {
|
|
25
|
+
...defaultClientConfig, // Base defaults
|
|
26
|
+
...filteredEnvOptions, // Environment variables override defaults
|
|
27
|
+
...options // Explicit options override everything
|
|
28
|
+
};
|
|
18
29
|
updateConfig({
|
|
19
30
|
vite: {
|
|
20
31
|
plugins: [
|
|
21
|
-
|
|
22
|
-
vitePluginStrifeStore({
|
|
23
|
-
...defaultClientConfig,
|
|
24
|
-
...options
|
|
25
|
-
})
|
|
32
|
+
vitePluginStrifeStore(mergedOptions)
|
|
26
33
|
],
|
|
27
|
-
// Add other Vite config options
|
|
28
34
|
}
|
|
29
35
|
});
|
|
30
|
-
|
|
31
|
-
/* if (options.basePath) {
|
|
32
|
-
injectRoute({
|
|
33
|
-
pattern: `/${options.basePath}`,
|
|
34
|
-
entrypoint: '@yourcms/astro/dashboard.astro',
|
|
35
|
-
prerender: false
|
|
36
|
-
})
|
|
37
|
-
} */
|
|
38
|
-
// Inject any client-side scripts
|
|
39
|
-
/* injectScript('page-ssr', `
|
|
40
|
-
import { store } from "strife:store";
|
|
41
|
-
globalThis.store = store;
|
|
42
|
-
`) */
|
|
43
|
-
}
|
|
36
|
+
},
|
|
44
37
|
}
|
|
45
38
|
};
|
|
46
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file serves as an entry point for the vite-plugin-strife-store module
|
|
2
|
-
export * from './vite-plugin-strife-store
|
|
2
|
+
export * from './vite-plugin-strife-store';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//import type {ClientConfig} from '@sanity/client'
|
|
2
1
|
import serialize from 'serialize-javascript';
|
|
2
|
+
import contentIndex from './contentIndex.js?raw';
|
|
3
3
|
const virtualModuleId = 'strife:store';
|
|
4
4
|
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
|
5
5
|
export function vitePluginStrifeStore(config) {
|
|
@@ -13,7 +13,7 @@ export function vitePluginStrifeStore(config) {
|
|
|
13
13
|
load(id) {
|
|
14
14
|
if (id === resolvedVirtualModuleId) {
|
|
15
15
|
return `
|
|
16
|
-
import { DocumentStore } from "ravendb";
|
|
16
|
+
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask, IndexCreation } from "ravendb";
|
|
17
17
|
|
|
18
18
|
const authOptions = {
|
|
19
19
|
type: 'pfx',
|
|
@@ -21,11 +21,37 @@ export function vitePluginStrifeStore(config) {
|
|
|
21
21
|
password: ${serialize(config.password)},
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const store = new DocumentStore(
|
|
25
25
|
${serialize(config.urls ? config.urls : [])},
|
|
26
|
-
${serialize(config.database || '
|
|
26
|
+
${serialize(config.database || '')},
|
|
27
27
|
authOptions
|
|
28
|
-
).initialize()
|
|
28
|
+
).initialize()
|
|
29
|
+
|
|
30
|
+
class Content_ByUrlzz extends AbstractJavaScriptMultiMapIndexCreationTask {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
|
|
34
|
+
this.additionalSources = {"Helper": ${serialize(contentIndex)}}
|
|
35
|
+
|
|
36
|
+
${(config.collections || ['Posts']).map(collection => `this.map("${collection.name}", (doc) => mapDocument(doc));`).join('\n')}
|
|
37
|
+
|
|
38
|
+
this.deploymentMode = 'Rolling';
|
|
39
|
+
this.searchEngineType = 'Lucene';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log('Deploying index...');
|
|
44
|
+
await IndexCreation.createIndexes([new Content_ByUrlzz()], store);
|
|
45
|
+
|
|
46
|
+
const bulkInsert = store.bulkInsert();
|
|
47
|
+
|
|
48
|
+
${config.collections?.map(collection => `
|
|
49
|
+
bulkInsert.store(${serialize(collection)}, 'templates/${collection.name}', { '@collection': 'Templates' });
|
|
50
|
+
`).join('\n')}
|
|
51
|
+
|
|
52
|
+
await bulkInsert.finish();
|
|
53
|
+
|
|
54
|
+
export { store };
|
|
29
55
|
`;
|
|
30
56
|
}
|
|
31
57
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strifeapp/astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Official Strife Astro integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro-integration",
|
|
@@ -11,22 +11,28 @@
|
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "tsc"
|
|
14
|
+
"build": "vite build && tsc",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
15
16
|
},
|
|
16
17
|
"exports": {
|
|
17
18
|
".": "./dist/index.js",
|
|
18
|
-
"./vite-plugin-strife-store": "./dist/vite-plugin-strife-store-entry.js"
|
|
19
|
+
"./vite-plugin-strife-store": "./dist/vite-plugin-strife-store-entry.js",
|
|
20
|
+
"./module": "./module.d.ts"
|
|
19
21
|
},
|
|
20
22
|
"files": [
|
|
21
23
|
"dist"
|
|
22
24
|
],
|
|
23
25
|
"dependencies": {
|
|
24
|
-
"astro": "^5.
|
|
26
|
+
"astro": "^4.0.0 || ^5.0.0",
|
|
27
|
+
"dotenv": "^16.4.5",
|
|
25
28
|
"ravendb": "^6.0.0",
|
|
26
29
|
"serialize-javascript": "^6.0.2"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"
|
|
32
|
+
"@types/dotenv": "^8.2.0",
|
|
33
|
+
"typescript": "^5.7.3",
|
|
34
|
+
"vite": "^6.2.1",
|
|
35
|
+
"vite-plugin-dts": "^4.5.3"
|
|
30
36
|
},
|
|
31
37
|
"peerDependencies": {
|
|
32
38
|
"astro": "^4.0.0 || ^5.0.0",
|