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

react-creates

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-creates - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

dist/fetch-template.d.ts

80

dist/commands/create-component.js

@@ -12,2 +12,3 @@ "use strict";

const file_system_cache_1 = require("../file-system-cache");
const fetch_template_1 = require("../fetch-template");
function createComponentCommand() {

@@ -27,40 +28,47 @@ let optionsCache;

.option('--fresh', 'Will not use cache')
.action((name, options) => (0, core_1.createComponent)({ name, ...options }, {
fileSystem: node_1.nodeFs,
logger: console,
templateDirectory: node_1.nodeFs.join(node_1.nodeFs.dirname(require.resolve('react-creates/package.json')), 'templates', 'component'),
onFinished({ name: _name, directory: _directory, ...resolvedOptions }) {
if (optionsCache && !options.fresh && !options.yes) {
for (const [key, value] of Object.entries(resolvedOptions)) {
.option('--templatesDirectory <string>', 'Target root directory for templates to be stored locally')
.action((name, options) => {
const { templatesDirectory } = options;
return (0, core_1.createComponent)({ name, ...options }, {
fileSystem: node_1.nodeFs,
logger: console,
async getTemplateDirectory({ language, type }) {
const { targetTemplateDirectory } = await (0, fetch_template_1.fetchTemplate)(['component', language, type], templatesDirectory);
return targetTemplateDirectory;
},
onFinished({ name: _name, directory: _directory, ...resolvedOptions }) {
if (optionsCache && !options.fresh && !options.yes) {
for (const [key, value] of Object.entries(resolvedOptions)) {
optionsCache.set(key, value);
}
}
},
async resolveProperty(key) {
if (options.yes) {
return;
}
if (!optionsCache) {
optionsCache = file_system_cache_1.FileSystemCache.create({ fileSystem: node_1.nodeFs, rootDir: options.directory });
}
if (!options.fresh && optionsCache.has(key)) {
return optionsCache.get(key);
}
if (!(key === 'style' || key === 'language' || key === 'type')) {
return;
}
const values = [...core_1.createComponentProperties[key]];
const response = await (0, prompts_1.default)({
type: 'select',
name: key,
message: `Select component ${key}:`,
choices: values.map((value) => ({ title: value.toString(), value })),
});
const value = response[key];
if (!options.fresh) {
optionsCache.set(key, value);
}
}
},
async resolveProperty(key) {
if (options.yes) {
return;
}
if (!optionsCache) {
optionsCache = file_system_cache_1.FileSystemCache.create({ fileSystem: node_1.nodeFs, rootDir: options.directory });
}
if (!options.fresh && optionsCache.has(key)) {
return optionsCache.get(key);
}
if (!(key === 'style' || key === 'language' || key === 'type')) {
return;
}
const values = [...core_1.createComponentProperties[key]];
const response = await (0, prompts_1.default)({
type: 'select',
name: key,
message: `Select component ${key}:`,
choices: values.map((value) => ({ title: value.toString(), value })),
});
const value = response[key];
if (!options.fresh) {
optionsCache.set(key, value);
}
return value;
},
}));
return value;
},
});
});
}

@@ -67,0 +75,0 @@ exports.createComponentCommand = createComponentCommand;

@@ -11,3 +11,3 @@ import type { IFileSystem } from '@file-services/types';

static create({ fileSystem, rootDir }?: FileSystemCacheOptions): FileSystemCache;
static getCachePath({ fileSystem, rootDir }?: FileSystemCacheOptions): string;
static getCacheRootPath({ rootDir }?: FileSystemCacheOptions): string;
static delete({ fileSystem, rootDir }?: FileSystemCacheOptions): boolean;

@@ -14,0 +14,0 @@ private constructor();

@@ -15,18 +15,14 @@ "use strict";

static create({ fileSystem = node_1.nodeFs, rootDir = process.cwd() } = {}) {
return new this(fileSystem, FileSystemCache.getCachePath({ fileSystem, rootDir }));
return new this(fileSystem, fileSystem.join(FileSystemCache.getCacheRootPath({ rootDir }), 'cache.json'));
}
static getCachePath({ fileSystem = node_1.nodeFs, rootDir = process.cwd() } = {}) {
const packageJsonPath = fileSystem.findClosestFileSync(rootDir, 'package.json');
if (!packageJsonPath) {
throw new Error('Could not find package.json');
}
static getCacheRootPath({ rootDir = process.cwd() } = {}) {
const cachePathDir = (0, find_cache_dir_1.default)({
name: fileSystem.join('react-creates', packageJsonPath),
name: 'react-creates',
create: true,
cwd: rootDir,
});
return fileSystem.join(cachePathDir, 'cache.json');
return cachePathDir;
}
static delete({ fileSystem = node_1.nodeFs, rootDir = process.cwd() } = {}) {
const cachePath = FileSystemCache.getCachePath({ fileSystem, rootDir });
const cachePath = FileSystemCache.getCacheRootPath({ rootDir });
if (fileSystem.existsSync(cachePath)) {

@@ -33,0 +29,0 @@ fileSystem.unlinkSync(cachePath);

{
"name": "react-creates",
"version": "2.1.2",
"version": "2.1.3",
"description": "React creates for you useful and common tools that adapt themselves to your project for faster and easier development",

@@ -9,4 +9,3 @@ "files": [

"!dist/tsconfig.tsbuildinfo",
"src",
"templates"
"src"
],

@@ -39,8 +38,9 @@ "types": "dist/index.d.ts",

"dependencies": {
"@file-services/node": "^6.0.0",
"@file-services/types": "^6.0.0",
"@file-services/node": "^7.0.1",
"@file-services/types": "^7.0.1",
"@react-creates/core": "^2.1.3",
"@types/find-cache-dir": "^3.2.1",
"@types/prompts": "^2.0.14",
"@react-creates/core": "^2.1.1",
"commander": "^9.3.0",
"commander": "^9.4.1",
"degit": "^2.8.4",
"find-cache-dir": "^3.3.2",

@@ -47,0 +47,0 @@ "prompts": "^2.4.2"

@@ -13,2 +13,3 @@ import { nodeFs } from '@file-services/node';

import { FileSystemCache } from '../file-system-cache';
import { fetchTemplate } from '../fetch-template';

@@ -29,4 +30,6 @@ export function createComponentCommand() {

.option('--fresh', 'Will not use cache')
.action((name, options) =>
createComponent(
.option('--templatesDirectory <string>', 'Target root directory for templates to be stored locally')
.action((name, options) => {
const { templatesDirectory } = options;
return createComponent(
{ name, ...options },

@@ -36,7 +39,7 @@ {

logger: console,
templateDirectory: nodeFs.join(
nodeFs.dirname(require.resolve('react-creates/package.json')),
'templates',
'component'
),
async getTemplateDirectory({ language, type }) {
const { targetTemplateDirectory } = await fetchTemplate(['component', language, type], templatesDirectory);
return targetTemplateDirectory;
},
onFinished({ name: _name, directory: _directory, ...resolvedOptions }) {

@@ -83,4 +86,4 @@ if (optionsCache && !options.fresh && !options.yes) {

}
)
);
);
});
}

@@ -87,0 +90,0 @@

@@ -13,14 +13,8 @@ import { nodeFs } from '@file-services/node';

static create({ fileSystem = nodeFs, rootDir = process.cwd() }: FileSystemCacheOptions = {}) {
return new this(fileSystem, FileSystemCache.getCachePath({ fileSystem, rootDir }));
return new this(fileSystem, fileSystem.join(FileSystemCache.getCacheRootPath({ rootDir }), 'cache.json'));
}
static getCachePath({ fileSystem = nodeFs, rootDir = process.cwd() }: FileSystemCacheOptions = {}) {
const packageJsonPath = fileSystem.findClosestFileSync(rootDir, 'package.json');
if (!packageJsonPath) {
throw new Error('Could not find package.json');
}
static getCacheRootPath({ rootDir = process.cwd() }: FileSystemCacheOptions = {}) {
const cachePathDir = findCacheDir({
name: fileSystem.join('react-creates', packageJsonPath),
name: 'react-creates',
create: true,

@@ -30,7 +24,7 @@ cwd: rootDir,

return fileSystem.join(cachePathDir, 'cache.json');
return cachePathDir;
}
static delete({ fileSystem = nodeFs, rootDir = process.cwd() }: FileSystemCacheOptions = {}) {
const cachePath = FileSystemCache.getCachePath({ fileSystem, rootDir });
const cachePath = FileSystemCache.getCacheRootPath({ rootDir });

@@ -37,0 +31,0 @@ if (fileSystem.existsSync(cachePath)) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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