Skip to content

Commit

Permalink
Fixes for "create" when published (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauckhart authored Oct 28, 2024
1 parent b87c8c8 commit f7b2f01
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/create/bin/create.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env matter-run
#!/usr/bin/env node
import "../dist/esm/cli.js";
6 changes: 6 additions & 0 deletions packages/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"build-clean": "matter-build --clean",
"create": "matter-run src/cli.ts"
},
"files": [
"dist/**/*",
"src/**/*",
"LICENSE",
"README.md"
],
"bin": {
"matter-create": "bin/create.js"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/create/src/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export async function before({ project }: Project.Context) {
});
}

const matterJsVersion = `~${await readFile(project.pkg.workspace.resolve("version.txt"), "utf-8")}`;
// We set the version after build so we don't know actual version. Juse use placeholder. We then replace with the
// "create" package version on init
const matterJsVersion = "latest";

const typescriptVersion = project.pkg.findPackage("@matter/tools").json.dependencies.typescript;

const config: Config = {
Expand Down
6 changes: 5 additions & 1 deletion packages/create/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import { readFile } from "fs/promises";
import { resolve } from "path";

export const TEMPLATE_DIR = resolve(import.meta.dirname, "../templates");
const CREATE_DIR = resolve(import.meta.dirname, "../..");
export const TEMPLATE_DIR = resolve(CREATE_DIR, "dist/templates");

export interface Template {
name: string;
Expand All @@ -28,5 +29,8 @@ export async function Config() {
config = JSON.parse(await readFile(resolve(TEMPLATE_DIR, "index.json"), "utf-8")) as Config;
}

const packageJson = JSON.parse(await readFile(resolve(CREATE_DIR, "package.json"), "utf-8")) as { version: string };
config.matterJsVersion = `^${packageJson.version}`;

return config;
}

0 comments on commit f7b2f01

Please sign in to comment.