studiocms 0.1.1 → 0.3.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 +65 -0
- package/dist/cli/add/index.js +6 -5
- package/dist/cli/add/tryToInstallPlugins.js +6 -5
- package/dist/cli/add/updateStudioCMSConfig.js +3 -4
- package/dist/cli/add/validatePlugins.d.ts +1 -2
- package/dist/cli/add/validatePlugins.js +15 -9
- package/dist/cli/crypto/genJWT/index.js +11 -11
- package/dist/cli/debug/index.js +2 -3
- package/dist/cli/getTurso/index.js +1 -1
- package/dist/cli/init/index.js +1 -1
- package/dist/cli/init/steps/env.js +5 -4
- package/dist/cli/init/steps/next.js +9 -7
- package/dist/cli/migrator/index.js +7 -8
- package/dist/cli/users/index.js +1 -1
- package/dist/cli/users/shared.js +3 -3
- package/dist/cli/users/steps/createUsers.js +7 -6
- package/dist/cli/users/steps/modifyUsers.js +9 -8
- package/dist/cli/users/steps/next.d.ts +1 -2
- package/dist/cli/users/steps/next.js +3 -3
- package/dist/cli/utils/checkRequiredEnvVars.js +2 -2
- package/dist/cli/utils/context.d.ts +1 -3
- package/dist/cli/utils/context.js +1 -3
- package/dist/cli/utils/intro.js +2 -2
- package/dist/cli/utils/logger.js +3 -3
- package/dist/cli/utils/user-utils.js +4 -3
- package/dist/consts.js +2 -1
- package/dist/handlers/setupDbStudio.d.ts +3 -1
- package/dist/handlers/setupDbStudio.js +19 -10
- package/dist/index.js +1 -15
- package/dist/toolbar/db-viewer/studio/connection.d.ts +8 -4
- package/dist/toolbar/db-viewer/studio/connection.js +2 -28
- package/dist/toolbar/db-viewer/studio/env/libsql.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/libsql.js +17 -0
- package/dist/toolbar/db-viewer/studio/env/mysql.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/mysql.js +23 -0
- package/dist/toolbar/db-viewer/studio/env/postgres.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/postgres.js +23 -0
- package/dist/toolbar/db-viewer/studio/index.js +20 -56
- package/dist/toolbar/db-viewer/studio/type.d.ts +1 -2
- package/dist/toolbar/db-viewer/studio/virtual-connection/libsql.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/libsql.js +24 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/mysql.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/mysql.js +9 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/postgres.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/postgres.js +9 -0
- package/dist/virtual.d.ts +12 -28
- package/dist/virtuals/auth/core.d.ts +5 -5
- package/dist/virtuals/scripts/StorageFileBrowser.d.ts +7 -0
- package/dist/virtuals/scripts/StorageFileBrowser.js +66 -2
- package/frontend/layouts/DashboardLayout.astro +1 -1
- package/frontend/middleware/_authmap.ts +63 -0
- package/frontend/middleware/index.ts +46 -0
- package/frontend/pages/404.astro +5 -8
- package/frontend/pages/studiocms_api/auth/[path].ts +0 -6
- package/frontend/pages/studiocms_api/dashboard/content/page.ts +4 -1
- package/frontend/pages/studiocms_api/integrations/[type]/_routes/db-studio.ts +16 -17
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/categories.ts +2 -2
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/pages.ts +4 -1
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/tags.ts +2 -2
- package/frontend/scripts/formdata-utils.ts +3 -3
- package/frontend/utils/rest-router.ts +20 -21
- package/package.json +33 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# studiocms
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1254](https://github.com/withstudiocms/studiocms/pull/1254) [`180b959`](https://github.com/withstudiocms/studiocms/commit/180b95972f9d51731eb570685e251532cbae2f62) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Replaces chalk with node:util's styleText
|
|
8
|
+
|
|
9
|
+
- [#1271](https://github.com/withstudiocms/studiocms/pull/1271) [`9a450cb`](https://github.com/withstudiocms/studiocms/commit/9a450cb9167e2f2ea4c197bc812131d2fdeda6c9) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Removes deprecated and unused virtual modules.
|
|
10
|
+
|
|
11
|
+
The following modules have been removed.
|
|
12
|
+
|
|
13
|
+
- `studiocms:astro-config/adapter`
|
|
14
|
+
- `studiocms:auth/utils/getLabelForPermissionLevel`
|
|
15
|
+
- `virtual:studiocms/sdk/env`
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#1237](https://github.com/withstudiocms/studiocms/pull/1237) [`fb6c96a`](https://github.com/withstudiocms/studiocms/commit/fb6c96ac6ae25887a0f673618770a67b2deffae6) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update studiocms dependencies
|
|
20
|
+
|
|
21
|
+
- [#1259](https://github.com/withstudiocms/studiocms/pull/1259) [`0525390`](https://github.com/withstudiocms/studiocms/commit/05253906d33a9b7bd12a27cdf2b8c9e9f693177f) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update studiocms dependencies
|
|
22
|
+
|
|
23
|
+
- [#1267](https://github.com/withstudiocms/studiocms/pull/1267) [`d56b066`](https://github.com/withstudiocms/studiocms/commit/d56b066554848d819cc3dd59cfacfbda51565ad5) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @nanostores/persistent to ^1.3.0
|
|
24
|
+
|
|
25
|
+
- [#1255](https://github.com/withstudiocms/studiocms/pull/1255) [`e12e074`](https://github.com/withstudiocms/studiocms/commit/e12e074e6432398181be1f58f5c89df96a516cbb) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Fix new type issues due to updated clack version
|
|
26
|
+
|
|
27
|
+
- [#1270](https://github.com/withstudiocms/studiocms/pull/1270) [`c9727f7`](https://github.com/withstudiocms/studiocms/commit/c9727f7a218113d68254de825b84ddb926721b56) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Fixes issue with pg and mysql2 being required to be installed when they should be optional
|
|
28
|
+
|
|
29
|
+
- [#1272](https://github.com/withstudiocms/studiocms/pull/1272) [`38e74bb`](https://github.com/withstudiocms/studiocms/commit/38e74bbeec97e054e8545d6665452c5246a1fdd3) Thanks [@RATIU5](https://github.com/RATIU5)! - Fix client regex in frontend to allow for slashes within a slug, but not on the outside. This unblocks creating pages under sub-paths just using the slug (e.g., `docs/getting-started`) and only affects client-side validation.
|
|
30
|
+
|
|
31
|
+
- [#1265](https://github.com/withstudiocms/studiocms/pull/1265) [`6d9b601`](https://github.com/withstudiocms/studiocms/commit/6d9b601b0a29ca2221d47efa65bc1356870e0339) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Removes legacy email domain verification code
|
|
32
|
+
|
|
33
|
+
- [#1231](https://github.com/withstudiocms/studiocms/pull/1231) [`e7b39ef`](https://github.com/withstudiocms/studiocms/commit/e7b39ef6c3e1e2a54201e200b32fb1c02cd5fc3e) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Fixes default 404 route rendering
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`6b826b8`](https://github.com/withstudiocms/studiocms/commit/6b826b80104fe23e35763edf275f1800e5629c32), [`8b46bf5`](https://github.com/withstudiocms/studiocms/commit/8b46bf5861f3ab884bb8cbac1b73a1e97fcabe96), [`f129eec`](https://github.com/withstudiocms/studiocms/commit/f129eec8d0a6f18c446c319dec9925cc31a890b4), [`e12e074`](https://github.com/withstudiocms/studiocms/commit/e12e074e6432398181be1f58f5c89df96a516cbb)]:
|
|
36
|
+
- @withstudiocms/internal_helpers@0.1.1
|
|
37
|
+
- @withstudiocms/effect@0.3.0
|
|
38
|
+
- @withstudiocms/auth-kit@0.1.3
|
|
39
|
+
- @withstudiocms/component-registry@0.1.3
|
|
40
|
+
- @withstudiocms/sdk@0.2.0
|
|
41
|
+
|
|
42
|
+
## 0.2.0
|
|
43
|
+
|
|
44
|
+
### Minor Changes
|
|
45
|
+
|
|
46
|
+
- [#1197](https://github.com/withstudiocms/studiocms/pull/1197) [`4b542ec`](https://github.com/withstudiocms/studiocms/commit/4b542eca8934996f7ed9eaf1c9f040305ea5e471) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Tweaks optional dependencies, and chunkSizeWarningLimit for Astro config to prevent warnings from WYSIWYG plugin
|
|
47
|
+
|
|
48
|
+
- [#1219](https://github.com/withstudiocms/studiocms/pull/1219) [`9122ddd`](https://github.com/withstudiocms/studiocms/commit/9122ddd16f9c7ab61c5df227ae7a81edd8620bb0) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Move to updated and migrated cli-kit package
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [#1222](https://github.com/withstudiocms/studiocms/pull/1222) [`0f6b4c7`](https://github.com/withstudiocms/studiocms/commit/0f6b4c74886f09ebf35ee73d5d8579d26f8e534a) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Tweaks package linking to pnpm catalog
|
|
53
|
+
|
|
54
|
+
- [#1211](https://github.com/withstudiocms/studiocms/pull/1211) [`b269e44`](https://github.com/withstudiocms/studiocms/commit/b269e44d68c8fd0da8eb3147c75b7d1cc899580d) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Adds regex and proper error handling to prevent illegal characters (non-url-safe) from being used for S3 objects.
|
|
55
|
+
|
|
56
|
+
- [#1220](https://github.com/withstudiocms/studiocms/pull/1220) [`3324f2b`](https://github.com/withstudiocms/studiocms/commit/3324f2be74a6c7d21005d1cc0b4a8695f376c53b) Thanks [@kunjabijukchhe](https://github.com/kunjabijukchhe)! - Fixes an issue where saving a page that does not have `draft` set to true, would previously update the `publishedAt` date value.
|
|
57
|
+
|
|
58
|
+
- [#1214](https://github.com/withstudiocms/studiocms/pull/1214) [`efc10be`](https://github.com/withstudiocms/studiocms/commit/efc10bee20db090fdd75463622c30dda390c50ad) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Fix: Reworks permission checks for dashboard routes to be at the middleware level to prevent unauthorized access
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`0f6b4c7`](https://github.com/withstudiocms/studiocms/commit/0f6b4c74886f09ebf35ee73d5d8579d26f8e534a), [`93e62f6`](https://github.com/withstudiocms/studiocms/commit/93e62f65f779192403361826bc2a7fb997762521), [`2dd709f`](https://github.com/withstudiocms/studiocms/commit/2dd709f7f83efbb64c4ccb83f49db2d589ca9404), [`0f6b4c7`](https://github.com/withstudiocms/studiocms/commit/0f6b4c74886f09ebf35ee73d5d8579d26f8e534a), [`4b542ec`](https://github.com/withstudiocms/studiocms/commit/4b542eca8934996f7ed9eaf1c9f040305ea5e471), [`4b542ec`](https://github.com/withstudiocms/studiocms/commit/4b542eca8934996f7ed9eaf1c9f040305ea5e471), [`e628b43`](https://github.com/withstudiocms/studiocms/commit/e628b431f3128da1ad378138bdda2ca14794e76e), [`8a0ea71`](https://github.com/withstudiocms/studiocms/commit/8a0ea7176350b9526203d5722e1ff45d7fe6dfeb), [`59e5517`](https://github.com/withstudiocms/studiocms/commit/59e5517963cfd5f62fd3631b5ee69ae1e423ef50), [`c68668b`](https://github.com/withstudiocms/studiocms/commit/c68668b0a83341dd6cbdc378e1673017afef1d73)]:
|
|
61
|
+
- @withstudiocms/cli-kit@0.2.0
|
|
62
|
+
- @withstudiocms/effect@0.2.0
|
|
63
|
+
- @withstudiocms/kysely@0.2.0
|
|
64
|
+
- @withstudiocms/sdk@0.2.0
|
|
65
|
+
- @withstudiocms/auth-kit@0.1.2
|
|
66
|
+
- @withstudiocms/component-registry@0.1.2
|
|
67
|
+
|
|
3
68
|
## 0.1.1
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
package/dist/cli/add/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { styleText } from "node:util";
|
|
3
4
|
import { cancelled, success } from "@withstudiocms/cli-kit/messages";
|
|
4
5
|
import { exists, pathToFileURL, resolveRoot } from "@withstudiocms/cli-kit/utils";
|
|
5
6
|
import { intro, note, outro } from "@withstudiocms/effect/clack";
|
|
@@ -123,14 +124,14 @@ const addPlugin = Cli.Command.make(
|
|
|
123
124
|
{
|
|
124
125
|
plugin
|
|
125
126
|
},
|
|
126
|
-
({ plugin: plugin2 })
|
|
127
|
+
Effect.fn(function* ({ plugin: plugin2 }) {
|
|
127
128
|
const [validator, installer, updater, context] = yield* Effect.all([
|
|
128
129
|
ValidatePlugins,
|
|
129
130
|
TryToInstallPlugins,
|
|
130
131
|
UpdateStudioCMSConfig,
|
|
131
132
|
genContext
|
|
132
133
|
]);
|
|
133
|
-
const { cwd
|
|
134
|
+
const { cwd } = context;
|
|
134
135
|
yield* intro("StudioCMS CLI Utilities (add)");
|
|
135
136
|
const pluginNames = plugin2.map((name) => {
|
|
136
137
|
const aliasName = ALIASES.get(name);
|
|
@@ -149,7 +150,7 @@ const addPlugin = Cli.Command.make(
|
|
|
149
150
|
case 2 /* cancelled */: {
|
|
150
151
|
yield* note(
|
|
151
152
|
cancelled(
|
|
152
|
-
`Dependencies ${
|
|
153
|
+
`Dependencies ${styleText("bold", "NOT")} installed.`,
|
|
153
154
|
"Be sure to install them manually before continuing!"
|
|
154
155
|
)
|
|
155
156
|
);
|
|
@@ -176,7 +177,7 @@ const addPlugin = Cli.Command.make(
|
|
|
176
177
|
}
|
|
177
178
|
switch (configResult) {
|
|
178
179
|
case 2 /* cancelled */: {
|
|
179
|
-
yield* outro(cancelled(`Your configuration has ${
|
|
180
|
+
yield* outro(cancelled(`Your configuration has ${styleText("bold", "NOT")} been updated.`));
|
|
180
181
|
break;
|
|
181
182
|
}
|
|
182
183
|
case 0 /* none */: {
|
|
@@ -211,7 +212,7 @@ const addPlugin = Cli.Command.make(
|
|
|
211
212
|
);
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
}
|
|
215
|
+
}, Effect.provide(addPluginDeps))
|
|
215
216
|
).pipe(Cli.Command.withDescription("Add StudioCMS plugin(s) to your project"));
|
|
216
217
|
export {
|
|
217
218
|
ALIASES,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
1
2
|
import { exec } from "@withstudiocms/cli-kit/utils";
|
|
2
3
|
import { askToContinue, note, spinner } from "@withstudiocms/effect/clack";
|
|
3
4
|
import { detect, resolveCommand } from "package-manager-detector";
|
|
@@ -12,7 +13,7 @@ class TryToInstallPlugins extends Effect.Service()(
|
|
|
12
13
|
{
|
|
13
14
|
effect: genLogger("studiocms/cli/add/validatePlugins/TryToInstallPlugins.effect")(function* () {
|
|
14
15
|
const run = (plugins) => genLogger("studiocms/cli/add/validatePlugins/TryToInstallPlugins.effect.run")(function* () {
|
|
15
|
-
const {
|
|
16
|
+
const { cwd } = yield* CliContext;
|
|
16
17
|
const packageManager = yield* Effect.tryPromise(
|
|
17
18
|
() => detect({
|
|
18
19
|
cwd,
|
|
@@ -37,7 +38,7 @@ class TryToInstallPlugins extends Effect.Service()(
|
|
|
37
38
|
const installSpecifiers = (yield* convertPluginsToInstallSpecifiers(plugins)).map(
|
|
38
39
|
(specifier) => installCommand.command === "deno" ? `npm:${specifier}` : specifier
|
|
39
40
|
);
|
|
40
|
-
const coloredOutput = `${
|
|
41
|
+
const coloredOutput = `${styleText("bold", installCommand.command)} ${installCommand.args.join(" ")} ${styleText("magenta", installSpecifiers.join(" "))}`;
|
|
41
42
|
const boxenMessage = yield* effectBoxen(
|
|
42
43
|
(boxen) => boxen(coloredOutput, {
|
|
43
44
|
margin: 0.5,
|
|
@@ -49,8 +50,8 @@ class TryToInstallPlugins extends Effect.Service()(
|
|
|
49
50
|
${boxenMessage}
|
|
50
51
|
`;
|
|
51
52
|
yield* note(
|
|
52
|
-
`${
|
|
53
|
-
${
|
|
53
|
+
`${styleText("magenta", "StudioCMS will run the following command:")}
|
|
54
|
+
${styleText("dim", "If you skip this step, you can always run it yourself later")}
|
|
54
55
|
${message}`
|
|
55
56
|
);
|
|
56
57
|
if (yield* askToContinue()) {
|
|
@@ -83,7 +84,7 @@ ${response.stdout || response.message}
|
|
|
83
84
|
`);
|
|
84
85
|
yield* Console.error(
|
|
85
86
|
`
|
|
86
|
-
${
|
|
87
|
+
${styleText("yellow", "You may want to try:")}
|
|
87
88
|
- Checking your network connection
|
|
88
89
|
- Running the package manager command manually
|
|
89
90
|
- Ensuring you have permissions to install packages
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { styleText } from "node:util";
|
|
3
4
|
import { askToContinue, note } from "@withstudiocms/effect/clack";
|
|
4
5
|
import { diffWords } from "diff";
|
|
5
6
|
import { generateCode } from "magicast";
|
|
@@ -15,7 +16,6 @@ class UpdateStudioCMSConfig extends Effect.Service()(
|
|
|
15
16
|
const run = (configURL, mod) => genLogger("studiocms/cli/add/updateStudioCMSConfig/UpdateStudioCMSConfig.effect.run")(
|
|
16
17
|
function* () {
|
|
17
18
|
const context = yield* CliContext;
|
|
18
|
-
const { chalk } = context;
|
|
19
19
|
const input = yield* Effect.tryPromise(
|
|
20
20
|
() => fs.readFile(fileURLToPath(configURL), { encoding: "utf-8" })
|
|
21
21
|
);
|
|
@@ -46,7 +46,7 @@ ${boxenMessage}
|
|
|
46
46
|
`;
|
|
47
47
|
yield* note(
|
|
48
48
|
`
|
|
49
|
-
${
|
|
49
|
+
${styleText("magenta", "StudioCMS will make the following changes to your config file:")}
|
|
50
50
|
${message}`
|
|
51
51
|
);
|
|
52
52
|
if (yield* askToContinue()) {
|
|
@@ -66,7 +66,6 @@ ${message}`
|
|
|
66
66
|
) {
|
|
67
67
|
}
|
|
68
68
|
const getDiffContent = (input, output) => genLogger("studiocms/cli/add/updateStudioCMSConfig.getDiffContentNew")(function* () {
|
|
69
|
-
const { chalk } = yield* CliContext;
|
|
70
69
|
const changes = [];
|
|
71
70
|
for (const change of diffWords(input, output)) {
|
|
72
71
|
const lines = change.value.trim().split("\n").slice(0, change.count);
|
|
@@ -81,7 +80,7 @@ const getDiffContent = (input, output) => genLogger("studiocms/cli/add/updateStu
|
|
|
81
80
|
}
|
|
82
81
|
let diffed = output;
|
|
83
82
|
for (const newContent of changes) {
|
|
84
|
-
const coloredOutput = newContent.split("\n").map((ln) => ln ?
|
|
83
|
+
const coloredOutput = newContent.split("\n").map((ln) => ln ? styleText("green", ln) : "").join("\n");
|
|
85
84
|
diffed = diffed.replace(newContent, coloredOutput);
|
|
86
85
|
}
|
|
87
86
|
return diffed;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Effect } from '../../effect.js';
|
|
2
|
-
import { CliContext } from '../utils/context.js';
|
|
3
2
|
import { type PluginInfo } from './index.js';
|
|
4
3
|
declare const ValidatePlugins_base: Effect.Service.Class<ValidatePlugins, "ValidatePlugins", {
|
|
5
4
|
readonly effect: Effect.Effect<{
|
|
6
|
-
run: (names: string[]) => Effect.Effect<PluginInfo[], import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError | import("@withstudiocms/effect").DeepmergeError | import("@withstudiocms/effect/clack").ClackError,
|
|
5
|
+
run: (names: string[]) => Effect.Effect<PluginInfo[], import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError | import("@withstudiocms/effect").DeepmergeError | import("@withstudiocms/effect/clack").ClackError, never>;
|
|
7
6
|
}, never, never>;
|
|
8
7
|
}>;
|
|
9
8
|
export declare class ValidatePlugins extends ValidatePlugins_base {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
1
2
|
import { askToContinue, spinner } from "@withstudiocms/effect/clack";
|
|
2
3
|
import { Effect, genLogger } from "../../effect.js";
|
|
3
|
-
import { CliContext } from "../utils/context.js";
|
|
4
4
|
import { StudioCMSScopes } from "./index.js";
|
|
5
5
|
import { fetchPackageJson, parsePluginName } from "./npm-utils.js";
|
|
6
6
|
class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
|
|
7
7
|
effect: genLogger("studiocms/cli/add/validatePlugins/ValidatePlugins.effect")(function* () {
|
|
8
8
|
const run = (names) => genLogger("studiocms/cli/add/validatePlugins/ValidatePlugins.effect.run")(function* () {
|
|
9
|
-
const { chalk } = yield* CliContext;
|
|
10
9
|
const spin = yield* spinner();
|
|
11
10
|
yield* spin.start("Resolving packages...");
|
|
12
11
|
const entries = [];
|
|
13
12
|
for (const plugin of names) {
|
|
14
13
|
const parsed = yield* parsePluginName(plugin);
|
|
15
14
|
if (!parsed)
|
|
16
|
-
throw new Error(
|
|
15
|
+
throw new Error(
|
|
16
|
+
`${styleText("bold", plugin)} does not appear to be a valid package name!`
|
|
17
|
+
);
|
|
17
18
|
const { scope, name, tag } = parsed;
|
|
18
19
|
let pkgJson = {};
|
|
19
20
|
let pkgType;
|
|
@@ -23,14 +24,17 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
|
|
|
23
24
|
const firstPartyPkgCheck = yield* fetchPackageJson(scope, name, tag);
|
|
24
25
|
if (firstPartyPkgCheck instanceof Error) {
|
|
25
26
|
if (firstPartyPkgCheck.message) {
|
|
26
|
-
yield* spin.message(
|
|
27
|
+
yield* spin.message(styleText("yellow", firstPartyPkgCheck.message));
|
|
27
28
|
}
|
|
28
29
|
yield* spin.message(
|
|
29
|
-
|
|
30
|
+
styleText(
|
|
31
|
+
"yellow",
|
|
32
|
+
`${styleText("bold", plugin)} is not an official StudioCMS package.`
|
|
33
|
+
)
|
|
30
34
|
);
|
|
31
35
|
if (!(yield* askToContinue())) {
|
|
32
36
|
throw new Error(
|
|
33
|
-
`No problem! Find our official plugins at ${
|
|
37
|
+
`No problem! Find our official plugins at ${styleText("magenta", "https://docs.studiocms.dev")}`
|
|
34
38
|
);
|
|
35
39
|
}
|
|
36
40
|
yield* spin.start("Resolving with third party packages...");
|
|
@@ -44,9 +48,11 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
|
|
|
44
48
|
const thirdPartyPkgCheck = yield* fetchPackageJson(scope, name, tag);
|
|
45
49
|
if (thirdPartyPkgCheck instanceof Error) {
|
|
46
50
|
if (thirdPartyPkgCheck.message) {
|
|
47
|
-
yield* spin.message(
|
|
51
|
+
yield* spin.message(styleText("yellow", thirdPartyPkgCheck.message));
|
|
48
52
|
}
|
|
49
|
-
throw new Error(
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Unable to fetch ${styleText("bold", plugin)}. Does the package exist?`
|
|
55
|
+
);
|
|
50
56
|
}
|
|
51
57
|
pkgJson = thirdPartyPkgCheck;
|
|
52
58
|
}
|
|
@@ -67,7 +73,7 @@ class ValidatePlugins extends Effect.Service()("ValidatePlugins", {
|
|
|
67
73
|
const keywords = Array.isArray(pkgJson.keywords) ? pkgJson.keywords : [];
|
|
68
74
|
if (!keywords.includes("studiocms-plugin")) {
|
|
69
75
|
throw new Error(
|
|
70
|
-
`${
|
|
76
|
+
`${styleText("bold", plugin)} doesn't appear to be an StudioCMS Plugin. Find our official plugins at ${styleText("magenta", "https://docs.studiocms.dev")}`
|
|
71
77
|
);
|
|
72
78
|
}
|
|
73
79
|
entries.push({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { styleText } from "node:util";
|
|
2
3
|
import {
|
|
3
4
|
StudioCMSColorway,
|
|
4
5
|
StudioCMSColorwayBg,
|
|
@@ -9,7 +10,6 @@ import { intro, log, outro, spinner } from "@withstudiocms/effect/clack";
|
|
|
9
10
|
import { SignJWT } from "jose";
|
|
10
11
|
import { importPKCS8 } from "jose/key/import";
|
|
11
12
|
import { Cli, Effect, genLogger } from "../../../effect.js";
|
|
12
|
-
import { genContext } from "../../utils/context.js";
|
|
13
13
|
import { dateAdd } from "../../utils/dateAdd.js";
|
|
14
14
|
import { debug } from "../../utils/debugOpt.js";
|
|
15
15
|
import { StudioCMSCliError } from "../../utils/errors.js";
|
|
@@ -56,11 +56,8 @@ const genJWT = Cli.Command.make(
|
|
|
56
56
|
logger.debug(`Key file: ${keyFile2}`);
|
|
57
57
|
logger.debug(`Expiration: ${exp}`);
|
|
58
58
|
}
|
|
59
|
-
if (debug2) logger.debug("Getting context");
|
|
60
|
-
const context = yield* genContext;
|
|
61
|
-
const { chalk } = context;
|
|
62
59
|
if (debug2) logger.debug("Init complete, starting...");
|
|
63
|
-
yield* intro(label("StudioCMS Crypto: Generate JWT", StudioCMSColorwayBg,
|
|
60
|
+
yield* intro(label("StudioCMS Crypto: Generate JWT", StudioCMSColorwayBg, "bold"));
|
|
64
61
|
const spin = yield* spinner();
|
|
65
62
|
try {
|
|
66
63
|
yield* spin.start("Getting Key from keyFile");
|
|
@@ -89,14 +86,17 @@ const genJWT = Cli.Command.make(
|
|
|
89
86
|
const base64UrlJwt = yield* convertJwtToBase64Url(jwt);
|
|
90
87
|
yield* spin.stop("Token Generated.");
|
|
91
88
|
yield* log.success(
|
|
92
|
-
boxen(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
boxen(
|
|
90
|
+
styleText("bold", `${label("Token Generated!", StudioCMSColorwayInfoBg, "bold")}`),
|
|
91
|
+
{
|
|
92
|
+
ln1: "Your new Token has been generated successfully:",
|
|
93
|
+
ln3: `Token: ${styleText("magenta", jwt)}`,
|
|
94
|
+
ln5: `Base64Url Token: ${styleText("blue", base64UrlJwt)}`
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
97
|
);
|
|
98
98
|
yield* outro(
|
|
99
|
-
`${label("You can now use this token where needed.", StudioCMSColorwayBg,
|
|
99
|
+
`${label("You can now use this token where needed.", StudioCMSColorwayBg, "bold")} Stuck? Join us on Discord at ${StudioCMSColorway(styleText(["bold", "underline"], "https://chat.studiocms.dev"))}`
|
|
100
100
|
);
|
|
101
101
|
} catch (err) {
|
|
102
102
|
if (err instanceof Error) {
|
package/dist/cli/debug/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { loadConfigFile } from "@withstudiocms/config-utils";
|
|
|
5
5
|
import { Cli, Effect } from "@withstudiocms/effect";
|
|
6
6
|
import { intro, log, outro } from "@withstudiocms/effect/clack";
|
|
7
7
|
import { DebugInfoProvider } from "@withstudiocms/internal_helpers/debug-info-provider";
|
|
8
|
-
import chalk from "chalk";
|
|
9
8
|
import { debug } from "../utils/debugOpt.js";
|
|
10
9
|
import { StudioCMSCliError } from "../utils/errors.js";
|
|
11
10
|
const astroConfigPaths = [
|
|
@@ -42,7 +41,7 @@ const loadConfig = (key) => Effect.tryPromise({
|
|
|
42
41
|
const debugCMD = Cli.Command.make(
|
|
43
42
|
"debug",
|
|
44
43
|
{ debug },
|
|
45
|
-
({ debug: _debug })
|
|
44
|
+
Effect.fn(function* ({ debug: _debug }) {
|
|
46
45
|
let debug2;
|
|
47
46
|
if (typeof _debug !== "boolean") {
|
|
48
47
|
debug2 = yield* _debug;
|
|
@@ -88,7 +87,7 @@ const debugCMD = Cli.Command.make(
|
|
|
88
87
|
yield* Effect.log("Debug info gathered successfully.");
|
|
89
88
|
}
|
|
90
89
|
console.log("");
|
|
91
|
-
yield* intro(`${label("StudioCMS Debug Information", StudioCMSColorwayBg,
|
|
90
|
+
yield* intro(`${label("StudioCMS Debug Information", StudioCMSColorwayBg, "black")}`);
|
|
92
91
|
yield* log.info(debugInfo);
|
|
93
92
|
yield* outro();
|
|
94
93
|
if (debug2) {
|
|
@@ -10,7 +10,7 @@ const shell = Cli.Args.text({ name: "shell" }).pipe(
|
|
|
10
10
|
const getTurso = Cli.Command.make(
|
|
11
11
|
"get-turso",
|
|
12
12
|
{ shell },
|
|
13
|
-
({ shell: rawShell })
|
|
13
|
+
Effect.fn(function* ({ shell: rawShell }) {
|
|
14
14
|
let shell2;
|
|
15
15
|
if (typeof rawShell !== "string" && rawShell !== void 0) {
|
|
16
16
|
shell2 = yield* rawShell;
|
package/dist/cli/init/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const initCMD = Cli.Command.make(
|
|
|
39
39
|
debugLogger(`Options: ${JSON.stringify({ debug: debug2, dry }, null, 2)}`),
|
|
40
40
|
debugLogger(`Context: ${JSON.stringify(context, null, 2)}`),
|
|
41
41
|
intro(
|
|
42
|
-
`${label("StudioCMS", StudioCMSColorwayBg,
|
|
42
|
+
`${label("StudioCMS", StudioCMSColorwayBg, "black")} Interactive CLI - initializing...`
|
|
43
43
|
)
|
|
44
44
|
]);
|
|
45
45
|
yield* SCMS_Intro(debug2).pipe(cliContext);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { styleText } from "node:util";
|
|
4
5
|
import {
|
|
5
6
|
StudioCMSColorwayError,
|
|
6
7
|
StudioCMSColorwayInfo,
|
|
@@ -35,7 +36,7 @@ function NumberStringToUndefined(value) {
|
|
|
35
36
|
return Number.isNaN(num) ? void 0 : num;
|
|
36
37
|
}
|
|
37
38
|
const env = Effect.fn(function* (context, debug, dryRun) {
|
|
38
|
-
const {
|
|
39
|
+
const { cwd, pCancel, pOnCancel } = context;
|
|
39
40
|
const debugLogger = yield* buildDebugLogger(debug);
|
|
40
41
|
yield* debugLogger("Running env...");
|
|
41
42
|
let _env = false;
|
|
@@ -44,7 +45,7 @@ const env = Effect.fn(function* (context, debug, dryRun) {
|
|
|
44
45
|
yield* debugLogger(`Environment file exists: ${envExists}`);
|
|
45
46
|
if (envExists) {
|
|
46
47
|
yield* log.warn(
|
|
47
|
-
`${label("Warning", StudioCMSColorwayWarnBg,
|
|
48
|
+
`${label("Warning", StudioCMSColorwayWarnBg, "black")} An environment file already exists. Would you like to overwrite it?`
|
|
48
49
|
);
|
|
49
50
|
const confirm2 = yield* askToContinue();
|
|
50
51
|
if (!confirm2) {
|
|
@@ -428,14 +429,14 @@ const env = Effect.fn(function* (context, debug, dryRun) {
|
|
|
428
429
|
}
|
|
429
430
|
if (dryRun) {
|
|
430
431
|
context.tasks.push({
|
|
431
|
-
title: `${StudioCMSColorwayInfo
|
|
432
|
+
title: `${StudioCMSColorwayInfo(styleText("bold", "--dry-run"))} ${styleText("dim", "Skipping environment file creation")}`,
|
|
432
433
|
task: async (message) => {
|
|
433
434
|
message("Creating environment file... (skipped)");
|
|
434
435
|
}
|
|
435
436
|
});
|
|
436
437
|
} else if (_env) {
|
|
437
438
|
context.tasks.push({
|
|
438
|
-
title:
|
|
439
|
+
title: styleText("dim", "Creating environment file..."),
|
|
439
440
|
task: async (message) => {
|
|
440
441
|
try {
|
|
441
442
|
await fs.writeFile(path.join(cwd, ".env"), envFileContent, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
1
2
|
import {
|
|
2
3
|
StudioCMSColorway,
|
|
3
4
|
StudioCMSColorwayBg,
|
|
@@ -21,7 +22,7 @@ const runCmdMap = {
|
|
|
21
22
|
pnpm: "pnpm run"
|
|
22
23
|
};
|
|
23
24
|
const next = (debug) => genLogger("studiocms/cli/init/steps/next")(function* () {
|
|
24
|
-
const [{
|
|
25
|
+
const [{ packageManager }, debugLogger] = yield* Effect.all([
|
|
25
26
|
CliContext,
|
|
26
27
|
buildDebugLogger(debug)
|
|
27
28
|
]);
|
|
@@ -32,20 +33,21 @@ const next = (debug) => genLogger("studiocms/cli/init/steps/next")(function* ()
|
|
|
32
33
|
debugLogger("Running next steps fn..."),
|
|
33
34
|
log.success(
|
|
34
35
|
boxen(
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
styleText(
|
|
37
|
+
"bold",
|
|
38
|
+
`${label("Init Complete!", StudioCMSColorwayInfoBg, "bold")} Get started with StudioCMS:`
|
|
37
39
|
),
|
|
38
40
|
{
|
|
39
|
-
ln1: `Ensure your ${
|
|
40
|
-
ln3: `Run ${
|
|
41
|
-
ln4: `Run ${
|
|
41
|
+
ln1: `Ensure your ${styleText("cyanBright", ".env")} file is configured correctly.`,
|
|
42
|
+
ln3: `Run ${styleText("cyan", `${runCmd} studiocms migrate`)} to sync your database schema.`,
|
|
43
|
+
ln4: `Run ${styleText("cyan", devCmd)} to start the dev server. ${styleText("cyanBright", "CTRL+C")} to stop.`
|
|
42
44
|
}
|
|
43
45
|
)
|
|
44
46
|
)
|
|
45
47
|
]);
|
|
46
48
|
yield* Effect.all([
|
|
47
49
|
outro(
|
|
48
|
-
`${label("Enjoy your new CMS!", StudioCMSColorwayBg,
|
|
50
|
+
`${label("Enjoy your new CMS!", StudioCMSColorwayBg, "bold")} Stuck? Join us on Discord at ${StudioCMSColorway(styleText(["bold", "underline"], "https://chat.studiocms.dev"))}`
|
|
49
51
|
),
|
|
50
52
|
debugLogger("Next steps complete")
|
|
51
53
|
]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { styleText } from "node:util";
|
|
2
3
|
import { StudioCMSColorwayBg, StudioCMSColorwayInfoBg } from "@withstudiocms/cli-kit/colors";
|
|
3
4
|
import { label } from "@withstudiocms/cli-kit/messages";
|
|
4
5
|
import { Cli, Effect, runEffect } from "@withstudiocms/effect";
|
|
@@ -102,9 +103,7 @@ const migratorCMD = Cli.Command.make(
|
|
|
102
103
|
debugLogger("Starting interactive CLI..."),
|
|
103
104
|
debugLogger(`Options: ${JSON.stringify({ debug: debug2, rollback: rollback2 }, null, 2)}`),
|
|
104
105
|
debugLogger(`Context: ${JSON.stringify(context, null, 2)}`),
|
|
105
|
-
intro(
|
|
106
|
-
`${label("StudioCMS Migrator", StudioCMSColorwayBg, context.chalk.black)} - initializing...`
|
|
107
|
-
)
|
|
106
|
+
intro(`${label("StudioCMS Migrator", StudioCMSColorwayBg, "black")} - initializing...`)
|
|
108
107
|
]);
|
|
109
108
|
const isRollback = rollback2 && !latest2 && !status2;
|
|
110
109
|
const isLatest = !rollback2 && latest2 && !status2;
|
|
@@ -144,13 +143,13 @@ const migratorCMD = Cli.Command.make(
|
|
|
144
143
|
const migrationTotal = status3.length;
|
|
145
144
|
const appliedMigrations = status3.filter((m) => m.executedAt).length;
|
|
146
145
|
const migrationPercent = appliedMigrations / migrationTotal * 100;
|
|
147
|
-
const migrationTotalColor = migrationPercent === 100 ?
|
|
146
|
+
const migrationTotalColor = migrationPercent === 100 ? (text) => styleText("green", text) : migrationPercent > 50 ? (text) => styleText("yellow", text) : (text) => styleText("red", text);
|
|
148
147
|
const labelParts = [
|
|
149
|
-
label("Migration Status", StudioCMSColorwayInfoBg,
|
|
148
|
+
label("Migration Status", StudioCMSColorwayInfoBg, "black"),
|
|
150
149
|
label(
|
|
151
|
-
`(${
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
`(${styleText("green", appliedMigrations.toString())}/${migrationTotalColor(migrationTotal.toString())}) Applied`,
|
|
151
|
+
(text) => styleText("bold", text),
|
|
152
|
+
"black"
|
|
154
153
|
)
|
|
155
154
|
];
|
|
156
155
|
const responseMessage = `${labelParts.join(" ")}
|
package/dist/cli/users/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const usersCMD = Cli.Command.make(
|
|
|
51
51
|
yield* Effect.all([
|
|
52
52
|
debugLogger(`Context: ${JSON.stringify(context, null, 2)}`),
|
|
53
53
|
intro(
|
|
54
|
-
`${label("StudioCMS", StudioCMSColorwayBg,
|
|
54
|
+
`${label("StudioCMS", StudioCMSColorwayBg, "black")} Interactive CLI - initializing...`
|
|
55
55
|
),
|
|
56
56
|
checkRequiredEnvVarsEffect(["CMS_ENCRYPTION_KEY"])
|
|
57
57
|
]);
|
package/dist/cli/users/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
1
2
|
import { Effect } from "@withstudiocms/effect";
|
|
2
3
|
import { log } from "@withstudiocms/effect/clack";
|
|
3
|
-
|
|
4
|
-
const validateInputOrRePrompt = (opts) => Effect.gen(function* () {
|
|
4
|
+
const validateInputOrRePrompt = Effect.fn("validateInputOrRePrompt")(function* (opts) {
|
|
5
5
|
const { prompt, checkEffect } = opts;
|
|
6
6
|
while (true) {
|
|
7
7
|
const input = yield* prompt;
|
|
@@ -12,7 +12,7 @@ const validateInputOrRePrompt = (opts) => Effect.gen(function* () {
|
|
|
12
12
|
if (checkResult === true) {
|
|
13
13
|
return input;
|
|
14
14
|
}
|
|
15
|
-
yield* log.error(
|
|
15
|
+
yield* log.error(styleText("red", `Invalid input: ${checkResult}`));
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
export {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
1
2
|
import { getAvatarUrl } from "@withstudiocms/auth-kit/utils/libravatar";
|
|
2
3
|
import { StudioCMSColorwayInfo } from "@withstudiocms/cli-kit/colors";
|
|
3
4
|
import { group, log, password, select, text } from "@withstudiocms/effect/clack";
|
|
@@ -49,7 +50,7 @@ const createUsers = Effect.fn(function* (context, _debug, dryRun) {
|
|
|
49
50
|
message: "Username",
|
|
50
51
|
placeholder: "johndoe",
|
|
51
52
|
validate: (user) => {
|
|
52
|
-
const u = user
|
|
53
|
+
const u = user?.trim();
|
|
53
54
|
const isUser = currentUsers.find(({ username: username2 }) => username2 === u);
|
|
54
55
|
if (isUser) return "Username is already in use, please try another one";
|
|
55
56
|
return void 0;
|
|
@@ -89,7 +90,7 @@ const createUsers = Effect.fn(function* (context, _debug, dryRun) {
|
|
|
89
90
|
message: "E-Mail Address",
|
|
90
91
|
placeholder: "john@doe.tld",
|
|
91
92
|
validate: (email2) => {
|
|
92
|
-
const e = email2
|
|
93
|
+
const e = email2?.trim().toLowerCase();
|
|
93
94
|
const emailSchema = z.string().email({ message: "Email address is invalid" });
|
|
94
95
|
const response = emailSchema.safeParse(e);
|
|
95
96
|
if (!response.success) return response.error.message;
|
|
@@ -120,7 +121,7 @@ const createUsers = Effect.fn(function* (context, _debug, dryRun) {
|
|
|
120
121
|
);
|
|
121
122
|
const { confirmPassword, email, name, newPassword, rank, username } = inputData;
|
|
122
123
|
if (newPassword !== confirmPassword) {
|
|
123
|
-
yield* log.error(
|
|
124
|
+
yield* log.error(styleText("red", "Passwords do not match, exiting..."));
|
|
124
125
|
return yield* context.exit(1);
|
|
125
126
|
}
|
|
126
127
|
const newUserId = crypto.randomUUID();
|
|
@@ -150,14 +151,14 @@ const createUsers = Effect.fn(function* (context, _debug, dryRun) {
|
|
|
150
151
|
const todo = Effect.all([_createUser(newUser), _createRank(newRank)]);
|
|
151
152
|
if (dryRun) {
|
|
152
153
|
context.tasks.push({
|
|
153
|
-
title: `${StudioCMSColorwayInfo
|
|
154
|
+
title: `${StudioCMSColorwayInfo(styleText("bold", "--dry-run"))} ${styleText("dim", "Skipping user creation")}`,
|
|
154
155
|
task: async (message) => {
|
|
155
156
|
message("Creating user... (skipped)");
|
|
156
157
|
}
|
|
157
158
|
});
|
|
158
159
|
} else {
|
|
159
160
|
context.tasks.push({
|
|
160
|
-
title:
|
|
161
|
+
title: styleText("dim", "Creating user..."),
|
|
161
162
|
task: async (message) => {
|
|
162
163
|
try {
|
|
163
164
|
const [insertedUser, insertedRank] = await runEffect(todo);
|
|
@@ -165,7 +166,7 @@ const createUsers = Effect.fn(function* (context, _debug, dryRun) {
|
|
|
165
166
|
message("Failed to create user or assign permissions");
|
|
166
167
|
return await runEffect(context.exit(1));
|
|
167
168
|
}
|
|
168
|
-
message(
|
|
169
|
+
message(styleText("green", "User created successfully!"));
|
|
169
170
|
} catch (error) {
|
|
170
171
|
await runEffect(log.error(`Failed to create user: ${error.message}`));
|
|
171
172
|
return await runEffect(context.exit(1));
|