Skip to content
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

"Manifest must include a JSON object." #19

Open
gregfenton opened this issue Oct 17, 2020 · 7 comments
Open

"Manifest must include a JSON object." #19

gregfenton opened this issue Oct 17, 2020 · 7 comments

Comments

@gregfenton
Copy link

gregfenton commented Oct 17, 2020

Topic and scope of discussion

Unable to get version bumping for app.config.js files - getting the subject's message to the console.

Motivation

To understand if a flexible, dynamic configuration is currently possible.

Additional context

In my .versionrc.js I have the following:

/*
 * From https://gist.github.com/gregfenton/b81ec014e8488dc5576f8444cbf7bcd4
 */
let fs = require('fs');

let bumps = [
  {filename: 'package.json'},
];

let CONFIGS_DIR = './customer-configs';

try {
  let entries = fs.readdirSync(CONFIGS_DIR, {withFileTypes: true});
  for (let i = 0; i < entries.length; i++) {
    let entry = entries[i];
    let confFile = `${CONFIGS_DIR}/${entry.name}/app.config.js`;
    if (entry?.isDirectory()) {ame: 
      if (fs.existsSync(confFile)) {
        // updates `expo.version`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo'),
        });
        // updates `expo.android.versionCode`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo/android'),
        });
        // updates `expo.ios.buildNumber`
        bumps.push({
          filename: confFile,
          updater: require.resolve('standard-version-expo/ios'),
        });
      }
    }
  }
} catch (ex) {
  console.log(`EXCEPTION with readdir: ${ex.message}`);
  throw ex;
}

module.exports = {
  bumpFiles: [...bumps],
};

When I run npx standard-version --dry-run I get the following output:

$ npx standard-version --dry-run
✔ bumping version in package.json from 0.2.17 to 0.2.18
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
Manifest must include a JSON object.
✔ outputting changes to CHANGELOG.md

---
### [0.2.18](https://github.com/gregfenton/rn_tick8s/compare/v0.2.17...v0.2.18) (2020-10-17)
---

✔ committing package.json and CHANGELOG.md
✔ tagging release v0.2.18
ℹ Run `git push --follow-tags origin main` to publish

and my app.config.js files do not update. I have 2 app.config.js files (I have 2 customer-configs), and I'm quite certain that the 6 instances of "Manifest must include a JSON object." are coming from (2 customer-configs * 3 updaters).

Looking at the code in standard-version-expo/build/expo.js, it seems that the code to parseJsonString() is failing with the exception message ending with:

└─ Cause: SyntaxError: JSON5: invalid character 'i' at 1:1
> 1 | import fs from 'fs';
    | ^
  2 | 
  3 | const APP_NAME = 'tick8s';
  4 | const FB_PROJECT_NAME = 't8s-CUSTOMER-DETAILS-HERE';

So it is blowing up simply trying to read in the app.config.js.

Any thoughts on what I could try next? It clearly finds the config files, but fails to parse them

@ourmaninamsterdam
Copy link

@gregfenton it appears it lacks support for app.config.js: #12 . It's a great library but I had to shelve use of it due to lack of support for app.config.js.

@oriharel
Copy link

A possible workaround is to use app.json and app.config.js. Example:

app.json:

{
 "expo": {
    "version": "0.2.5"
 }
}

app.config.js:

import appJson from "./app.json";

export default {
 ...
 version: appJson.expo.version,
 ...
}

There are actually other tools that don't play nice with app.config.js (e.g., detox)

@gregfenton
Copy link
Author

@oriharel - interesting, though then I wonder the value of using this extension over pure standard-version? I have essentially followed your approach, though I named my file version.json and I'm just using standard-version's configuration file .versionrc.js with:

/*
 * From https://gist.github.com/gregfenton/b81ec014e8488dc5576f8444cbf7bcd4
 */
const fs = require('fs');
const path = require('path');

const bumps = [
  {filename: 'package.json'},
]; // update the global project

const PROJECTS_DIR = './subprojects';
const VERSION_JSON_FILENAME = 'version.json';

try {
  let entries = fs.readdirSync(PROJECTS_DIR, {withFileTypes: true});
  for (let i = 0; i < entries.length; i++) {
    let entry = entries[i];
    if (entry?.isDirectory()) {
      let confFile = path.join(PROJECTS_DIR, entry.name, VERSION_JSON_FILENAME);
      if (fs.existsSync(confFile)) {
        bumps.push({
          filename: confFile,
          type: 'json',
        });
      }
    }
  }
} catch (ex) {
  console.log(`EXCEPTION with readdir(): ${ex.message}`);
  throw ex;
}

module.exports = {
  bumpFiles: [...bumps],
};

@Stevemoretz
Copy link

I need this feature too...

@sainijagjit
Copy link

Having this feature would be helpful

@gregfenton
Copy link
Author

Note: standard-version is no longer being actively maintained 😕

@Stevemoretz
Copy link

Note: standard-version is no longer being actively maintained 😕

Yeah that's a bummer but I think it's famous enough to get a serious fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants