@faststore/cli
Advanced tools
Comparing version 3.0.13 to 3.0.22
/// <reference types="node" /> | ||
import { Command } from '@oclif/core'; | ||
export default class CmsSync extends Command { | ||
run(): Promise<import("child_process").ChildProcess>; | ||
static flags: { | ||
"dry-run": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>; | ||
}; | ||
run(): Promise<import("child_process").ChildProcess | undefined>; | ||
} |
@@ -8,4 +8,12 @@ "use strict"; | ||
class CmsSync extends core_1.Command { | ||
static flags = { | ||
['dry-run']: core_1.Flags.boolean({ char: 'd' }), | ||
}; | ||
async run() { | ||
const { flags } = await this.parse(CmsSync); | ||
await (0, generate_1.generate)({ setup: true }); | ||
await (0, generate_1.generateCMSFiles)(); | ||
if (flags['dry-run']) { | ||
return; | ||
} | ||
return (0, child_process_1.spawn)(`vtex cms sync faststore`, { | ||
@@ -12,0 +20,0 @@ shell: true, |
@@ -5,2 +5,3 @@ interface GenerateOptions { | ||
export declare function generate(options?: GenerateOptions): Promise<void>; | ||
export declare function generateCMSFiles(): Promise<void>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generate = void 0; | ||
exports.generateCMSFiles = exports.generate = void 0; | ||
const tslib_1 = require("tslib"); | ||
const fs_extra_1 = require("fs-extra"); | ||
const path_1 = tslib_1.__importDefault(require("path")); | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const directory_1 = require("./directory"); | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const hcms_1 = require("./hcms"); | ||
// package.json is copied manually after filtering its content | ||
@@ -157,34 +158,2 @@ const ignorePaths = ['package.json', 'node_modules', 'cypress.config.ts']; | ||
} | ||
function mergeCMSFile(fileName) { | ||
const customFilePath = path_1.default.join(directory_1.userCMSDir, fileName); | ||
const coreFilePath = path_1.default.join(directory_1.coreCMSDir, fileName); | ||
const coreFile = (0, fs_extra_1.readFileSync)(coreFilePath, 'utf8'); | ||
const output = [...JSON.parse(coreFile)]; | ||
// TODO: create a validation when has the cms files but doesn't have a component for then | ||
if ((0, fs_extra_1.existsSync)(customFilePath)) { | ||
const customFile = (0, fs_extra_1.readFileSync)(customFilePath, 'utf8'); | ||
try { | ||
output.push(...JSON.parse(customFile)); | ||
} | ||
catch (err) { | ||
if (err instanceof SyntaxError) { | ||
console.info(`${chalk_1.default.red('error')} - ${fileName} is a malformed JSON file, ignoring its contents.`); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
} | ||
try { | ||
(0, fs_extra_1.writeFileSync)(path_1.default.join(directory_1.tmpCMSDir, fileName), JSON.stringify(output)); | ||
console.log(`${chalk_1.default.green('success')} - CMS file ${chalk_1.default.dim(fileName)} created`); | ||
} | ||
catch (err) { | ||
console.error(`${chalk_1.default.red('error')} - ${err}`); | ||
} | ||
} | ||
function mergeCMSFiles() { | ||
mergeCMSFile('content-types.json'); | ||
mergeCMSFile('sections.json'); | ||
} | ||
async function generate(options) { | ||
@@ -205,7 +174,10 @@ const { setup = false } = options ?? {}; | ||
copyTheme(), | ||
createCmsWebhookUrlsJsonFile(), | ||
mergeCMSFiles(), | ||
]); | ||
} | ||
exports.generate = generate; | ||
async function generateCMSFiles() { | ||
await createCmsWebhookUrlsJsonFile(); | ||
await (0, hcms_1.mergeCMSFiles)(); | ||
} | ||
exports.generateCMSFiles = generateCMSFiles; | ||
//# sourceMappingURL=generate.js.map |
@@ -1,1 +0,1 @@ | ||
{"version":"3.0.13","commands":{"build":{"id":"build","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"cms-sync":{"id":"cms-sync","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"dev":{"id":"dev","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate-graphql":{"id":"generate-graphql","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{"debug":{"name":"debug","type":"boolean","char":"d","allowNo":false},"core":{"name":"core","type":"boolean","char":"c","hidden":true,"allowNo":false}},"args":[]},"start":{"id":"start","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"test":{"id":"test","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]}}} | ||
{"version":"3.0.22","commands":{"build":{"id":"build","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"cms-sync":{"id":"cms-sync","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{"dry-run":{"name":"dry-run","type":"boolean","char":"d","allowNo":false}},"args":[]},"dev":{"id":"dev","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"generate-graphql":{"id":"generate-graphql","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{"debug":{"name":"debug","type":"boolean","char":"d","allowNo":false},"core":{"name":"core","type":"boolean","char":"c","hidden":true,"allowNo":false}},"args":[]},"start":{"id":"start","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"test":{"id":"test","strict":true,"pluginName":"@faststore/cli","pluginAlias":"@faststore/cli","pluginType":"core","aliases":[],"flags":{},"args":[]}}} |
{ | ||
"name": "@faststore/cli", | ||
"version": "3.0.13", | ||
"version": "3.0.22", | ||
"description": "FastStore CLI", | ||
@@ -36,4 +36,6 @@ "author": "Emerson Laurentino @emersonlaurentino", | ||
"eslint": "7.32.0", | ||
"jest": "^29.7.0", | ||
"oclif": "^3", | ||
"shx": "^0.3.3", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.1", | ||
@@ -59,2 +61,3 @@ "tslib": "^2.3.1", | ||
"lint": "eslint src/**/*.ts", | ||
"test": "jest src/**/*.test.ts", | ||
"postpack": "shx rm -f oclif.manifest.json", | ||
@@ -70,3 +73,3 @@ "posttest": "yarn lint", | ||
"types": "dist/index.d.ts", | ||
"gitHead": "9ccaaa8c2e9e6b2c9f3c82ac3d52405e51ddd6a0" | ||
"gitHead": "efaaecd4ce65532d3615595645b5b9d0fa0fe2a0" | ||
} |
@@ -33,3 +33,3 @@ <p align="center"> | ||
$ faststore (--version) | ||
@faststore/cli/3.0.13 linux-x64 node-v18.19.1 | ||
@faststore/cli/3.0.22 darwin-arm64 node-v18.19.0 | ||
$ faststore --help [COMMAND] | ||
@@ -60,3 +60,3 @@ USAGE | ||
_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/build.ts)_ | ||
_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/build.ts)_ | ||
@@ -67,6 +67,9 @@ ## `faststore cms-sync` | ||
USAGE | ||
$ faststore cms-sync | ||
$ faststore cms-sync [-d] | ||
FLAGS | ||
-d, --dry-run | ||
``` | ||
_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/cms-sync.ts)_ | ||
_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/cms-sync.ts)_ | ||
@@ -80,3 +83,3 @@ ## `faststore dev` | ||
_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/dev.ts)_ | ||
_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/dev.ts)_ | ||
@@ -93,3 +96,3 @@ ## `faststore generate-graphql` | ||
_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/generate-graphql.ts)_ | ||
_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/generate-graphql.ts)_ | ||
@@ -123,3 +126,3 @@ ## `faststore help [COMMAND]` | ||
_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/start.ts)_ | ||
_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/start.ts)_ | ||
@@ -133,3 +136,3 @@ ## `faststore test` | ||
_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.13/dist/commands/test.ts)_ | ||
_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.22/dist/commands/test.ts)_ | ||
<!-- commandsstop --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
81925
50
1204
132
14
12
7