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

Rewrite #35

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": [
"@vkontakte"
],
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"requireConfigFile": false
},
"rules": {
"guard-for-in": "off",
"comma-dangle": [
"error",
"never"
]
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ node_modules/
build/
bundle.zip
vk-hosting-config.json
*.log
*.lock
*-lock.json
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ To configure `vk-miniapps-deploy` all you need to do is specify a couple of thin
```

## How to use:

* Make sure that in package.json the key value «homepage» is «./»
* Copy the example config to the root folder of your application vk-hosting-config.json.example
and remove the suffix «.example»
* Run yarn deploy

For your CI, you can use
CI/CD is automatically detected, you only need to pass `access_token` to env:

```bash
$ env MINI_APPS_ACCESS_TOKEN=<token> yarn deploy
$ cross-env MINI_APPS_ACCESS_TOKEN=<token> yarn deploy
```

with *user token* retrieved from vk-miniapps-deploy OR *service token* of deployable application
Expand All @@ -67,12 +68,38 @@ There are two values to specify MINI_APPS_ENVIRONMENT: `production` or `dev`.
All production builds will be also deployed on dev environment.

If you grep URL paths, you can use environment variable `CI_URLS = true`.
URLs will be printed as followed structure (⇆ is tab character):

```md
# development
vk_app_desktop_dev_url:⇆url
vk_app_dev_url:⇆url
vk_mini_app_mvk_dev_url:⇆url

# production
iframe_secure_url:⇆url
m_iframe_secure_url:⇆url
vk_mini_app_mvk_url:⇆url
```

> See [URL_NAMES](./lib/deploy.js#L8) for more information.

If you always need to run in CI/CD-mode, in config:

```json
{
"noprompt": true
}
```

## Troubleshooting:
If you get an error `User authorization failed: invalid session`, try this comand:

If you get an error `Access token is invalid`, try this comand:

```bash
rm ~/.config/configstore/@vkontakte/vk-miniapps-deploy.json
```

[npm]: https://img.shields.io/npm/v/@vkontakte/vk-miniapps-deploy.svg
[npm-url]: https://npmjs.com/package/@vkontakte/vk-miniapps-deploy
[deps]: https://img.shields.io/david/vkcom/vk-miniapps-deploy.svg
Expand Down
47 changes: 1 addition & 46 deletions bin/vk-miniapps-deploy
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
#!/usr/bin/env node
var chalk = require('chalk');
const fs = require('fs-extra');
const configFilePath = './vk-hosting-config.json';
const prompt = require('prompts');

async function run() {
if (fs.pathExists(configFilePath).then((res) => {
if (!res) {
console.error(configFilePath + ' is missing');
return false;
}
})) ;

const configJSON = require('require-module')(configFilePath);
if (!configJSON) {
console.error(configFilePath + ' is missing');
return false;
}

const deploy = require('../index');
const cfg = configJSON || {};

if (!cfg) {
console.error('vk-hosting-config.json is missing');
return false;
}

if (cfg.noprompt) {
deploy.run(cfg);
} else {
prompt.message = chalk.cyan("vk-mini-apps-deploy:");
prompt.delimiter = chalk.green(" $ ");

const result = await prompt({
type: 'confirm',
initial: true,
name: 'result',
message: chalk.yellow('Would you like to deploy to VK Mini Apps hosting using these commands?')
});

if (result.result) {
const status = await deploy.run(cfg) ? 0 : 1;
process.exit(status);
}
}
}
run().then(r => console.log(r));
require('../lib/index');
Loading