create-foldkit-app 0.20.0 → 0.20.1
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/commands/create.js +3 -4
- package/dist/utils/files.js +9 -5
- package/dist/utils/packages.js +8 -0
- package/package.json +1 -1
- package/templates/base/README.md +2 -2
- package/templates/base/gitignore +3 -0
- package/templates/base/package.json +2 -2
- package/templates/base/vitest.config.ts +1 -0
package/dist/commands/create.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { Console, Effect, FileSystem,
|
|
2
|
+
import { Console, Effect, FileSystem, Option, Path } from 'effect';
|
|
3
3
|
import { Prompt } from 'effect/unstable/cli';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
import { examples } from '../examples.js';
|
|
6
6
|
import { createProject } from '../utils/files.js';
|
|
7
|
-
import { installDependencies } from '../utils/packages.js';
|
|
7
|
+
import { devCommand, installDependencies, } from '../utils/packages.js';
|
|
8
8
|
import { validateProjectName } from '../validateName.js';
|
|
9
9
|
const isWindows = process.platform === 'win32';
|
|
10
10
|
const promptForName = Prompt.text({
|
|
@@ -73,12 +73,11 @@ const installProjectDependencies = (projectPath, packageManager, example) => Eff
|
|
|
73
73
|
yield* Console.log(chalk.green('✅ Dependencies installed'));
|
|
74
74
|
yield* Console.log('');
|
|
75
75
|
});
|
|
76
|
-
const runDevServerCommand = (packageManager) => Match.value(packageManager).pipe(Match.when('pnpm', () => 'pnpm dev'), Match.when('npm', () => 'npm run dev'), Match.when('yarn', () => 'yarn dev'), Match.when('bun', () => 'bun dev'), Match.exhaustive);
|
|
77
76
|
const displaySuccessMessage = (name, packageManager) => Effect.gen(function* () {
|
|
78
77
|
yield* Console.log(chalk.bold('All systems nominal.'));
|
|
79
78
|
yield* Console.log('');
|
|
80
79
|
yield* Console.log(` > ${chalk.cyan('cd')} ${name}`);
|
|
81
|
-
yield* Console.log(` > ${chalk.cyan(
|
|
80
|
+
yield* Console.log(` > ${chalk.cyan(devCommand(packageManager))}`);
|
|
82
81
|
yield* Console.log('');
|
|
83
82
|
yield* Console.log(chalk.bold('AI-Assisted Development'));
|
|
84
83
|
yield* Console.log('');
|
package/dist/utils/files.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Array, Effect, FileSystem, Match, Option, Path, Record, Ref, Schema, String, pipe, } from 'effect';
|
|
2
2
|
import { HttpClient, HttpClientRequest, } from 'effect/unstable/http';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { devCommand, installCommand } from './packages.js';
|
|
4
5
|
const GITHUB_API_BASE_URL = 'https://api.github.com/repos/foldkit/foldkit/contents/examples';
|
|
5
6
|
const getTemplateRoot = Effect.gen(function* () {
|
|
6
7
|
const path = yield* Path.Path;
|
|
@@ -73,17 +74,20 @@ const createPackageManagerFiles = (projectPath, packageManager) => Effect.gen(fu
|
|
|
73
74
|
});
|
|
74
75
|
export const createProject = (name, projectPath, example, packageManager) => Effect.gen(function* () {
|
|
75
76
|
yield* createBaseFiles(projectPath);
|
|
76
|
-
yield* modifyBaseFiles(projectPath, name);
|
|
77
|
+
yield* modifyBaseFiles(projectPath, name, packageManager);
|
|
77
78
|
yield* createPackageManagerFiles(projectPath, packageManager);
|
|
78
79
|
yield* createExampleFiles(projectPath, example);
|
|
79
80
|
});
|
|
80
|
-
const
|
|
81
|
+
export const applyPackageManager = (readme, packageManager) => pipe(readme, String.replace('{{installCommand}}', installCommand(packageManager)), String.replace('{{devCommand}}', devCommand(packageManager)));
|
|
82
|
+
const modifyBaseFiles = (projectPath, name, packageManager) => Effect.gen(function* () {
|
|
81
83
|
const fs = yield* FileSystem.FileSystem;
|
|
82
84
|
const path = yield* Path.Path;
|
|
83
85
|
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const packageJson = yield* fs.readFileString(packageJsonPath);
|
|
87
|
+
yield* fs.writeFileString(packageJsonPath, String.replace('{{name}}', name)(packageJson));
|
|
88
|
+
const readmePath = path.join(projectPath, 'README.md');
|
|
89
|
+
const readme = yield* fs.readFileString(readmePath);
|
|
90
|
+
yield* fs.writeFileString(readmePath, applyPackageManager(readme, packageManager));
|
|
87
91
|
});
|
|
88
92
|
const GitHubFileEntry = Schema.Struct({
|
|
89
93
|
name: Schema.String,
|
package/dist/utils/packages.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Array, Effect, FileSystem, Match, Order, Path, Record, Result, Schema, pipe, } from 'effect';
|
|
2
2
|
import { HttpClient, HttpClientRequest } from 'effect/unstable/http';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
|
+
export const installCommand = (packageManager) => `${packageManager} install`;
|
|
5
|
+
const DEV_COMMANDS = {
|
|
6
|
+
pnpm: 'pnpm dev',
|
|
7
|
+
npm: 'npm run dev',
|
|
8
|
+
yarn: 'yarn dev',
|
|
9
|
+
bun: 'bun dev',
|
|
10
|
+
};
|
|
11
|
+
export const devCommand = (packageManager) => DEV_COMMANDS[packageManager];
|
|
4
12
|
const GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com/foldkit/foldkit/main/examples';
|
|
5
13
|
const NPM_REGISTRY_BASE_URL = 'https://registry.npmjs.org';
|
|
6
14
|
const FOLDKIT_SCOPE_PREFIX = '@foldkit/';
|
package/package.json
CHANGED
package/templates/base/README.md
CHANGED
package/templates/base/gitignore
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "{{name}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
10
10
|
"format": "prettier -w .",
|
|
11
11
|
"test": "vitest run",
|
|
12
|
-
"lint": "oxlint"
|
|
12
|
+
"lint": "oxlint src"
|
|
13
13
|
}
|
|
14
14
|
}
|