create-foldkit-app 0.27.1 → 0.27.3

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.
@@ -84,9 +84,9 @@ const setupProject = (name, projectPath, scaffold, packageManager) => Effect.gen
84
84
  yield* Console.log(chalk.green(`✅ Created project`));
85
85
  yield* Console.log('');
86
86
  });
87
- const installProjectDependencies = (projectPath, packageManager, scaffold) => Effect.gen(function* () {
87
+ const installProjectDependencies = (projectPath, packageManager, scaffold, maybeDependencyManifestsDirectory) => Effect.gen(function* () {
88
88
  yield* Console.log(chalk.blue(`📦 Installing dependencies with ${packageManager}...`));
89
- yield* installDependencies(projectPath, packageManager, scaffold);
89
+ yield* installDependencies(projectPath, packageManager, scaffold, maybeDependencyManifestsDirectory);
90
90
  yield* Console.log(chalk.green('✅ Dependencies installed'));
91
91
  yield* Console.log('');
92
92
  });
@@ -132,10 +132,14 @@ const displaySuccessMessage = (name, packageManager) => Effect.gen(function* ()
132
132
  export const create = (input) => Effect.gen(function* () {
133
133
  const { name, scaffold, packageManager } = yield* resolveInput(input);
134
134
  const path = yield* Path.Path;
135
+ if (Option.isSome(input.maybeDependencyManifestsDirectory) &&
136
+ !path.isAbsolute(input.maybeDependencyManifestsDirectory.value)) {
137
+ return yield* Effect.fail('CREATE_FOLDKIT_APP_DEPENDENCY_MANIFESTS_DIRECTORY must be an absolute path.');
138
+ }
135
139
  const projectPath = path.resolve(name);
136
140
  yield* validateProject(name, projectPath, packageManager);
137
141
  yield* setupProject(name, projectPath, scaffold, packageManager);
138
- yield* installProjectDependencies(projectPath, packageManager, scaffold);
142
+ yield* installProjectDependencies(projectPath, packageManager, scaffold, input.maybeDependencyManifestsDirectory);
139
143
  yield* displaySuccessMessage(name, packageManager);
140
144
  return name;
141
145
  });
package/dist/index.js CHANGED
@@ -23,12 +23,13 @@ const packageManager = Flag.choice('package-manager', [
23
23
  'yarn',
24
24
  'bun',
25
25
  ]).pipe(Flag.withAlias('p'), Flag.withDescription('The package manager to use for installing dependencies'), Flag.optional);
26
+ const maybeDependencyManifestsDirectory = Option.fromNullishOr(process.env['CREATE_FOLDKIT_APP_DEPENDENCY_MANIFESTS_DIRECTORY']);
26
27
  const create = Command.make('create', {
27
28
  name,
28
29
  rendering,
29
30
  example,
30
31
  packageManager,
31
- }, create_).pipe(Command.withDescription('Create a new Foldkit application'));
32
+ }, input => create_({ ...input, maybeDependencyManifestsDirectory })).pipe(Command.withDescription('Create a new Foldkit application'));
32
33
  const cli = Command.run(create, {
33
34
  version: packageJson.version,
34
35
  });
@@ -1,4 +1,4 @@
1
- import { Array, Data, Effect, FileSystem, Match, Order, Path, Record, Result, Schema, pipe, } from 'effect';
1
+ import { Array, Data, Effect, FileSystem, Match, Option, 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
4
  export const installCommand = (packageManager) => `${packageManager} install`;
@@ -122,6 +122,15 @@ const fetchExamplePackageJson = (example) => Effect.gen(function* () {
122
122
  const json = yield* response.json;
123
123
  return yield* Schema.decodeUnknownEffect(PackageJson)(json);
124
124
  });
125
+ const readExamplePackageJson = (example, maybeDependencyManifestsDirectory) => Option.match(maybeDependencyManifestsDirectory, {
126
+ onNone: () => fetchExamplePackageJson(example),
127
+ onSome: directory => Effect.gen(function* () {
128
+ const fs = yield* FileSystem.FileSystem;
129
+ const path = yield* Path.Path;
130
+ const content = yield* fs.readFileString(path.join(directory, example, 'package.json'));
131
+ return yield* Schema.decodeUnknownEffect(PackageJson)(JSON.parse(content));
132
+ }),
133
+ });
125
134
  const writeManifest = (projectPath, dependencies, devDependencies) => Effect.gen(function* () {
126
135
  const fs = yield* FileSystem.FileSystem;
127
136
  const path = yield* Path.Path;
@@ -159,8 +168,8 @@ const runCommand = (command, args, cwd) => Effect.callback((resume) => {
159
168
  }
160
169
  });
161
170
  });
162
- export const installDependencies = (projectPath, packageManager, scaffold) => Effect.gen(function* () {
163
- const examplePackageJson = yield* fetchExamplePackageJson(dependencyExample(scaffold));
171
+ export const installDependencies = (projectPath, packageManager, scaffold, maybeDependencyManifestsDirectory) => Effect.gen(function* () {
172
+ const examplePackageJson = yield* readExamplePackageJson(dependencyExample(scaffold), maybeDependencyManifestsDirectory);
164
173
  const dependencies = yield* resolveSpecs(buildUnresolvedDeps(examplePackageJson.dependencies));
165
174
  const devDependencies = yield* resolveSpecs(buildUnresolvedDevDeps(examplePackageJson.devDependencies, scaffoldDevDependencies(scaffold)));
166
175
  yield* writeManifest(projectPath, sortDependencies(dependencies), sortDependencies(devDependencies));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-foldkit-app",
3
- "version": "0.27.1",
3
+ "version": "0.27.3",
4
4
  "description": "Create Foldkit applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,5 +11,5 @@ A Foldkit application built with Effect.
11
11
 
12
12
  ## Learn More
13
13
 
14
- - [Foldkit Documentation](https://github.com/foldkit/foldkit)
14
+ - [Foldkit Documentation](https://foldkit.dev)
15
15
  - [Effect Documentation](https://effect.website)
@@ -57,5 +57,5 @@ build script generate one.
57
57
 
58
58
  ## Learn More
59
59
 
60
- - [Foldkit Documentation](https://github.com/foldkit/foldkit)
60
+ - [Foldkit Documentation](https://foldkit.dev)
61
61
  - [Effect Documentation](https://effect.website)
@@ -1,20 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process'
2
2
  import { randomUUID } from 'node:crypto'
3
3
 
4
- // NOTE: one id names this build, and every command below is given that same
5
- // id, so the client bundle and the server bundle of a deployment agree on which
6
- // deployment they are. `renderToString` stamps it on the prerendered pages and
7
- // `Runtime.hydrate` compares it before adopting any DOM, so a page left over
8
- // from an earlier deployment is refused and contained rather than reconciled
9
- // against a client that no longer means the same thing by it.
10
- //
11
- // The id is published in the HTML every visitor receives. It identifies a
12
- // deployment and is never a credential, so keep secrets out of it. Set
13
- // FOLDKIT_BUILD_ID to name builds from a value the deployment already has, such
14
- // as a commit or a release tag; without one, each build takes a fresh id.
15
- // NOTE: `??` alone would take an empty FOLDKIT_BUILD_ID as a real value, and
16
- // the plugin treats empty as absent, so the build would compile no id at all and
17
- // fail later at the render. Empty is unset here too.
4
+ // NOTE: one nonempty id must reach every step in this build.
18
5
  const supplied = process.env.FOLDKIT_BUILD_ID
19
6
  const buildId =
20
7
  supplied === undefined || supplied === '' ? randomUUID() : supplied
@@ -61,5 +61,5 @@ and let the build script generate one.
61
61
 
62
62
  ## Learn More
63
63
 
64
- - [Foldkit Documentation](https://github.com/foldkit/foldkit)
64
+ - [Foldkit Documentation](https://foldkit.dev)
65
65
  - [Effect Documentation](https://effect.website)
@@ -1,20 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process'
2
2
  import { randomUUID } from 'node:crypto'
3
3
 
4
- // NOTE: one id names this build, and every command below is given that same
5
- // id, so the client bundle and the server bundle of a deployment agree on which
6
- // deployment they are. `renderToString` stamps it on the rendered root and
7
- // `Runtime.hydrate` compares it before adopting any DOM, so a page left over
8
- // from an earlier deployment is refused and contained rather than reconciled
9
- // against a client that no longer means the same thing by it.
10
- //
11
- // The id is published in the HTML every visitor receives. It identifies a
12
- // deployment and is never a credential, so keep secrets out of it. Set
13
- // FOLDKIT_BUILD_ID to name builds from a value the deployment already has, such
14
- // as a commit or a release tag; without one, each build takes a fresh id.
15
- // NOTE: `??` alone would take an empty FOLDKIT_BUILD_ID as a real value, and
16
- // the plugin treats empty as absent, so the build would compile no id at all and
17
- // fail later at the render. Empty is unset here too.
4
+ // NOTE: one nonempty id must reach every step in this build.
18
5
  const supplied = process.env.FOLDKIT_BUILD_ID
19
6
  const buildId =
20
7
  supplied === undefined || supplied === '' ? randomUUID() : supplied