samengine 1.10.0 → 1.10.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.
@@ -6,8 +6,6 @@ export interface CLIArgs {
6
6
  singlefile: boolean;
7
7
  /** Project name passed to `--new` or `--new-empty`; otherwise `null`. */
8
8
  newProject: boolean;
9
- /** True when `--new-empty` should create an empty starter instead of the example game. */
10
- empty: boolean;
11
9
  /** Show a Help Message */
12
10
  help: boolean;
13
11
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export function parseArgs() {
8
8
  const args = process.argv.slice(2);
9
- const options = { release: false, singlefile: false, newProject: false, empty: false, help: false };
9
+ const options = { release: false, singlefile: false, newProject: false, help: false };
10
10
  for (let i = 0; i < args.length; i++) {
11
11
  const arg = args[i];
12
12
  switch (arg) {
@@ -21,7 +21,6 @@ import { GetDefaultHTML, GetSingleFileHTML, getVersion } from "../exporthtml.js"
21
21
  import { loadUserConfig } from "./../config.js";
22
22
  import { compressHTML } from "../../index.js";
23
23
  import { parseArgs } from "./argparser.js";
24
- import { run as runCreateProject } from "../projcreator/main.js";
25
24
  // ================= HELP ============
26
25
  /**
27
26
  * Function to print Help
@@ -202,7 +201,11 @@ async function startWatcher(onChange) {
202
201
  async function main() {
203
202
  const args = parseArgs();
204
203
  if (args.newProject) {
205
- await runCreateProject();
204
+ console.log(`to create a new project run:
205
+
206
+ npx create-samengine-project
207
+
208
+ and then select your template!`);
206
209
  process.exit(0);
207
210
  }
208
211
  if (args.help) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samengine",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "A TypeScript game library to make HTML Games",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -38,12 +38,9 @@
38
38
  "author": "Shadowdara",
39
39
  "license": "Apache-2.0",
40
40
  "devDependencies": {
41
- "@types/fs-extra": "^11.0.4",
42
41
  "@types/html-minifier-terser": "^7.0.2",
43
42
  "@types/node": "^25.9.4",
44
- "@types/unzipper": "^0.10.11",
45
43
  "@types/ws": "^8.18.1",
46
- "rimraf": "^6.1.3",
47
44
  "ts-node": "^10.9.2",
48
45
  "typescript": "^6.0.3"
49
46
  },
@@ -58,12 +55,8 @@
58
55
  "type": "module",
59
56
  "dependencies": {
60
57
  "esbuild": "^0.28.0",
61
- "fs-extra": "^11.3.5",
62
58
  "html-minifier-terser": "^7.2.0",
63
- "inquirer": "^14.0.2",
64
59
  "mime": "^4.1.0",
65
- "node-fetch": "^3.3.2",
66
- "unzipper": "^0.12.5",
67
60
  "ws": "^8.20.0",
68
61
  "chalk": "^5.6.2",
69
62
  "samengine-cli": "2.0.4"
@@ -1,4 +0,0 @@
1
- export declare function downloadAndExtract(url: string, targetDir: string): Promise<void>;
2
- export declare function flattenGitHubZip(rootDir: string): Promise<void>;
3
- export declare function keepOnlySelectedVersion(rootDir: string, selectedVersion: string, selectedStarter: string): Promise<void>;
4
- export declare function finalizeProject(rootDir: string, version: string, starter: string): Promise<void>;
@@ -1,83 +0,0 @@
1
- import fetch from "node-fetch";
2
- import fs from "fs-extra";
3
- import unzipper from "unzipper";
4
- import path from "path";
5
- export async function downloadAndExtract(url, targetDir) {
6
- await fs.ensureDir(targetDir);
7
- const res = await fetch(url);
8
- if (!res.ok || !res.body) {
9
- throw new Error("Failed to download template");
10
- }
11
- const body = res.body;
12
- const zipPath = path.join(targetDir, "template.zip");
13
- const fileStream = fs.createWriteStream(zipPath);
14
- await new Promise((resolve, reject) => {
15
- body.pipe(fileStream);
16
- body.on("error", reject);
17
- fileStream.on("finish", resolve);
18
- });
19
- await fs
20
- .createReadStream(zipPath)
21
- .pipe(unzipper.Extract({ path: targetDir }))
22
- .promise();
23
- await fs.remove(zipPath);
24
- // flatten GitHub folder
25
- const items = await fs.readdir(targetDir);
26
- const rootFolder = items.find(f => f.includes("game-template"));
27
- if (rootFolder) {
28
- const rootPath = path.join(targetDir, rootFolder);
29
- const files = await fs.readdir(rootPath);
30
- for (const file of files) {
31
- await fs.move(path.join(rootPath, file), path.join(targetDir, file), { overwrite: true });
32
- }
33
- await fs.remove(rootPath);
34
- }
35
- }
36
- export async function flattenGitHubZip(rootDir) {
37
- const items = await fs.readdir(rootDir);
38
- // finde GitHub wrapper folder
39
- const wrapper = items.find(name => name.includes("-main") ||
40
- name.includes("-master") ||
41
- name.includes("-"));
42
- if (!wrapper)
43
- return;
44
- const wrapperPath = path.join(rootDir, wrapper);
45
- const inner = await fs.readdir(wrapperPath);
46
- for (const file of inner) {
47
- await fs.move(path.join(wrapperPath, file), path.join(rootDir, file), { overwrite: true });
48
- }
49
- await fs.remove(wrapperPath);
50
- }
51
- export async function keepOnlySelectedVersion(rootDir, selectedVersion, selectedStarter) {
52
- const versions = await fs.readdir(rootDir);
53
- for (const version of versions) {
54
- const versionPath = path.join(rootDir, version);
55
- const stat = await fs.stat(versionPath);
56
- if (!stat.isDirectory())
57
- continue;
58
- if (version !== selectedVersion) {
59
- await fs.remove(versionPath);
60
- continue;
61
- }
62
- // inside selected version → handle starters
63
- const starters = await fs.readdir(versionPath);
64
- for (const starter of starters) {
65
- const starterPath = path.join(versionPath, starter);
66
- const stat2 = await fs.stat(starterPath);
67
- if (!stat2.isDirectory())
68
- continue;
69
- if (starter !== selectedStarter) {
70
- await fs.remove(starterPath);
71
- }
72
- }
73
- }
74
- }
75
- export async function finalizeProject(rootDir, version, starter) {
76
- const starterPath = path.join(rootDir, version, starter);
77
- const files = await fs.readdir(starterPath);
78
- for (const file of files) {
79
- await fs.move(path.join(starterPath, file), path.join(rootDir, file), { overwrite: true });
80
- }
81
- // cleanup EVERYTHING else
82
- await fs.remove(path.join(rootDir, version));
83
- }
@@ -1 +0,0 @@
1
- export declare function run(): Promise<void>;
@@ -1,81 +0,0 @@
1
- import inquirer from "inquirer";
2
- import path from "path";
3
- import fs from "fs-extra";
4
- import { downloadAndExtract, flattenGitHubZip } from "./downloadZip.js";
5
- const USERNAME = "Shadowdara";
6
- const REPO = "samengine-project-templates";
7
- export async function run() {
8
- const answers = await inquirer.prompt([
9
- {
10
- name: "projectName",
11
- message: "Project name?",
12
- default: "my-game"
13
- }
14
- ]);
15
- const targetDir = path.join(process.cwd(), answers.projectName);
16
- console.log("📦 Downloading template repo...");
17
- await downloadAndExtract(`https://codeload.github.com/${USERNAME}/${REPO}/zip/refs/heads/main`, targetDir);
18
- await flattenGitHubZip(targetDir);
19
- // -------------------------
20
- // 1. VERSIONEN LADEN
21
- // -------------------------
22
- const versions = (await fs.readdir(targetDir))
23
- .filter(v => fs.statSync(path.join(targetDir, v)).isDirectory());
24
- const { version } = await inquirer.prompt([
25
- {
26
- name: "version",
27
- message: "Choose version",
28
- type: "select",
29
- choices: versions
30
- }
31
- ]);
32
- const versionPath = path.join(targetDir, version);
33
- // -------------------------
34
- // 2. STARTER LADEN
35
- // -------------------------
36
- const starters = (await fs.readdir(versionPath))
37
- .filter(s => fs.statSync(path.join(versionPath, s)).isDirectory());
38
- const { starter } = await inquirer.prompt([
39
- {
40
- name: "starter",
41
- message: "Choose starter",
42
- type: "select",
43
- choices: starters
44
- }
45
- ]);
46
- // -------------------------
47
- // 3. CLEANUP (KEEP ONLY SELECTED)
48
- // -------------------------
49
- for (const v of await fs.readdir(targetDir)) {
50
- const vPath = path.join(targetDir, v);
51
- if (!(await fs.stat(vPath)).isDirectory())
52
- continue;
53
- if (v !== version) {
54
- await fs.remove(vPath);
55
- continue;
56
- }
57
- // remove other starters inside selected version
58
- for (const s of await fs.readdir(vPath)) {
59
- const sPath = path.join(vPath, s);
60
- if (!(await fs.stat(sPath)).isDirectory())
61
- continue;
62
- if (s !== starter) {
63
- await fs.remove(sPath);
64
- }
65
- }
66
- }
67
- // -------------------------
68
- // 4. MOVE STARTER TO ROOT
69
- // -------------------------
70
- const starterPath = path.join(targetDir, version, starter);
71
- const files = await fs.readdir(starterPath);
72
- for (const file of files) {
73
- await fs.move(path.join(starterPath, file), path.join(targetDir, file), { overwrite: true });
74
- }
75
- // -------------------------
76
- // 5. FINAL CLEANUP
77
- // -------------------------
78
- await fs.remove(path.join(targetDir, version));
79
- console.log("✅ Done!");
80
- console.log(`👉 cd ${answers.projectName} && npm install`);
81
- }