Skip to content

Commit

Permalink
feat: rename assets.json to eik.json
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed Jun 23, 2020
1 parent 161ab2b commit e8bd24d
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
assets.json
eik.json
package-lock.json
node_modules
tmp
Expand Down
4 changes: 2 additions & 2 deletions commands/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ exports.command = 'development';

exports.aliases = ['dev'];

// exports.describe = `Build an apps dependencies based on local assets.json file.`;
// exports.describe = `Build an apps dependencies based on local eik.json file.`;
exports.describe = false;

exports.builder = yargs => {
let assets = {};
try {
const assetsPath = resolvePath('./assets.json').pathname;
const assetsPath = resolvePath('./eik.json').pathname;
assets = JSON.parse(readFileSync(assetsPath));
} catch (err) {
// noop
Expand Down
26 changes: 13 additions & 13 deletions commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ exports.command = 'init';

exports.aliases = ['i'];

exports.describe = `Creates a new default "assets.json" file and saves it to the current working directory
Override default "assets.json" fields using command line flags --server, --name, --major, --js and --css`;
exports.describe = `Creates a new default "eik.json" file and saves it to the current working directory
Override default "eik.json" fields using command line flags --server, --name, --major, --js and --css`;

exports.builder = (yargs) => {
yargs.example('eik init');
Expand All @@ -20,7 +20,7 @@ exports.builder = (yargs) => {
yargs.options({
server: {
alias: 's',
describe: `Specify asset server field in "assets.json".
describe: `Specify asset server field in "eik.json".
This the URL to an Eik asset server
Eg. --server https://assets.myeikserver.com`,
default: '',
Expand All @@ -29,33 +29,33 @@ exports.builder = (yargs) => {
alias: 'c',
describe: `Alter the current working directory
Defaults to the directory where the command is being run.
This affects where the generated "assets.json" file will be saved.
This affects where the generated "eik.json" file will be saved.
Eg. --cwd /path/to/save/to`,
default: process.cwd(),
},
major: {
alias: 'm',
describe: `Specify the semver major version field in "assets.json".
describe: `Specify the semver major version field in "eik.json".
This should be a single integer.
Eg. --major 2`,
default: 1,
},
name: {
alias: 'n',
describe: `Specify the app name field in "assets.json".
describe: `Specify the app name field in "eik.json".
Eg. --name my-great-app`,
default: '',
},
js: {
describe:
`Specify the path on local disk to JavaScript client side assets relative to the current working directory.
This will be used to populate the "js.input" field of "assets.json"`,
This will be used to populate the "js.input" field of "eik.json"`,
default: '',
},
css: {
describe:
`Specify the path on local disk to CSS client side assets relative to the current working directory.
This will be used to populate the "css.input" field of "assets.json"`,
This will be used to populate the "css.input" field of "eik.json"`,
default: '',
},
debug: {
Expand All @@ -69,12 +69,12 @@ exports.builder = (yargs) => {
exports.handler = async (argv) => {
const spinner = ora({ stream: process.stdout }).start('working...');
const { name, major, server, js, css, cwd, debug } = argv;
const { pathname } = resolvePath('./assets.json', cwd);
const { pathname } = resolvePath('./eik.json', cwd);
const log = logger(spinner, debug);
let assetFileExists = false;

try {
log.debug(`Checking for existing "assets.json" file in directory (${cwd})`);
log.debug(`Checking for existing "eik.json" file in directory (${cwd})`);
try {
const st = fs.statSync(pathname);
if (st.isFile()) {
Expand All @@ -85,10 +85,10 @@ exports.handler = async (argv) => {
}

if (assetFileExists) {
throw new Error(`An "assets.json" file already exists in directory. File will not be written`);
throw new Error(`An "eik.json" file already exists in directory. File will not be written`);
}

log.debug(`Writing "assets.json" to directory (${cwd})`);
log.debug(`Writing "eik.json" to directory (${cwd})`);
fs.writeFileSync(
pathname,
JSON.stringify(
Expand All @@ -104,7 +104,7 @@ exports.handler = async (argv) => {
),
);

log.info(`"assets.json" successfully written to directory`);
log.info(`"eik.json" successfully written to directory`);
} catch (err) {
log.warn(err.message);
}
Expand Down
8 changes: 4 additions & 4 deletions commands/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ exports.describe = `Publish an app package to an Eik server by a given semver le
Bundles and publishes JavaScript and CSS at given local paths creating a new version based off the previous version and the given semver level.
Specifying semver level is optional and defaults to "patch", specifying "major" locks version to the given semver major.
If a package has never previously been published, the first version generated will be equal to specified major version or 1.0.0 if no major is specified.
Local paths to asset files can be defined in an "assets.json" file using "js.input" and "css.input" fields or can be provided directly to the CLI command using the flags --js and --css.
URLs to import maps can be provided to map "bare" imports found in asset files, to do so either use the field "map" in "assets.json" or the --map CLI flag.`;
Local paths to asset files can be defined in an "eik.json" file using "js.input" and "css.input" fields or can be provided directly to the CLI command using the flags --js and --css.
URLs to import maps can be provided to map "bare" imports found in asset files, to do so either use the field "map" in "eik.json" or the --map CLI flag.`;

exports.builder = (yargs) => {
const cwd = getCWD();
Expand Down Expand Up @@ -77,9 +77,9 @@ exports.handler = async (argv) => {

try {
try {
await fs.access(join(cwd, 'assets.json'), constants.F_OK);
await fs.access(join(cwd, 'eik.json'), constants.F_OK);
} catch(err) {
throw new Error('No assets.json file found in the current working directory. Please run eik init');
throw new Error('No eik.json file found in the current working directory. Please run eik init');
}

const options = {
Expand Down
12 changes: 6 additions & 6 deletions test/integration/alias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ test('eik package-alias <name> <version> <alias>', async t => {
t.match(stdout, 'NEW');
});

test('eik npm-alias <name> <version> <alias> --token --server : no assets.json or .eikrc', async (t) => {
test('eik npm-alias <name> <version> <alias> --token --server : no eik.json or .eikrc', async (t) => {
const eik = join(__dirname, '../../index.js');
const cmd = `${eik} npm-alias scroll-into-view-if-needed 2.2.24 2
--token ${t.context.token}
Expand All @@ -125,13 +125,13 @@ test('eik npm-alias <name> <version> <alias> --token --server : no assets.json o
t.end();
});

test('eik npm-alias <name> <version> <alias> : publish details provided by assets.json file', async (t) => {
test('eik npm-alias <name> <version> <alias> : publish details provided by eik.json file', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);
const eik = join(__dirname, '../../index.js');
Expand All @@ -153,7 +153,7 @@ test('eik npm-alias <name> <version> <alias> : publish details provided by asset
t.end();
});

test('eik map-alias <name> <version> <alias> --token --server : no assets.json or .eikrc', async (t) => {
test('eik map-alias <name> <version> <alias> --token --server : no eik.json or .eikrc', async (t) => {
const eik = join(__dirname, '../../index.js');
const cmd = `${eik} map-alias test-map 1.0.0 1
--token ${t.context.token}
Expand All @@ -177,13 +177,13 @@ test('eik map-alias <name> <version> <alias> --token --server : no assets.json o
t.end();
});

test('eik map-alias <name> <version> <alias> : publish details provided by assets.json file', async (t) => {
test('eik map-alias <name> <version> <alias> : publish details provided by eik.json file', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);
const eik = join(__dirname, '../../index.js');
Expand Down
28 changes: 14 additions & 14 deletions test/integration/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ function exec(cmd) {
});
}

test('Initializing a new assets.json file', async t => {
test('Initializing a new eik.json file', async t => {
const eik = join(__dirname, '../../index.js');
const folder = await fs.mkdtemp(join(os.tmpdir(), 'foo-'));

const publishCmd = `${eik} init --cwd ${folder}`;
await exec(publishCmd);

const assets = JSON.parse(
readFileSync(join(folder, 'assets.json')),
readFileSync(join(folder, 'eik.json')),
);

t.equals(assets.name, '', 'assets.json "name" field should be empty');
t.equals(assets.major, 1, 'assets.json "major" field should equal 1');
t.equals(assets.server, '', 'assets.json "server" field should be empty');
t.equals(assets.name, '', 'eik.json "name" field should be empty');
t.equals(assets.major, 1, 'eik.json "major" field should equal 1');
t.equals(assets.server, '', 'eik.json "server" field should be empty');
t.equals(
assets.js.input,
'',
'assets.json "js.input" field should be empty',
'eik.json "js.input" field should be empty',
);
t.equals(
assets.css.input,
'',
'assets.json "css.input" field should be empty',
'eik.json "css.input" field should be empty',
);
});

test('Initializing a new assets.json file passing custom values', async t => {
test('Initializing a new eik.json file passing custom values', async t => {
const eik = join(__dirname, '../../index.js');
const folder = await fs.mkdtemp(join(os.tmpdir(), 'foo-'));

Expand All @@ -55,32 +55,32 @@ test('Initializing a new assets.json file passing custom values', async t => {
await exec(publishCmd.split('\n').join(' '));

const assets = JSON.parse(
readFileSync(join(folder, 'assets.json')),
readFileSync(join(folder, 'eik.json')),
);

t.equals(
assets.name,
'custom-name',
'assets.json "name" field should not be empty',
'eik.json "name" field should not be empty',
);
t.equals(
assets.major,
2,
'assets.json "major" field should not be empty',
'eik.json "major" field should not be empty',
);
t.equals(
assets.server,
'http://localhost:4001',
'assets.json "server" field should not be empty',
'eik.json "server" field should not be empty',
);
t.equals(
assets.js.input,
'./assets/client.js',
'assets.json "js.input" field should not be empty',
'eik.json "js.input" field should not be empty',
);
t.equals(
assets.css.input,
'./assets/styles.css',
'assets.json "css.input" field should not be empty',
'eik.json "css.input" field should not be empty',
);
});
6 changes: 3 additions & 3 deletions test/integration/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ afterEach(async (done, t) => {
done();
});

test('eik map --token --server : no assets.json or .eikrc', async (t) => {
test('eik map --token --server : no eik.json or .eikrc', async (t) => {
const map = {
imports: {
'scroll-into-view-if-needed': new URL(
Expand Down Expand Up @@ -77,13 +77,13 @@ test('eik map --token --server : no assets.json or .eikrc', async (t) => {
t.end();
});

test('eik map : publish, details provided by assets.json file', async (t) => {
test('eik map : publish, details provided by eik.json file', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);

Expand Down
6 changes: 3 additions & 3 deletions test/integration/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ afterEach(async (done, t) => {
done();
});

test('eik meta --server : no assets.json', async (t) => {
test('eik meta --server : no eik.json', async (t) => {
const eik = join(__dirname, '../../index.js');
const cmd = `${eik} meta scroll-into-view-if-needed --server ${t.context.address}`;

Expand All @@ -61,13 +61,13 @@ test('eik meta --server : no assets.json', async (t) => {
t.end();
});

test('eik meta : details provided by assets.json', async (t) => {
test('eik meta : details provided by eik.json', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);

Expand Down
6 changes: 3 additions & 3 deletions test/integration/npm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ afterEach(async (done, t) => {
done();
});

test('eik npm --token --server : no assets.json or .eikrc', async (t) => {
test('eik npm --token --server : no eik.json or .eikrc', async (t) => {
const eik = join(__dirname, '../../index.js');
const cmd = `${eik} npm scroll-into-view-if-needed 2.2.24
--token ${t.context.token}
Expand All @@ -66,13 +66,13 @@ test('eik npm --token --server : no assets.json or .eikrc', async (t) => {
t.end();
});

test('eik npm : publish details provided by assets.json file and .eikrc', async (t) => {
test('eik npm : publish details provided by eik.json file and .eikrc', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);

Expand Down
6 changes: 3 additions & 3 deletions test/integration/package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ afterEach(async (done, t) => {
done();
});

test('eik package : package, details provided by assets.json file', async (t) => {
test('eik package : package, details provided by eik.json file', async (t) => {
const assets = {
name: 'test-app',
server: t.context.address,
Expand All @@ -54,7 +54,7 @@ test('eik package : package, details provided by assets.json file', async (t) =>
};

await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);

Expand Down Expand Up @@ -126,7 +126,7 @@ test('workflow: publish npm, alias npm, publish map, alias map and then publish
'import-map': [new URL('/map/my-map/v1', t.context.address).href]
};
await fs.writeFile(
join(t.context.folder, 'assets.json'),
join(t.context.folder, 'eik.json'),
JSON.stringify(assets),
);

Expand Down
6 changes: 3 additions & 3 deletions utils/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const resolvePath = require('./resolve-path');

module.exports = function getDefaults(cwd) {
try {
// read assets.json in current dir
const assetsPath = resolvePath('./assets.json', cwd).pathname;
// read eik.json in current dir
const assetsPath = resolvePath('./eik.json', cwd).pathname;
const assetsFile = existsSync(assetsPath) ? readFileSync(assetsPath) : '{}';
const assets = JSON.parse(assetsFile);

Expand All @@ -24,7 +24,7 @@ module.exports = function getDefaults(cwd) {
server = tokens.keys().next().value;
}

// server value in assets.json always takes presedence
// server value in eik.json always takes presedence
if (assets.server) {
server = assets.server;
}
Expand Down

0 comments on commit e8bd24d

Please sign in to comment.