Skip to content

Support asconfig.json #1238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
67d8013
implement naive asconfig
jtenner Jun 17, 2020
6a70013
switch to args, whoops
jtenner Jun 17, 2020
4cf1b2b
semicolon for lint
jtenner Jun 17, 2020
0115341
each merge returns an options object
jtenner Jun 17, 2020
cb6e9ac
try to follow coding style, maybe use for of loop?
jtenner Jun 17, 2020
f071ae8
Actually, ' Object' is not 'Object'
jtenner Jun 17, 2020
dd12c9a
add asconfig.entries to compilation, keep track of asconfigDir for la…
jtenner Jun 20, 2020
6f98121
take into account relative baseDirs
jtenner Jun 20, 2020
d637a1f
fix small linted error
jtenner Jun 20, 2020
ef481e5
Merge branch 'asconfig' of https://github.com/jtenner/assemblyscript …
jtenner Jun 29, 2020
483cc9d
Setup tests for asconfig
jtenner Jul 1, 2020
9f602b1
Merge branch 'master' of https://github.com/assemblyscript/assemblysc…
jtenner Jul 1, 2020
ca95430
add const test
jtenner Jul 1, 2020
3257573
test single level inheritence with targets
jtenner Jul 1, 2020
e05a71f
config extension test, switch getAsconfig params
jtenner Jul 2, 2020
a0700c6
Modify asinit
jtenner Jul 3, 2020
4dd142e
typos
jtenner Jul 3, 2020
3b5a8ce
switch code style to regular functions
jtenner Jul 3, 2020
2a4e351
leading newline in json
jtenner Jul 3, 2020
9e0d217
config changes
jtenner Jul 3, 2020
7155d50
switch to isObject helper, and use typeof for string validation
jtenner Jul 3, 2020
a7a3999
semicolon
jtenner Jul 3, 2020
4e3de7d
Update bin/asinit
jtenner Jul 3, 2020
3e39805
Merge branch 'master' of https://github.com/assemblyscript/assemblysc…
jtenner Jul 3, 2020
932961d
switch to more general unique function
jtenner Jul 3, 2020
a29f617
unique cleanups
jtenner Jul 3, 2020
2ead5ae
Update cli/asc.js
jtenner Jul 3, 2020
c6af0dd
ignore cyclical dependencies
jtenner Jul 5, 2020
ec7d44c
Update cli/asc.js
jtenner Jul 5, 2020
d3abe65
Merge branch 'asconfig' of https://github.com/jtenner/assemblyscript …
jtenner Jul 5, 2020
acd8725
suggested changes
jtenner Jul 5, 2020
8195764
Swap merge args, rename config.entries --> config.include
Jul 8, 2020
f30d456
Rename include back to entries
Jul 9, 2020
7e26838
Added entry-points test
Jul 10, 2020
d8bd07b
Swap back and fix transform
Jul 10, 2020
7827a93
Added more tests
Jul 10, 2020
3e0303d
Merge pull request #1 from willemneal/asconfig
jtenner Jul 11, 2020
bb4cdaf
Merge branch 'master' of https://github.com/assemblyscript/assemblysc…
jtenner Jul 11, 2020
f44491c
cleanup
jtenner Jul 11, 2020
ac37a14
add watfile output
jtenner Jul 11, 2020
a77826c
remove complicated test
jtenner Jul 13, 2020
7c4e5cf
remove options test matching, why export argv/args
jtenner Jul 13, 2020
2ef00d0
Merge branch 'master' of https://github.com/assemblyscript/assemblysc…
jtenner Jul 13, 2020
3ad6d88
Whoops
jtenner Jul 13, 2020
ca18d62
make tests pass. What's next?
jtenner Jul 13, 2020
7f25365
linting issues
jtenner Jul 13, 2020
dc55518
linting issues
jtenner Jul 13, 2020
cbcb88e
Add showConfig to print out config and exit
Jul 13, 2020
9e35892
fix linting issue with indentation? really?
jtenner Jul 14, 2020
42703a1
remove watfile output, it's a bug, add complicated test
jtenner Jul 14, 2020
0f1803d
add complicated test
jtenner Jul 14, 2020
b177e94
check memory size here, switch args merge order
jtenner Jul 14, 2020
e80cd8b
Merge remote-tracking branch 'jtenner/asconfig' into asconfig
Jul 15, 2020
d3a347d
Merge pull request #2 from willemneal/asconfig
jtenner Jul 15, 2020
2495578
Update cli/asc.js
jtenner Jul 15, 2020
ad7d24a
Update cli/asc.json
jtenner Jul 15, 2020
9e4aebf
Update bin/asinit
jtenner Jul 15, 2020
debc2fc
Update bin/asinit
jtenner Jul 15, 2020
00e9b27
Update cli/asc.json
jtenner Jul 15, 2020
d304b36
Update tests/asconfig/entry-points/nested/assembly/index.ts
jtenner Jul 15, 2020
16bfe42
Update bin/asinit
jtenner Jul 15, 2020
bc24391
Update cli/asc.js
jtenner Jul 15, 2020
27656af
remove flags
jtenner Jul 15, 2020
e2bf925
Merge branch 'asconfig' of https://github.com/jtenner/assemblyscript …
jtenner Jul 15, 2020
8f5e8fb
add suggested target description
jtenner Jul 15, 2020
55135bc
remove path.join because resolve performs concatenation already
jtenner Jul 15, 2020
1b1fc19
updated test to include 'optimize' flag
jtenner Jul 15, 2020
62caba3
rename to resolveBasedir
jtenner Jul 15, 2020
0d0e29e
Merge branch 'master' of https://github.com/assemblyscript/assemblysc…
jtenner Jul 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ exports.main = function main(argv, options, callback) {
if (!stderr) throw Error("'options.stderr' must be specified");

const opts = optionsUtil.parse(argv, exports.options);
const args = opts.options;
let args = opts.options;

argv = opts.arguments;
if (args.noColors) {
colorsUtil.stdout.supported =
Expand Down Expand Up @@ -270,6 +271,25 @@ exports.main = function main(argv, options, callback) {

// Set up base directory
const baseDir = args.baseDir ? path.resolve(args.baseDir) : ".";
const target = args.target;

// Once the basedir is calculated, we can resolve the config, and it's extensions
let asconfig = getAsconfig(args.config, baseDir, readFile);
while (asconfig) {
// merge target first, then base options, then extended asconfigs
if (asconfig.targets && asconfig.targets[target]) {
optionsUtil.merge(exports.options, args, asconfig.targets[target]);
}
if (asconfig.options) {
optionsUtil.merge(exports.options, args, asconfig.options);
}
if (asconfig.extends) {
const dirname = path.dirname(path.join(baseDir, options.config));
asconfig = getAsconfig(asconfig.extends, dirname, readFile);
} else {
asconfig = null; // finished resolving the configuration
}
}

// Set up options
const compilerOptions = assemblyscript.newOptions();
Expand Down Expand Up @@ -924,6 +944,16 @@ exports.main = function main(argv, options, callback) {
}
};

function getAsconfig(file, baseDir, readFile) {
const contents = readFile(file, baseDir);
if (!contents) return null;
const config = JSON.parse(contents);
// TODO: validate configuration shape
// TODO: wrap JSON.parse() in try catch to obtain a more descriptive error
return config;
}
exports.getAsconfig = getAsconfig;

/** Checks diagnostics emitted so far for errors. */
function checkDiagnostics(program, stderr) {
var diagnostic;
Expand Down
12 changes: 12 additions & 0 deletions cli/asc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
"type": "b",
"default": false
},
"config": {
"category": "General",
"description": "Provides a configuration for assemblyscript to compile your project.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are the descriptions here? Should they be changed?

Copy link
Member

@dcodeIO dcodeIO Jul 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The challenge here is to keep these relatively short, i.e. not longer than any other descriptions when printed to console to avoid unnecessary wrapping or cutoff. Typically trying to keep fill words to a minimum. Here for example: "Configuration file to apply. CLI arguments take precedence."

"type": "s",
"default": "asconfig.json"
},
"target": {
"category": "General",
"description": "Provides a compile target for use with an assemblyscript configuration.",
"type": "s",
"default": "release"
},

"optimize": {
"category": "Optimization",
Expand Down