New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vuedx/projectconfig

Package Overview
Dependencies
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuedx/projectconfig - npm Package Compare versions

Comparing version 0.7.2-insiders-1623402835.0 to 0.7.2-insiders-1630600136.0

53

lib/index.d.ts

@@ -5,8 +5,10 @@ var version = "0.7.1";

moduleName: string;
/** Use '*' for namespace imports. */
exportName?: string;
}
interface ProjectPreferences {
componentsDirectories: string[];
script: {
mode: 'setup' | 'setup-ref' | 'normal';
mode: 'setup' | 'normal';
language: 'js' | 'ts';

@@ -23,11 +25,50 @@ };

}
interface ProjectConfigNormalized {
globalComponents: Array<string | Record<string, string | ImportSource>>;
preferences: ProjectPreferences;
}
interface ProjectConfig {
globalComponents?: Array<string | Record<string, string | ImportSource>>;
globalDirectives?: Array<string | Record<string, string | ImportSource>>;
preferences?: Partial<ProjectPreferences>;
}
interface ResolvedProjectConfig {
globalComponents: Record<string, ImportSource[]>;
globalDirectives: Record<string, ImportSource[]>;
preferences: ProjectPreferences;
}
export { ImportSource, ProjectConfig, ProjectConfigNormalized, ProjectPreferences, version };
interface FileWatcher {
close(): void;
}
declare enum FileWatcherEventKind {
Created = 0,
Changed = 1,
Deleted = 2
}
declare type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void;
declare type DirectoryWatcherCallback = (fileName: string) => void;
interface FilesystemHost {
readDirectory(rootDir: string, extensions: string[]): string[];
fileExists(path: string): boolean;
readFile(path: string): string | undefined;
watchFile(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
}
declare class VueProject {
protected readonly fs: FilesystemHost;
readonly rootDir: string;
readonly packageFile: string | null;
readonly projectFile: string | null;
static create(fs: FilesystemHost, rootDir: string): VueProject;
private readonly watchers;
private constructor();
private loadDependencies;
dispose(): void;
_dependencies: Record<string, string>;
get dependencies(): Readonly<Record<string, string>>;
private _config;
get config(): Readonly<ResolvedProjectConfig>;
private setConfig;
get kind(): 'inferred' | 'configured';
}
export { FilesystemHost, ProjectConfig, ProjectPreferences, ResolvedProjectConfig, VueProject, version };

@@ -5,5 +5,214 @@ 'use strict';

const Path = require('path');
const shared = require('@vuedx/shared');
const JSON5 = require('json5');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
const Path__default = /*#__PURE__*/_interopDefaultLegacy(Path);
const JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5);
var version = "0.7.1";
const DEFAULT_PROJECT_CONFIG = {
globalComponents: {},
globalDirectives: {},
preferences: {
componentsDirectories: ['src/components'],
script: { mode: 'normal', language: 'js' },
style: { language: 'css' },
template: {
directiveSyntax: 'shorthand',
propCase: 'camel',
tagCase: 'auto',
},
},
};
function deepDefaults(a, b) {
if (b == null)
return a;
Object.keys(b).forEach((key) => {
const valueA = a[key];
const valueB = b[key];
if (valueB === undefined)
return;
if (valueA == null || Array.isArray(valueB)) {
a[key] = valueB;
}
else if (typeof valueA === 'object' && typeof valueB === 'object') {
a[key] = deepDefaults(valueA, valueB);
}
else {
a[key] = valueB;
}
});
return a;
}
var FileWatcherEventKind;
(function (FileWatcherEventKind) {
FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
})(FileWatcherEventKind || (FileWatcherEventKind = {}));
function findNearestFile(fs, dir, name) {
let cur = shared.toPosixPath(dir);
while (cur.length > 1) {
const fileName = Path__default['default'].posix.resolve(cur, name);
if (fs.fileExists(fileName))
return fileName;
cur = Path__default['default'].posix.dirname(cur);
}
return null;
}
function resolveComponents(rootDir, resources) {
const components = {};
const add = (name, source) => {
var _a;
const sources = (_a = components[name]) !== null && _a !== void 0 ? _a : (components[name] = []);
if (sources.some((item) => item.moduleName === source.moduleName &&
item.exportName === source.exportName)) {
return; // duplicate
}
sources.push(source);
};
for (const resource of resources) {
if (shared.isString(resource)) {
add(shared.getComponentName(resource), {
moduleName: resolve(resource),
});
}
else
Object.entries(resource).forEach(([key, value]) => {
add(key, shared.isString(value) ? { moduleName: resolve(value) } : value);
});
}
return components;
function resolve(resource) {
if (resource.startsWith('.'))
return Path__default['default'].posix.resolve(rootDir, resource);
else
return resource;
}
}
function resolveDirectives(rootDir, resources) {
const directives = {};
const add = (name, source) => {
var _a;
const sources = (_a = directives[name]) !== null && _a !== void 0 ? _a : (directives[name] = []);
if (sources.some((item) => item.moduleName === source.moduleName &&
item.exportName === source.exportName)) {
return; // duplicate
}
sources.push(source);
};
for (const resource of resources) {
if (shared.isString(resource)) ;
else
Object.entries(resource).forEach(([key, value]) => {
add(key, shared.isString(value) ? { moduleName: resolve(value) } : value);
});
}
return directives;
function resolve(resource) {
if (resource.startsWith('.'))
return Path__default['default'].posix.resolve(rootDir, resource);
else
return resource;
}
}
class VueProject {
constructor(fs, rootDir, packageFile = null, projectFile = null) {
this.fs = fs;
this.rootDir = rootDir;
this.packageFile = packageFile;
this.projectFile = projectFile;
this.watchers = [];
this._dependencies = {};
this._config = DEFAULT_PROJECT_CONFIG;
if (projectFile != null) {
this.watchers.push(fs.watchFile(projectFile, (fileName, event) => {
if (event === FileWatcherEventKind.Changed) {
const content = fs.readFile(fileName);
if (content != null) {
try {
this.setConfig(JSON5__default['default'].parse(content));
}
catch (error) {
// FIXME: Store error for diagnostics usage.
}
}
}
}));
}
if (packageFile != null) {
this.watchers.push(fs.watchFile(packageFile, (fileName, event) => {
if (event === FileWatcherEventKind.Changed) {
const content = fs.readFile(fileName);
if (content != null) {
try {
const pkg = JSON.parse(content);
this.loadDependencies({
...pkg.devDependencies,
...pkg.dependencies,
});
}
catch (error) {
// FIXME: Store error for diagnostics usage.
}
}
}
}));
}
}
static create(fs, rootDir) {
const projectFile = Path__default['default'].posix.resolve(rootDir, 'vueconfig.json');
const packageFile = findNearestFile(fs, rootDir, 'package.json');
return new VueProject(fs, rootDir, packageFile, fs.fileExists(projectFile) ? projectFile : null);
}
loadDependencies(dependencies) {
if (this.packageFile == null)
return;
const modulesDir = Path__default['default'].posix.resolve(Path__default['default'].posix.dirname(this.packageFile), 'node_modules');
Object.keys(dependencies).forEach((packageName) => {
const fileName = Path__default['default'].posix.resolve(modulesDir, packageName, 'package.json');
if (this.fs.fileExists(fileName)) {
this._dependencies[packageName] = JSON.parse(fileName).version;
}
});
}
dispose() {
this.watchers.forEach((watcher) => watcher.close());
this.watchers.length = 0;
}
get dependencies() {
return this._dependencies;
}
get config() {
return this._config;
}
setConfig(config) {
this._config = {
globalComponents: this._config.globalComponents,
globalDirectives: this._config.globalDirectives,
preferences: deepDefaults(this._config.preferences, config.preferences),
};
if (config.globalComponents != null) {
this._config.globalComponents = resolveComponents(this.rootDir, config.globalComponents);
}
if (config.globalDirectives != null) {
this._config.globalDirectives = resolveDirectives(this.rootDir, config.globalDirectives);
}
}
get kind() {
return this.projectFile == null ? 'inferred' : 'configured';
}
}
exports.VueProject = VueProject;
exports.version = version;
//# sourceMappingURL=index.js.map

8

package.json
{
"name": "@vuedx/projectconfig",
"version": "0.7.2-insiders-1623402835.0",
"version": "0.7.2-insiders-1630600136.0",
"description": "TypeScript plugin for Vue",

@@ -34,3 +34,7 @@ "main": "lib/index.js",

},
"homepage": "https://github.com/znck/vue-developer-experience#readme"
"homepage": "https://github.com/znck/vue-developer-experience#readme",
"dependencies": {
"@vuedx/shared": "0.7.4-insiders-1630600136.0",
"json5": "^2.2.0"
}
}

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