@cosystem/create 0.0.2
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/LICENSE +21 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +15 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/src-CaHW0Je1.mjs +77 -0
- package/dist/src-CaHW0Je1.mjs.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Coaction
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as createCosystemProject } from "./src-CaHW0Je1.mjs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
//#region src/cli.ts
|
|
5
|
+
const target = process.argv[2] ?? "cosystem-app";
|
|
6
|
+
const root = resolve(process.cwd(), target);
|
|
7
|
+
await createCosystemProject({
|
|
8
|
+
name: target,
|
|
9
|
+
root
|
|
10
|
+
});
|
|
11
|
+
console.log(`Created CoSystem project at ${root}`);
|
|
12
|
+
//#endregion
|
|
13
|
+
export {};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { resolve } from \"node:path\";\n\nimport { createCosystemProject } from \"./index.js\";\n\nconst target = process.argv[2] ?? \"cosystem-app\";\nconst root = resolve(process.cwd(), target);\n\nawait createCosystemProject({\n name: target,\n root,\n});\n\nconsole.log(`Created CoSystem project at ${root}`);\n"],"mappings":";;;;AAKA,MAAM,SAAS,QAAQ,KAAK,MAAM;AAClC,MAAM,OAAO,QAAQ,QAAQ,IAAI,GAAG,MAAM;AAE1C,MAAM,sBAAsB;CAC1B,MAAM;CACN;AACF,CAAC;AAED,QAAQ,IAAI,+BAA+B,MAAM"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
interface CreateCosystemProjectOptions {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly packageManager?: string;
|
|
6
|
+
}
|
|
7
|
+
interface CreatedCosystemProject {
|
|
8
|
+
readonly root: string;
|
|
9
|
+
readonly files: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
declare function createCosystemProject(options: CreateCosystemProjectOptions): Promise<CreatedCosystemProject>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CreateCosystemProjectOptions, CreatedCosystemProject, createCosystemProject };
|
|
14
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";UAGiB,4BAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;EAAA,SACA,cAAA;AAAA;AAAA,UAGM,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;AAAA;AAAA,iBAGW,qBAAA,CACpB,OAAA,EAAS,4BAAA,GACR,OAAA,CAAQ,sBAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
async function createCosystemProject(options) {
|
|
5
|
+
const packageManager = options.packageManager ?? "pnpm@11.8.0";
|
|
6
|
+
const files = [
|
|
7
|
+
"package.json",
|
|
8
|
+
"tsconfig.json",
|
|
9
|
+
"src/main.ts"
|
|
10
|
+
];
|
|
11
|
+
await mkdir(join(options.root, "src"), { recursive: true });
|
|
12
|
+
await writeFile(join(options.root, "package.json"), `${JSON.stringify(createPackageJson(options.name, packageManager), null, 2)}\n`);
|
|
13
|
+
await writeFile(join(options.root, "tsconfig.json"), `${JSON.stringify(createTsConfig(), null, 2)}\n`);
|
|
14
|
+
await writeFile(join(options.root, "src/main.ts"), createMainSource());
|
|
15
|
+
return {
|
|
16
|
+
files,
|
|
17
|
+
root: options.root
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createPackageJson(name, packageManager) {
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
private: true,
|
|
24
|
+
scripts: {
|
|
25
|
+
build: "tsc -p tsconfig.json",
|
|
26
|
+
start: "tsx src/main.ts"
|
|
27
|
+
},
|
|
28
|
+
dependencies: { "@cosystem/core": "latest" },
|
|
29
|
+
devDependencies: {
|
|
30
|
+
tsx: "latest",
|
|
31
|
+
typescript: "latest"
|
|
32
|
+
},
|
|
33
|
+
packageManager
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createTsConfig() {
|
|
37
|
+
return {
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
module: "NodeNext",
|
|
40
|
+
moduleResolution: "NodeNext",
|
|
41
|
+
strict: true,
|
|
42
|
+
target: "ES2022"
|
|
43
|
+
},
|
|
44
|
+
include: ["src/**/*.ts"]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function createMainSource() {
|
|
48
|
+
return `import { createApp, defineModule } from "@cosystem/core";
|
|
49
|
+
|
|
50
|
+
class Counter {
|
|
51
|
+
count = 0;
|
|
52
|
+
|
|
53
|
+
increase(): void {
|
|
54
|
+
this.count += 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
defineModule(Counter, {
|
|
59
|
+
actions: ["increase"],
|
|
60
|
+
name: "counter",
|
|
61
|
+
state: ["count"],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const app = createApp({
|
|
65
|
+
providers: [Counter],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const counter = app.getModule(Counter);
|
|
69
|
+
counter.increase();
|
|
70
|
+
|
|
71
|
+
console.log(app.store.getPureState());
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { createCosystemProject as t };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=src-CaHW0Je1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-CaHW0Je1.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface CreateCosystemProjectOptions {\n readonly root: string;\n readonly name: string;\n readonly packageManager?: string;\n}\n\nexport interface CreatedCosystemProject {\n readonly root: string;\n readonly files: readonly string[];\n}\n\nexport async function createCosystemProject(\n options: CreateCosystemProjectOptions,\n): Promise<CreatedCosystemProject> {\n const packageManager = options.packageManager ?? \"pnpm@11.8.0\";\n const files = [\"package.json\", \"tsconfig.json\", \"src/main.ts\"] as const;\n\n await mkdir(join(options.root, \"src\"), { recursive: true });\n await writeFile(\n join(options.root, \"package.json\"),\n `${JSON.stringify(createPackageJson(options.name, packageManager), null, 2)}\\n`,\n );\n await writeFile(\n join(options.root, \"tsconfig.json\"),\n `${JSON.stringify(createTsConfig(), null, 2)}\\n`,\n );\n await writeFile(join(options.root, \"src/main.ts\"), createMainSource());\n\n return {\n files,\n root: options.root,\n };\n}\n\nfunction createPackageJson(name: string, packageManager: string): object {\n return {\n name,\n private: true,\n scripts: {\n build: \"tsc -p tsconfig.json\",\n start: \"tsx src/main.ts\",\n },\n dependencies: {\n \"@cosystem/core\": \"latest\",\n },\n devDependencies: {\n tsx: \"latest\",\n typescript: \"latest\",\n },\n packageManager,\n };\n}\n\nfunction createTsConfig(): object {\n return {\n compilerOptions: {\n module: \"NodeNext\",\n moduleResolution: \"NodeNext\",\n strict: true,\n target: \"ES2022\",\n },\n include: [\"src/**/*.ts\"],\n };\n}\n\nfunction createMainSource(): string {\n return `import { createApp, defineModule } from \"@cosystem/core\";\n\nclass Counter {\n count = 0;\n\n increase(): void {\n this.count += 1;\n }\n}\n\ndefineModule(Counter, {\n actions: [\"increase\"],\n name: \"counter\",\n state: [\"count\"],\n});\n\nconst app = createApp({\n providers: [Counter],\n});\n\nconst counter = app.getModule(Counter);\ncounter.increase();\n\nconsole.log(app.store.getPureState());\n`;\n}\n"],"mappings":";;;AAcA,eAAsB,sBACpB,SACiC;CACjC,MAAM,iBAAiB,QAAQ,kBAAkB;CACjD,MAAM,QAAQ;EAAC;EAAgB;EAAiB;CAAa;CAE7D,MAAM,MAAM,KAAK,QAAQ,MAAM,KAAK,GAAG,EAAE,WAAW,KAAK,CAAC;CAC1D,MAAM,UACJ,KAAK,QAAQ,MAAM,cAAc,GACjC,GAAG,KAAK,UAAU,kBAAkB,QAAQ,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,GAC9E;CACA,MAAM,UACJ,KAAK,QAAQ,MAAM,eAAe,GAClC,GAAG,KAAK,UAAU,eAAe,GAAG,MAAM,CAAC,EAAE,GAC/C;CACA,MAAM,UAAU,KAAK,QAAQ,MAAM,aAAa,GAAG,iBAAiB,CAAC;CAErE,OAAO;EACL;EACA,MAAM,QAAQ;CAChB;AACF;AAEA,SAAS,kBAAkB,MAAc,gBAAgC;CACvE,OAAO;EACL;EACA,SAAS;EACT,SAAS;GACP,OAAO;GACP,OAAO;EACT;EACA,cAAc,EACZ,kBAAkB,SACpB;EACA,iBAAiB;GACf,KAAK;GACL,YAAY;EACd;EACA;CACF;AACF;AAEA,SAAS,iBAAyB;CAChC,OAAO;EACL,iBAAiB;GACf,QAAQ;GACR,kBAAkB;GAClB,QAAQ;GACR,QAAQ;EACV;EACA,SAAS,CAAC,aAAa;CACzB;AACF;AAEA,SAAS,mBAA2B;CAClC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;AAyBT"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosystem/create",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Project scaffolding utilities for CoSystem.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-cosystem": "./dist/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "22.19.21",
|
|
27
|
+
"tsdown": "0.22.3",
|
|
28
|
+
"typescript": "6.0.3",
|
|
29
|
+
"vitest": "4.1.9",
|
|
30
|
+
"@cosystem/tsconfig": "0.0.2"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsdown",
|
|
34
|
+
"clean": "rm -rf coverage dist .turbo",
|
|
35
|
+
"dev": "tsdown --watch",
|
|
36
|
+
"test": "cd ../.. && vitest run --project @cosystem/create",
|
|
37
|
+
"test:coverage": "cd ../.. && vitest run --coverage --project @cosystem/create",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
39
|
+
}
|
|
40
|
+
}
|