cluaupp 2.0.0-beta.1 → 2.0.0-beta.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/CHANGELOG.md +5 -0
- package/README.md +2 -1
- package/api/generated/lsp-index.json +1 -1
- package/api/manifests/roblox-target.manifest.json +5 -5
- package/api/normalized/roblox-target.profile.json +3 -3
- package/api/roblox-api.lock.json +2 -2
- package/editors/vscode/README.md +1 -1
- package/editors/vscode/package.json +50 -15
- package/editors/vscode/snippets/flare.json +1 -1
- package/editors/vscode/snippets/hive.json +1 -1
- package/generated/api-cli.js +2 -2
- package/generated/cli.js +18 -17
- package/generated/compiler/project.js +1 -1
- package/generated/intellisense.js +1 -15
- package/generated/lsp.js +1 -1
- package/generated/target/datamodel-generate.js +12 -0
- package/generated/utils/project.js +21 -6
- package/include/README.md +5 -0
- package/package.json +2 -2
- package/src/api-cli.ts +2 -2
- package/src/cli.ts +19 -18
- package/src/compiler/project.ts +1 -1
- package/src/intellisense.ts +1 -13
- package/src/lsp.ts +1 -1
- package/src/target/datamodel-generate.ts +12 -1
- package/src/utils/project.ts +20 -6
|
@@ -6,6 +6,7 @@ import fs from "node:fs";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import type { DatamodelNode, DatamodelProfile } from "./datamodel.js";
|
|
8
8
|
import { buildDatamodelProfile } from "./datamodel.js";
|
|
9
|
+
import { collectSources } from "../clpp/paths.js";
|
|
9
10
|
|
|
10
11
|
function safeIdent(name: string): string {
|
|
11
12
|
const cleaned = name.replace(/[^A-Za-z0-9_]/g, "_");
|
|
@@ -58,7 +59,7 @@ export function profileWithoutIndex(profile: DatamodelProfile): Omit<DatamodelPr
|
|
|
58
59
|
export function writeDatamodelArtifacts(
|
|
59
60
|
projectRoot: string,
|
|
60
61
|
opts?: { projectJson?: string; outDir?: string; headerPath?: string },
|
|
61
|
-
): { profile: DatamodelProfile; profilePath: string; headerPath: string } | null {
|
|
62
|
+
): { profile: DatamodelProfile; profilePath: string; headerPath: string | null } | null {
|
|
62
63
|
const profile = buildDatamodelProfile(projectRoot, opts?.projectJson);
|
|
63
64
|
if (!profile) {
|
|
64
65
|
return null;
|
|
@@ -68,6 +69,16 @@ export function writeDatamodelArtifacts(
|
|
|
68
69
|
const profilePath = path.join(outDir, "datamodel-profile.json");
|
|
69
70
|
fs.writeFileSync(profilePath, JSON.stringify(profileWithoutIndex(profile), null, "\t") + "\n", "utf8");
|
|
70
71
|
|
|
72
|
+
let sourceRoot = "src";
|
|
73
|
+
const configPath = path.join(projectRoot, "cluaupp.config.json");
|
|
74
|
+
if (fs.existsSync(configPath)) {
|
|
75
|
+
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
76
|
+
if (typeof config.rootDir === "string") sourceRoot = config.rootDir;
|
|
77
|
+
}
|
|
78
|
+
const sources = collectSources(path.resolve(projectRoot, sourceRoot));
|
|
79
|
+
const modern = sources.some(file => /\.clp$/i.test(file)) && !sources.some(file => /\.clpp$/i.test(file));
|
|
80
|
+
if (modern && !opts?.headerPath) return { profile, profilePath, headerPath: null };
|
|
81
|
+
|
|
71
82
|
const headerPath =
|
|
72
83
|
opts?.headerPath ||
|
|
73
84
|
path.join(projectRoot, "include", "clpp", "generated", "datamodel.clh");
|
package/src/utils/project.ts
CHANGED
|
@@ -338,6 +338,11 @@ function compileOptions(root: string, config: ProjectConfig, file: string, rel:
|
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
function needsLegacyHeaders(srcDir: string): boolean {
|
|
342
|
+
const sources = collectSources(srcDir);
|
|
343
|
+
return sources.some(file => /\.clpp$/i.test(file)) || !sources.some(file => /\.clp$/i.test(file));
|
|
344
|
+
}
|
|
345
|
+
|
|
341
346
|
function compileSchemaJobs(root: string, config: ProjectConfig, srcDir: string) {
|
|
342
347
|
const jobs: Array<{ rel: string; files: CompiledArtifact[]; stale: string[] }> = [];
|
|
343
348
|
const errors: Array<{ rel: string; prefixes: string[]; message: string }> = [];
|
|
@@ -352,7 +357,7 @@ function compileSchemaJobs(root: string, config: ProjectConfig, srcDir: string)
|
|
|
352
357
|
if (!isInside(path.resolve(root, config.rootDir), headerDest) && !isInside(srcDir, headerDest)) {
|
|
353
358
|
throw new Error(`cluaupp schema: skip unsafe header ${emit.headerRel}`);
|
|
354
359
|
}
|
|
355
|
-
writeTextIfChanged(headerDest, emit.header);
|
|
360
|
+
if (needsLegacyHeaders(srcDir)) writeTextIfChanged(headerDest, emit.header);
|
|
356
361
|
jobs.push({
|
|
357
362
|
rel,
|
|
358
363
|
files: [{ name: emit.luauRel, contents: emit.luau }],
|
|
@@ -380,7 +385,7 @@ function compileFlareJobs(root: string, config: ProjectConfig, srcDir: string) {
|
|
|
380
385
|
if (!isInside(path.resolve(root, config.rootDir), headerDest) && !isInside(srcDir, headerDest)) {
|
|
381
386
|
throw new Error(`cluaupp flare: skip unsafe header ${emit.headerRel}`);
|
|
382
387
|
}
|
|
383
|
-
writeTextIfChanged(headerDest, emit.header);
|
|
388
|
+
if (needsLegacyHeaders(srcDir)) writeTextIfChanged(headerDest, emit.header);
|
|
384
389
|
jobs.push({
|
|
385
390
|
rel,
|
|
386
391
|
files: [{ name: emit.luauRel, contents: emit.luau }],
|
|
@@ -638,7 +643,10 @@ function writeJobs(root: string, config: ProjectConfig, jobs: Array<{ rel: strin
|
|
|
638
643
|
|
|
639
644
|
function ensureVendor(root: string): void {
|
|
640
645
|
copyRuntime(root);
|
|
641
|
-
|
|
646
|
+
const config = loadConfig(root);
|
|
647
|
+
if (collectSources(path.join(root, config.rootDir)).some(file => /\.clpp$/i.test(file))) {
|
|
648
|
+
copyHeaders(root);
|
|
649
|
+
}
|
|
642
650
|
}
|
|
643
651
|
|
|
644
652
|
function finishBuild(
|
|
@@ -778,10 +786,15 @@ export async function buildAsync(root: string, options: BuildOptions = {}): Prom
|
|
|
778
786
|
|
|
779
787
|
export async function init(dest: string): Promise<void> {
|
|
780
788
|
const target = assertInitDest(dest);
|
|
789
|
+
if (fs.existsSync(path.join(target, "cluaupp.config.json")) || fs.existsSync(path.join(target, "src"))) {
|
|
790
|
+
throw new Error("cluaupp init: project already exists; choose a new folder. Existing .clpp/.clh sources require migration, not another init.");
|
|
791
|
+
}
|
|
781
792
|
const template = path.join(__dirname, "..", "..", "templates", "game-modern");
|
|
782
|
-
const include = path.join(__dirname, "..", "..", "include");
|
|
783
793
|
copyDir(template, target);
|
|
784
|
-
|
|
794
|
+
const packageFile = path.join(target, "package.json");
|
|
795
|
+
const projectPackage = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
|
796
|
+
projectPackage.devDependencies = { ...projectPackage.devDependencies, cluaupp: pkg.version };
|
|
797
|
+
fs.writeFileSync(packageFile, JSON.stringify(projectPackage, null, "\t") + "\n");
|
|
785
798
|
const skills = path.join(__dirname, "..", "..", "skills");
|
|
786
799
|
if (fs.existsSync(skills)) {
|
|
787
800
|
copyDir(skills, path.join(target, ".cursor", "skills"));
|
|
@@ -795,7 +808,8 @@ export async function init(dest: string): Promise<void> {
|
|
|
795
808
|
console.log(" CL++ 0.10 editor extension provides syntax highlighting; Cluaupp compiles Roblox .clp files");
|
|
796
809
|
console.log(" cluaupp intellisense (schema .flare .hive .mint .bloom .helm .shift .axiom)");
|
|
797
810
|
console.log(" rokit install");
|
|
798
|
-
console.log("
|
|
811
|
+
console.log(" npm install");
|
|
812
|
+
console.log(" npm run build");
|
|
799
813
|
console.log(" rojo serve");
|
|
800
814
|
}
|
|
801
815
|
|