@akii09/pdfx-cli 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4148,7 +4148,9 @@ var configSchema = external_exports.object({
|
|
|
4148
4148
|
registry: external_exports.string().url("registry must be a valid URL"),
|
|
4149
4149
|
theme: external_exports.string().min(1).optional(),
|
|
4150
4150
|
/** Directory where templates are installed. Defaults to ./src/templates/pdfx */
|
|
4151
|
-
templateDir: external_exports.string().min(1).optional()
|
|
4151
|
+
templateDir: external_exports.string().min(1).optional(),
|
|
4152
|
+
/** Directory where blocks are installed. Defaults to ./src/blocks/pdfx */
|
|
4153
|
+
blockDir: external_exports.string().min(1).optional()
|
|
4152
4154
|
});
|
|
4153
4155
|
var registryFileTypes = [
|
|
4154
4156
|
"registry:component",
|
|
@@ -5102,7 +5104,8 @@ var DEFAULTS = {
|
|
|
5102
5104
|
SCHEMA_URL: "https://pdfx.akashpise.dev/schema.json",
|
|
5103
5105
|
COMPONENT_DIR: "./src/components/pdfx",
|
|
5104
5106
|
THEME_FILE: "./src/lib/pdfx-theme.ts",
|
|
5105
|
-
TEMPLATE_DIR: "./src/templates/pdfx"
|
|
5107
|
+
TEMPLATE_DIR: "./src/templates/pdfx",
|
|
5108
|
+
BLOCK_DIR: "./src/blocks/pdfx"
|
|
5106
5109
|
};
|
|
5107
5110
|
var REGISTRY_SUBPATHS = {
|
|
5108
5111
|
TEMPLATES: "templates"
|
|
@@ -5183,7 +5186,7 @@ async function fetchComponent2(name, registryUrl) {
|
|
|
5183
5186
|
}
|
|
5184
5187
|
function resolveBlockImports(content, blockName, config) {
|
|
5185
5188
|
const cwd = process.cwd();
|
|
5186
|
-
const blockSubdir = path4.resolve(cwd, config.
|
|
5189
|
+
const blockSubdir = path4.resolve(cwd, config.blockDir ?? DEFAULTS.BLOCK_DIR, blockName);
|
|
5187
5190
|
let result = content.replace(
|
|
5188
5191
|
/from '\.\.\/\.\.\/components\/pdfx\/([a-z][a-z0-9-]*)\/pdfx-([a-z][a-z0-9-]*)'/g,
|
|
5189
5192
|
(_match, componentName) => {
|
|
@@ -5280,7 +5283,7 @@ async function ensurePeerComponents(block, config, force) {
|
|
|
5280
5283
|
async function installBlock(name, config, force) {
|
|
5281
5284
|
const block = await fetchBlock(name, config.registry);
|
|
5282
5285
|
const peerResult = await ensurePeerComponents(block, config, force);
|
|
5283
|
-
const blockBaseDir = path4.resolve(process.cwd(), config.
|
|
5286
|
+
const blockBaseDir = path4.resolve(process.cwd(), config.blockDir ?? DEFAULTS.BLOCK_DIR);
|
|
5284
5287
|
const blockDir = path4.join(blockBaseDir, block.name);
|
|
5285
5288
|
ensureDir(blockDir);
|
|
5286
5289
|
const filesToWrite = [];
|
|
@@ -5412,7 +5415,7 @@ async function blockAdd(names, options = {}) {
|
|
|
5412
5415
|
console.log(chalk2.yellow(`Failed: ${failed.join(", ")}`));
|
|
5413
5416
|
}
|
|
5414
5417
|
if (failed.length < names.length) {
|
|
5415
|
-
const resolvedDir = path4.resolve(process.cwd(), config.
|
|
5418
|
+
const resolvedDir = path4.resolve(process.cwd(), config.blockDir ?? DEFAULTS.BLOCK_DIR);
|
|
5416
5419
|
console.log(chalk2.green("Done!"));
|
|
5417
5420
|
console.log(chalk2.dim(`Blocks installed to: ${resolvedDir}
|
|
5418
5421
|
`));
|
|
@@ -5462,7 +5465,7 @@ async function blockList() {
|
|
|
5462
5465
|
console.log(chalk2.dim("\n No blocks available in the registry.\n"));
|
|
5463
5466
|
return;
|
|
5464
5467
|
}
|
|
5465
|
-
const blockBaseDir = path4.resolve(process.cwd(), config.
|
|
5468
|
+
const blockBaseDir = path4.resolve(process.cwd(), config.blockDir ?? DEFAULTS.BLOCK_DIR);
|
|
5466
5469
|
console.log(chalk2.bold(`
|
|
5467
5470
|
Available Blocks (${blocks.length})
|
|
5468
5471
|
`));
|
|
@@ -5891,6 +5894,24 @@ async function init() {
|
|
|
5891
5894
|
return true;
|
|
5892
5895
|
}
|
|
5893
5896
|
},
|
|
5897
|
+
{
|
|
5898
|
+
type: "text",
|
|
5899
|
+
name: "blockDir",
|
|
5900
|
+
message: "Where should we install blocks?",
|
|
5901
|
+
initial: DEFAULTS.BLOCK_DIR,
|
|
5902
|
+
validate: (value) => {
|
|
5903
|
+
if (!value || value.trim().length === 0) {
|
|
5904
|
+
return "Block directory is required";
|
|
5905
|
+
}
|
|
5906
|
+
if (path8.isAbsolute(value)) {
|
|
5907
|
+
return "Please use a relative path (e.g., ./src/blocks/pdfx)";
|
|
5908
|
+
}
|
|
5909
|
+
if (!value.startsWith(".")) {
|
|
5910
|
+
return "Path should start with ./ or ../ (e.g., ./src/blocks/pdfx)";
|
|
5911
|
+
}
|
|
5912
|
+
return true;
|
|
5913
|
+
}
|
|
5914
|
+
},
|
|
5894
5915
|
{
|
|
5895
5916
|
type: "text",
|
|
5896
5917
|
name: "registry",
|
|
@@ -5960,7 +5981,8 @@ async function init() {
|
|
|
5960
5981
|
$schema: DEFAULTS.SCHEMA_URL,
|
|
5961
5982
|
componentDir: answers.componentDir,
|
|
5962
5983
|
registry: answers.registry,
|
|
5963
|
-
theme: answers.themePath || DEFAULTS.THEME_FILE
|
|
5984
|
+
theme: answers.themePath || DEFAULTS.THEME_FILE,
|
|
5985
|
+
blockDir: answers.blockDir || DEFAULTS.BLOCK_DIR
|
|
5964
5986
|
};
|
|
5965
5987
|
const validation = configSchema.safeParse(config);
|
|
5966
5988
|
if (!validation.success) {
|
|
@@ -5983,8 +6005,10 @@ async function init() {
|
|
|
5983
6005
|
spinner.succeed(`Created pdfx.json + ${config.theme} (${presetName} theme)`);
|
|
5984
6006
|
console.log(chalk6.green("\nSuccess! You can now run:"));
|
|
5985
6007
|
console.log(chalk6.cyan(" pdfx add heading"));
|
|
6008
|
+
console.log(chalk6.cyan(" pdfx block add invoice-classic"));
|
|
5986
6009
|
console.log(chalk6.dim(`
|
|
5987
6010
|
Components: ${path8.resolve(process.cwd(), answers.componentDir)}`));
|
|
6011
|
+
console.log(chalk6.dim(` Blocks: ${path8.resolve(process.cwd(), config.blockDir)}`));
|
|
5988
6012
|
console.log(chalk6.dim(` Theme: ${path8.resolve(process.cwd(), config.theme)}
|
|
5989
6013
|
`));
|
|
5990
6014
|
} catch (error) {
|