Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accent-cli

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accent-cli - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

lib/services/formatters/hook-runner.d.ts

2

.oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"0.3.0","commands":{"add-translations":{"id":"add-translations","description":"Add translations in Accent and write them to your local filesystem","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent add-translations","$ accent add-translations Localization-admin"],"flags":{"write":{"name":"write","type":"boolean","description":"Write the file from the export _after_ the operation"},"mergeType":{"name":"mergeType","type":"option","required":false,"options":["smart","force","passive"],"default":"passive"}},"args":[{"name":"filename","required":false}]},"stats":{"id":"stats","description":"Fetch stats from the API and display it beautifully","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent stats"],"flags":{},"args":[]},"sync":{"id":"sync","description":"Sync files in Accent and write them to your local filesystem","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent sync","$ accent sync Localization-admin"],"flags":{"write":{"name":"write","type":"boolean","description":"Write the file from the export _after_ the operation"}},"args":[{"name":"filename","required":false}]}}}
{"version":"0.4.0","commands":{"add-translations":{"id":"add-translations","description":"Add translations in Accent and write them to your local filesystem","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent add-translations","$ accent add-translations Localization-admin"],"flags":{"write":{"name":"write","type":"boolean","description":"Write the file from the export _after_ the operation"},"mergeType":{"name":"mergeType","type":"option","required":false,"options":["smart","force","passive"],"default":"passive"}},"args":[{"name":"filename","required":false}]},"stats":{"id":"stats","description":"Fetch stats from the API and display it beautifully","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent stats"],"flags":{},"args":[]},"sync":{"id":"sync","description":"Sync files in Accent and write them to your local filesystem","pluginName":"accent-cli","pluginType":"core","aliases":[],"examples":["$ accent sync","$ accent sync Localization-admin"],"flags":{"write":{"name":"write","type":"boolean","description":"Write the file from the export _after_ the operation"}},"args":[{"name":"filename","required":false}]}}}

@@ -27,4 +27,2 @@ import { flags } from '@oclif/command';

private processDocumentConfig(document);
private logProjectOperation(project, documentConfigs);
private logProjectExport(documentConfigs);
}

@@ -11,2 +11,5 @@ "use strict";

const document_export_1 = require("../services/formatters/document-export");
const hook_runner_1 = require("../services/hook-runner");
// Types
const document_config_1 = require("../types/document-config");
class AddTranslations extends base_commit_1.default {

@@ -17,6 +20,9 @@ async run() {

const documents = this.projectConfig.addTranslations(args.filename);
const documentConfigs = documents.map((document) => document.config);
// From all the documentConfigs, do the add translations or peek operations and log the results.
this.logProjectOperation(this.project, documents.map((document) => document.config));
new project_add_translations_1.default(this.project).log(documentConfigs);
for (const document of documents) {
await new hook_runner_1.default(document).run(document_config_1.Hooks.beforeAddTranslations);
await Promise.all(this.processDocumentConfig(document));
await new hook_runner_1.default(document).run(document_config_1.Hooks.afterAddTranslations);
}

@@ -27,4 +33,5 @@ if (!flags.write)

// From all the documentConfigs, do the export, write to local file and log the results.
this.logProjectExport(documents.map((document) => document.config));
new project_export_1.default().log(documentConfigs);
for (const document of documents) {
await new hook_runner_1.default(document).run(document_config_1.Hooks.beforeExport);
await Promise.all(document.paths.map(path => {

@@ -34,2 +41,3 @@ formatter.log(path);

}));
await new hook_runner_1.default(document).run(document_config_1.Hooks.afterExport);
}

@@ -50,10 +58,2 @@ }

}
logProjectOperation(project, documentConfigs) {
const formatter = new project_add_translations_1.default(project);
formatter.log(documentConfigs);
}
logProjectExport(documentConfigs) {
const formatter = new project_export_1.default();
formatter.log(documentConfigs);
}
}

@@ -60,0 +60,0 @@ AddTranslations.description = 'Add translations in Accent and write them to your local filesystem';

@@ -25,4 +25,2 @@ import Command from '../base-commit';

private processDocumentConfig(document);
private logProjectOperation(project, documentConfigs);
private logProjectExport(documentConfigs);
}

@@ -10,2 +10,5 @@ "use strict";

const document_export_1 = require("../services/formatters/document-export");
const hook_runner_1 = require("../services/hook-runner");
// Types
const document_config_1 = require("../types/document-config");
class Sync extends base_commit_1.default {

@@ -16,6 +19,9 @@ async run() {

const documents = this.projectConfig.sync(args.filename);
const documentConfigs = documents.map((document) => document.config);
// From all the documentConfigs, do the sync or peek operations and log the results.
this.logProjectOperation(this.project, documents.map((document) => document.config));
new project_sync_1.default(this.project).log(documentConfigs);
for (const document of documents) {
await new hook_runner_1.default(document).run(document_config_1.Hooks.beforeSync);
await Promise.all(this.processDocumentConfig(document));
await new hook_runner_1.default(document).run(document_config_1.Hooks.afterSync);
}

@@ -26,4 +32,5 @@ if (!flags.write)

// From all the documentConfigs, do the export, write to local file and log the results.
this.logProjectExport(documents.map((document) => document.config));
new project_export_1.default().log(documentConfigs);
for (const document of documents) {
await new hook_runner_1.default(document).run(document_config_1.Hooks.beforeExport);
await Promise.all(document.paths.map(path => {

@@ -33,2 +40,3 @@ formatter.log(path);

}));
await new hook_runner_1.default(document).run(document_config_1.Hooks.afterExport);
}

@@ -48,10 +56,2 @@ }

}
logProjectOperation(project, documentConfigs) {
const formatter = new project_sync_1.default(project);
formatter.log(documentConfigs);
}
logProjectExport(documentConfigs) {
const formatter = new project_export_1.default();
formatter.log(documentConfigs);
}
}

@@ -58,0 +58,0 @@ Sync.description = 'Sync files in Accent and write them to your local filesystem';

@@ -0,1 +1,17 @@

export declare enum Hooks {
beforeSync = "beforeSync",
afterSync = "afterSync",
beforeAddTranslations = "beforeAddTranslations",
afterAddTranslations = "afterAddTranslations",
beforeExport = "beforeExport",
afterExport = "afterExport",
}
export interface HookConfig {
[Hooks.beforeSync]: string;
[Hooks.afterSync]: string;
[Hooks.beforeAddTranslations]: string;
[Hooks.afterAddTranslations]: string;
[Hooks.beforeExport]: string;
[Hooks.afterExport]: string;
}
export interface DocumentConfig {

@@ -6,2 +22,3 @@ name: string;

path: string;
hooks?: HookConfig;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Hooks;
(function (Hooks) {
Hooks["beforeSync"] = "beforeSync";
Hooks["afterSync"] = "afterSync";
Hooks["beforeAddTranslations"] = "beforeAddTranslations";
Hooks["afterAddTranslations"] = "afterAddTranslations";
Hooks["beforeExport"] = "beforeExport";
Hooks["afterExport"] = "afterExport";
})(Hooks = exports.Hooks || (exports.Hooks = {}));
{
"name": "accent-cli",
"version": "0.3.0",
"version": "0.4.0",
"author": "Simon Prévost",

@@ -14,2 +14,3 @@ "description": "Accent CLI",

"@oclif/plugin-not-found": "~> 1.0",
"@types/decamelize": "1.2.0",
"@types/form-data": "2.2.1",

@@ -21,2 +22,3 @@ "@types/fs-extra": "5.0.1",

"cli-ux": "3.3.26",
"decamelize": "2.0.0",
"form-data": "2.3.2",

@@ -69,3 +71,3 @@ "glob": "7.1.2",

"fix": "tslint --project tsconfig.json --fix 'src/**/*.{ts,tsx}'",
"prepublishOnly": "npm run build && oclif-dev manifest",
"prepublishOnly": "npm run build && oclif-dev readme && oclif-dev manifest",
"prettier": "prettier --single-quote --no-bracket-spacing --no-semi --write './src/**/*.{js,json,ts,tsx,gql}'",

@@ -72,0 +74,0 @@ "test": "mocha --forbid-only \"test/**/*.test.ts\""

@@ -8,3 +8,6 @@ Accent CLI

* [Usage](#usage)
* [Configuration](#configuration)
* [Commands](#commands)
* [License](#license)
* [About Mirego](#about-mirego)
<!-- tocstop -->

@@ -19,3 +22,3 @@

$ accent (-v|--version|version)
accent/0.0.0 darwin-x64 node-v8.5.0
accent-cli/0.4.0 darwin-x64 node-v8.5.0
$ accent --help [COMMAND]

@@ -28,35 +31,64 @@ USAGE

# Commands
<!-- commands -->
## accent help [FILE]
# Configuration
describe the command here
accent-cli reads from a `accent.json` file. The file should contain valid JSON representing the configuration of your project.
```
USAGE
$ accent [COMMAND]
## Example
COMMANDS
add-translations Add translations in Accent and write them to your local filesystem
help display help for accent
stats Fetch stats from the API and display it beautifully
sync Sync files in Accent and write them to your local filesystem
```
{
"api": {
"url": "http://your.accent.instance",
"key": "2nziVSaa8yUJxLkwoZA"
},
"sync": [
{
"language": "fr",
"format": "json",
"path": "localization/fr/*.json",
"hooks": {
"afterSync": "touch sync-done.txt",
}
}
],
"addTranslations": [
{
"language": "en",
"format": "json",
"path": "localization/en/*.json",
"hooks": {
"afterSync": "touch add-translations-done.txt",
}
}
]
}
```
## accent sync [FILENAME]
## Document configuration
Sync files in Accent and write them to your local filesystem
Each operation section `sync` and `addTranslations` can contain the following object:
```
USAGE
$ accent sync [FILENAME]
- `language`: The identifier of the document’s language
- `format`: The format of the document
- `path`: The path of the document. This can contain glob pattern (See [the node glob library] used as a dependancy (https://github.com/isaacs/node-glob))
- `hooks`: List of hooks to be run
OPTIONS
--write Write the file from the export _after_ the operation
## Hooks
EXAMPLES
$ accent sync
$ accent sync Localization-admin
```
Here is a list of available hooks. Those are self-explanatory
- `beforeSync`
- `afterSync`
- `beforeAddTranslations`
- `afterAddTranslations`
- `beforeExport`
- `afterExport`
# Commands
<!-- commands -->
* [accent add-translations [FILENAME]](#accent-add-translations-filename)
* [accent help [COMMAND]](#accent-help-command)
* [accent stats](#accent-stats)
* [accent sync [FILENAME]](#accent-sync-filename)
## accent add-translations [FILENAME]

@@ -79,2 +111,19 @@

## accent help [COMMAND]
display help for accent
```
USAGE
$ accent help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
```
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v1.2.2/src/commands/help.ts)_
## accent stats

@@ -90,23 +139,18 @@

$ accent stats
```
OUTPUT
=== Stats cli v2
## accent sync [FILENAME]
=== Last synced
2018-03-27T21:30:06.233789Z
Sync files in Accent and write them to your local filesystem
=== Master language
French
```
USAGE
$ accent sync [FILENAME]
=== Translations (1)
English
OPTIONS
--write Write the file from the export _after_ the operation
=== Documents
Format: JSON
Path: public
=== Strings
# Strings: 6
✓ Reviewed: 0
× In review: 6
EXAMPLES
$ accent sync
$ accent sync Localization-admin
```

@@ -113,0 +157,0 @@ <!-- commandsstop -->

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc