create-foldkit-app 0.2.3 → 0.3.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 -3
- package/dist/index.js +9 -3
- package/dist/utils/files.js +4 -2
- package/dist/utils/packages.js +24 -5
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -19,9 +19,9 @@ const setupProject = (name, projectPath, example) => Effect.gen(function* () {
|
|
|
19
19
|
yield* Console.log(chalk.green(`✅ Created project`));
|
|
20
20
|
yield* Console.log('');
|
|
21
21
|
});
|
|
22
|
-
const installProjectDependencies = (projectPath, packageManager) => Effect.gen(function* () {
|
|
22
|
+
const installProjectDependencies = (projectPath, packageManager, example) => Effect.gen(function* () {
|
|
23
23
|
yield* Console.log(chalk.blue(`📦 Installing dependencies with ${packageManager}...`));
|
|
24
|
-
yield* installDependencies(projectPath, packageManager);
|
|
24
|
+
yield* installDependencies(projectPath, packageManager, example);
|
|
25
25
|
yield* Console.log(chalk.green('✅ Dependencies installed'));
|
|
26
26
|
yield* Console.log('');
|
|
27
27
|
});
|
|
@@ -40,7 +40,7 @@ export const create = ({ name, example, packageManager }) => Effect.gen(function
|
|
|
40
40
|
const projectPath = path.resolve(name);
|
|
41
41
|
yield* validateProject(name, projectPath, packageManager);
|
|
42
42
|
yield* setupProject(name, projectPath, example);
|
|
43
|
-
yield* installProjectDependencies(projectPath, packageManager);
|
|
43
|
+
yield* installProjectDependencies(projectPath, packageManager, example);
|
|
44
44
|
yield* displaySuccessMessage(name, packageManager);
|
|
45
45
|
return name;
|
|
46
46
|
});
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const example = Options.choice('example', [
|
|
|
16
16
|
'routing',
|
|
17
17
|
'shopping-cart',
|
|
18
18
|
'websocket-chat',
|
|
19
|
+
'auth',
|
|
19
20
|
]).pipe(Options.withAlias('e'), Options.withDescription("The example application to start from. Pick an example that's similar to the application you're building. Or create multiple projects and take pieces of each!\n\n" +
|
|
20
21
|
'Available examples:\n' +
|
|
21
22
|
' counter - Simple increment/decrement with reset\n' +
|
|
@@ -26,8 +27,13 @@ const example = Options.choice('example', [
|
|
|
26
27
|
' snake - Classic game built with command streams\n' +
|
|
27
28
|
' routing - URL routing with parser combinators and route parameters\n' +
|
|
28
29
|
' shopping-cart - Complex state management with nested models and routing\n' +
|
|
29
|
-
' websocket-chat - WebSocket integration'
|
|
30
|
-
|
|
30
|
+
' websocket-chat - WebSocket integration\n' +
|
|
31
|
+
' auth - Authentication with Model-as-Union pattern and protected routes'));
|
|
32
|
+
const packageManager = Options.choice('package-manager', [
|
|
33
|
+
'pnpm',
|
|
34
|
+
'npm',
|
|
35
|
+
'yarn',
|
|
36
|
+
]).pipe(Options.withAlias('p'), Options.withDescription('The package manager to use for installing dependencies'));
|
|
31
37
|
const create = Command.make('create', {
|
|
32
38
|
name,
|
|
33
39
|
example,
|
|
@@ -35,7 +41,7 @@ const create = Command.make('create', {
|
|
|
35
41
|
}, create_);
|
|
36
42
|
const cli = Command.run(create, {
|
|
37
43
|
name: 'Create Foldkit App',
|
|
38
|
-
version: '0.
|
|
44
|
+
version: '0.3.1',
|
|
39
45
|
summary: HelpDoc.getSpan(HelpDoc.p('Create a new Foldkit application')),
|
|
40
46
|
});
|
|
41
47
|
cli(process.argv).pipe(Effect.provide([FetchHttpClient.layer, NodeContext.layer]), NodeRuntime.runMain);
|
package/dist/utils/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileSystem, HttpClient, HttpClientRequest, Path, } from '@effect/platform';
|
|
2
|
-
import { Array, Effect, Match, Option, Record, Ref, Schema, String, pipe } from 'effect';
|
|
2
|
+
import { Array, Effect, Match, Option, Record, Ref, Schema, String, pipe, } from 'effect';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
const GITHUB_API_BASE_URL = 'https://api.github.com/repos/devinjameson/foldkit/contents/examples';
|
|
5
5
|
const getBaseFiles = Effect.gen(function* () {
|
|
@@ -22,7 +22,9 @@ const getBaseFiles = Effect.gen(function* () {
|
|
|
22
22
|
});
|
|
23
23
|
const processDirectory = (dir) => Effect.gen(function* () {
|
|
24
24
|
const entries = yield* fs.readDirectory(dir);
|
|
25
|
-
yield* Effect.forEach(entries, processEntry(dir), {
|
|
25
|
+
yield* Effect.forEach(entries, processEntry(dir), {
|
|
26
|
+
concurrency: 'unbounded',
|
|
27
|
+
});
|
|
26
28
|
});
|
|
27
29
|
yield* processDirectory(templatesDir);
|
|
28
30
|
return yield* Ref.get(fileContentByPath);
|
package/dist/utils/packages.js
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import { Command } from '@effect/platform';
|
|
2
|
-
import { Effect, Match, pipe } from 'effect';
|
|
1
|
+
import { Command, HttpClient, HttpClientRequest } from '@effect/platform';
|
|
2
|
+
import { Array, Effect, Match, Record, Schema, pipe } from 'effect';
|
|
3
|
+
const GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com/devinjameson/foldkit/main/examples';
|
|
3
4
|
const getInstallArgs = (packageManager, isDev = false) => pipe(Match.value(packageManager), Match.when('npm', () => ['install']), Match.when('yarn', () => ['add']), Match.when('pnpm', () => ['add']), Match.exhaustive, (args) => (isDev ? [...args, '-D'] : args));
|
|
4
|
-
|
|
5
|
+
const StringRecord = Schema.Record({ key: Schema.String, value: Schema.String });
|
|
6
|
+
const PackageJson = Schema.Struct({
|
|
7
|
+
dependencies: Schema.optionalWith(StringRecord, { default: () => ({}) }),
|
|
8
|
+
devDependencies: Schema.optionalWith(StringRecord, { default: () => ({}) }),
|
|
9
|
+
});
|
|
10
|
+
const formatDeps = (deps) => pipe(deps, Record.toEntries, Array.filter(([_, version]) => !version.includes('workspace:')), Array.map(([name, version]) => `${name}@${version}`));
|
|
11
|
+
const fetchExampleDeps = (example) => Effect.gen(function* () {
|
|
12
|
+
const client = yield* HttpClient.HttpClient;
|
|
13
|
+
const url = `${GITHUB_RAW_BASE_URL}/${example}/package.json`;
|
|
14
|
+
const response = yield* client.execute(HttpClientRequest.get(url));
|
|
15
|
+
const json = yield* response.json;
|
|
16
|
+
const packageJson = yield* Schema.decodeUnknown(PackageJson)(json);
|
|
17
|
+
return {
|
|
18
|
+
dependencies: formatDeps(packageJson.dependencies),
|
|
19
|
+
devDependencies: formatDeps(packageJson.devDependencies),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
export const installDependencies = (projectPath, packageManager, example) => Effect.gen(function* () {
|
|
23
|
+
const exampleDeps = yield* fetchExampleDeps(example);
|
|
5
24
|
const installArgs = getInstallArgs(packageManager);
|
|
6
|
-
const installDeps = Command.make(packageManager, ...installArgs, 'foldkit',
|
|
25
|
+
const installDeps = Command.make(packageManager, ...installArgs, 'foldkit', ...exampleDeps.dependencies).pipe(Command.workingDirectory(projectPath), Command.stdout('inherit'), Command.stderr('inherit'));
|
|
7
26
|
yield* Command.exitCode(installDeps);
|
|
8
27
|
const installDevArgs = getInstallArgs(packageManager, true);
|
|
9
|
-
const installDevDeps = Command.make(packageManager, ...installDevArgs, '@foldkit/vite-plugin
|
|
28
|
+
const installDevDeps = Command.make(packageManager, ...installDevArgs, '@foldkit/vite-plugin', ...exampleDeps.devDependencies).pipe(Command.workingDirectory(projectPath), Command.stdout('inherit'), Command.stderr('inherit'));
|
|
10
29
|
yield* Command.exitCode(installDevDeps);
|
|
11
30
|
});
|