Skip to content

Commit b4ce588

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth
2 parents fb6c0ed + 6d7f540 commit b4ce588

5 files changed

Lines changed: 76 additions & 34 deletions

File tree

adminforth/commands/createApp/utils.js

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -487,32 +487,42 @@ async function writeTemplateFiles(dirname, cwd, useNpm, includePrismaMigrations,
487487
}
488488
}
489489

490-
async function resolvePackageManagerCommand(packageManager) {
491-
if (packageManager !== 'pnpm') {
492-
return packageManager;
493-
}
494-
495-
try {
496-
await execAsync('pnpm --version', { env: process.env });
497-
return 'pnpm';
498-
} catch {
499-
try {
500-
await execAsync('corepack pnpm --version', { env: process.env });
501-
return 'corepack pnpm';
502-
} catch {
503-
throw new Error('pnpm is not available. Install pnpm globally or enable Corepack before creating a pnpm project.');
504-
}
490+
async function installDependenciesPnpm(ctx, cwd) {
491+
const isWindows = process.platform === 'win32';
492+
493+
const nodeBinary = process.execPath;
494+
const pnpmPath = path.join(path.dirname(nodeBinary), isWindows ? 'pnpm.cmd' : 'pnpm');
495+
const customDir = ctx.customDir;
496+
if (isWindows) {
497+
const res = await Promise.all([
498+
execAsync(`pnpm install`, { cwd, env: { PATH: process.env.PATH } }),
499+
execAsync(`pnpm install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
500+
]);
501+
} else {
502+
const res = await Promise.all([
503+
execAsync(`${nodeBinary} ${pnpmPath} install`, { cwd, env: { PATH: process.env.PATH } }),
504+
execAsync(`${nodeBinary} ${pnpmPath} install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
505+
]);
505506
}
506507
}
507508

508-
async function installDependencies(ctx, cwd, packageManager) {
509-
const packageManagerCommand = await resolvePackageManagerCommand(packageManager);
510-
const command = `${packageManagerCommand} install`;
511-
512-
await Promise.all([
513-
execAsync(command, { cwd, env: process.env }),
514-
execAsync(command, { cwd: ctx.customDir, env: process.env }),
515-
]);
509+
async function installDependenciesNpm(ctx, cwd) {
510+
const isWindows = process.platform === 'win32';
511+
512+
const nodeBinary = process.execPath;
513+
const npmPath = path.join(path.dirname(nodeBinary), isWindows ? 'npm.cmd' : 'npm');
514+
const customDir = ctx.customDir;
515+
if (isWindows) {
516+
const res = await Promise.all([
517+
execAsync(`npm install`, { cwd, env: { PATH: process.env.PATH } }),
518+
execAsync(`npm install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
519+
]);
520+
} else {
521+
const res = await Promise.all([
522+
execAsync(`${nodeBinary} ${npmPath} install`, { cwd, env: { PATH: process.env.PATH } }),
523+
execAsync(`${nodeBinary} ${npmPath} install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
524+
]);
525+
}
516526
}
517527

518528
function generateFinalInstructionsPnpm(skipPrismaSetup, options) {
@@ -586,7 +596,11 @@ export function prepareWorkflow(options) {
586596
{
587597
title: '📦 Installing dependencies...',
588598
task: async (ctx) => {
589-
await installDependencies(ctx, ctx.projectDir, options.useNpm ? 'npm' : 'pnpm');
599+
if (options.useNpm) {
600+
await installDependenciesNpm(ctx, ctx.projectDir);
601+
} else {
602+
await installDependenciesPnpm(ctx, ctx.projectDir);
603+
}
590604
}
591605
},
592606
{

adminforth/documentation/docs/tutorial/03-Customization/15-afcl.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ import { Button } from '@/afcl'
4141

4242
loader prop would show loader when it's true.
4343

44+
### Variant
45+
46+
The `variant` prop controls the button style. Possible values are `primary` (default), `secondary` and `danger`.
47+
48+
<div class="split-screen" >
49+
<div >
50+
51+
```html
52+
<Button @click="doSmth">
53+
Primary button
54+
</Button>
55+
56+
<Button @click="doSmth" variant="secondary" class="mt-4">
57+
Secondary button
58+
</Button>
59+
60+
<Button @click="doSmth" variant="danger" class="mt-4">
61+
Danger button
62+
</Button>
63+
```
64+
</div>
65+
</div>
66+
67+
> ☝️ The `mode` prop is deprecated, use `variant` instead.
68+
4469
## Button Group
4570
### With active button
4671
<div class="split-screen" >

adminforth/spa/src/afcl/Dropzone.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@dragleave.prevent="dragging = false"
66
@drop.prevent="dragging = false; doEmit(($event.dataTransfer as DataTransfer).files)"
77
>
8-
<label :id="id" class="flex flex-col items-center justify-center w-full border-2 border-dashed rounded-lg cursor-pointer
8+
<label :id="id" class="flex flex-col items-center justify-center w-full border-2 border-dashed rounded-default cursor-pointer
99
hover:bg-lightDropzoneBackgroundHover hover:border-lightDropzoneBorderHover dark:hover:border-darkDropzoneBorderHover dark:hover:bg-darkDropzoneBackgroundHover"
1010
:class="{
1111
'border-lightDropzoneBorderDragging dark:border-darkDropzoneBorderDragging': dragging,
@@ -50,7 +50,7 @@
5050
>
5151
<template v-for="(file, index) in selectedFiles" :key="index">
5252
<div
53-
class="text-sm text-lightDropzoneIcon dark:text-darkDropzoneIcon bg-lightDropzoneBackgroundHover dark:bg-darkDropzoneBackgroundHover rounded-md
53+
class="text-sm text-lightDropzoneIcon dark:text-darkDropzoneIcon bg-lightDropzoneBackgroundHover dark:bg-darkDropzoneBackgroundHover rounded-default
5454
flex items-center gap-1 px-2 py-1 group"
5555
>
5656
<IconFileSolid class="w-4 h-4 flex-shrink-0" />

adminforth/spa/src/afcl/ProgressBar.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
22
<div class="relative w-full bg-lightProgressBarUnfilledColor rounded-full h-2.5 dark:bg-darkProgressBarUnfilledColor" :class="props.height ? `h-${props.height}` : ''">
3-
<span v-if="leftLabel" class="absolute -top-6 left-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ leftLabel }}</span>
4-
<span v-if="rightLabel" class="absolute -top-6 right-0 text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ rightLabel }}</span>
5-
<div
3+
<span v-if="leftLabel" class="absolute -top-6 left-0 text-sm" :class="textClass">{{ leftLabel }}</span>
4+
<span v-if="rightLabel" class="absolute -top-6 right-0 text-sm" :class="textClass">{{ rightLabel }}</span>
5+
<div
66
class="bg-lightPrimary dark:bg-darkPrimary h-2.5 rounded-full transition-all duration-300 ease-in-out"
7-
:class="{ 'progress-bar': showAnimation, [`h-${props.height}`]: props.height }"
7+
:class="{ 'progress-bar': showAnimation, [`h-${props.height}`]: props.height }"
88
:style="{ width: `${percentage}%` }"
99
></div>
1010
<div v-if="showValues || showProgress" class="flex justify-between mt-2">
11-
<span v-if="showValues" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ formatValue(minValue) }}</span>
12-
<span v-if="showProgress" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ progressText }}</span>
13-
<span v-if="showValues" class="text-sm text-lightProgressBarText dark:text-darkProgressBarText">{{ formatValue(maxValue) }}</span>
11+
<span v-if="showValues" class="text-sm" :class="textClass">{{ formatValue(minValue) }}</span>
12+
<span v-if="showProgress" class="text-sm" :class="textClass">{{ progressText }}</span>
13+
<span v-if="showValues" class="text-sm" :class="textClass">{{ formatValue(maxValue) }}</span>
1414
</div>
1515
</div>
1616
</template>
@@ -31,6 +31,7 @@ interface Props {
3131
showProgress?: boolean
3232
showAnimation?: boolean
3333
height?: number
34+
textClass?: string
3435
}
3536
3637
const props = withDefaults(defineProps<Props>(), {
@@ -39,7 +40,8 @@ const props = withDefaults(defineProps<Props>(), {
3940
formatter: (value: number) => `${value}`,
4041
progressFormatter: (value: number, percentage: number) => `${value}`,
4142
showValues: true,
42-
showProgress: true
43+
showProgress: true,
44+
textClass: 'text-lightProgressBarText dark:text-darkProgressBarText',
4345
})
4446
4547
const percentage = computed((): number => {

dev-demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"scripts": {
88
"_env:dev": "dotenvx run -f .env.local -f .env --overload --",
99
"start": "pnpm _env:dev tsx watch index.ts",
10+
"dev": "pnpm _env:dev tsx watch index.ts",
1011
"makemigration:sqlite": "pnpm _env:dev pnpm exec prisma migrate dev --create-only --config=./migrations/prisma/sqlite/prisma.config.ts --schema=./migrations/prisma/sqlite/schema.prisma",
1112
"migrate:sqlite": "pnpm _env:dev pnpm exec prisma migrate deploy --config=./migrations/prisma/sqlite/prisma.config.ts --schema=./migrations/prisma/sqlite/schema.prisma",
1213
"makemigration:mysql": "pnpm _env:dev pnpm exec prisma migrate dev --create-only --config=./migrations/prisma/mysql/prisma.config.ts --schema=./migrations/prisma/mysql/schema.mysql.prisma",

0 commit comments

Comments
 (0)