-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e69aa1
commit d6320c9
Showing
5 changed files
with
129 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,27 @@ | ||
version = 0.1 | ||
|
||
[env] | ||
BUILD_TYPE = "Debug" | ||
|
||
# [[task]] | ||
# name = "build" | ||
# target = "test/lib/#.js" | ||
# deps = ["node_modules/.bin/swc", "test/src/#.ts"] | ||
# run = "npx @chomp/svelte" | ||
|
||
# [[task]] | ||
# name = "install" | ||
# target = "node_modules/.bin/swc" | ||
# run = "npm install @swc/core @swc/cli --save-dev" | ||
|
||
# [[task]] | ||
# run = "@chomp/svelte" | ||
|
||
[[task]] | ||
name = "tpl" | ||
template = "chomp:svelte" | ||
[task.args] | ||
indir = "src" | ||
outdir = "lib" | ||
|
||
[[template]] | ||
name = "chomp:svelte" | ||
definition = """({ outdir = 'lib', indir = 'src' }) => [{ | ||
target: `${outdir}/#.svelte.js`, | ||
deps: [`${indir}/#.svelte`, 'node_modules/svelte', 'node_modules/mkdirp'], | ||
engine: 'node', | ||
run: ` | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { compile } from 'svelte/compiler'; | ||
import mkdirp from 'mkdirp'; | ||
import { dirname } from 'path'; | ||
const source = readFileSync(process.env.dep, "utf-8"); | ||
const result = compile(source, { | ||
filename: process.env.DEP, | ||
css: false, | ||
}); | ||
name = "install" | ||
deps = ["build"] | ||
run = """ | ||
cp target/Debug/chp.exe ~/bin/chp2.exe | ||
cp target/Debug/chp.exe ~/bin/chp.exe | ||
""" | ||
|
||
mkdirp.sync(dirname(process.env.TARGET)); | ||
writeFileSync(process.env.TARGET, result.js.code); | ||
writeFileSync(process.env.TARGET + ".map", JSON.stringify(result.js.map)); | ||
[[task]] | ||
name = "build" | ||
deps = ["build:templates"] | ||
run = "cargo build" | ||
|
||
const cssFile = process.env.TARGET.replace(/\\.js$/, ".css"); | ||
writeFileSync(cssFile, result.css.code); | ||
writeFileSync(cssFile + ".map", JSON.stringify(result.css.map)); | ||
` | ||
}, { | ||
targets: ['node_modules/svelte', 'node_modules/mkdirp'], | ||
run: 'npm install svelte mkdirp --save-dev' | ||
}] | ||
[[task]] | ||
name = "build:templates" | ||
engine = "node" | ||
run = """ | ||
import { readdirSync, readFileSync, writeFileSync } from 'fs'; | ||
let combinedTemplates = 'version = 0.1\\n'; | ||
for (const tpl of readdirSync('templates')) | ||
combinedTemplates += readFileSync(`templates/${tpl}`).toString() + '\\n'; | ||
writeFileSync('src/templates.toml', combinedTemplates); | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version = 0.1 | ||
[[template]] | ||
name = "chomp:svelte" | ||
definition = """({ outdir = 'lib', indir = 'src' }) => [{ | ||
target: `${outdir}/#.svelte.js`, | ||
deps: [`${indir}/#.svelte`, 'node_modules/svelte', 'node_modules/mkdirp'], | ||
engine: 'node', | ||
run: ` | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { compile } from 'svelte/compiler'; | ||
import mkdirp from 'mkdirp'; | ||
import { dirname } from 'path'; | ||
const source = readFileSync(process.env.dep, "utf-8"); | ||
const result = compile(source, { | ||
filename: process.env.DEP, | ||
css: false, | ||
}); | ||
mkdirp.sync(dirname(process.env.TARGET)); | ||
writeFileSync(process.env.TARGET, result.js.code); | ||
writeFileSync(process.env.TARGET + ".map", JSON.stringify(result.js.map)); | ||
const cssFile = process.env.TARGET.replace(/\\.js$/, ".css"); | ||
writeFileSync(cssFile, result.css.code); | ||
writeFileSync(cssFile + ".map", JSON.stringify(result.css.map)); | ||
` | ||
}, { | ||
targets: ['node_modules/svelte', 'node_modules/mkdirp'], | ||
run: 'npm install svelte mkdirp --save-dev' | ||
}] | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[[template]] | ||
name = "chomp:svelte" | ||
definition = """({ outdir = 'lib', indir = 'src' }) => [{ | ||
target: `${outdir}/#.svelte.js`, | ||
deps: [`${indir}/#.svelte`, 'node_modules/svelte', 'node_modules/mkdirp'], | ||
engine: 'node', | ||
run: ` | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { compile } from 'svelte/compiler'; | ||
import mkdirp from 'mkdirp'; | ||
import { dirname } from 'path'; | ||
const source = readFileSync(process.env.dep, "utf-8"); | ||
const result = compile(source, { | ||
filename: process.env.DEP, | ||
css: false, | ||
}); | ||
mkdirp.sync(dirname(process.env.TARGET)); | ||
writeFileSync(process.env.TARGET, result.js.code); | ||
writeFileSync(process.env.TARGET + ".map", JSON.stringify(result.js.map)); | ||
const cssFile = process.env.TARGET.replace(/\\.js$/, ".css"); | ||
writeFileSync(cssFile, result.css.code); | ||
writeFileSync(cssFile + ".map", JSON.stringify(result.css.map)); | ||
` | ||
}, { | ||
targets: ['node_modules/svelte', 'node_modules/mkdirp'], | ||
run: 'npm install svelte mkdirp --save-dev' | ||
}] | ||
""" |