npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

import-code-xml

v1.0.0

Published

CLI tool to import code files from an XML manifest with diff support, auto-skip identical files, and force-overwrite option

Downloads

108

Readme

Import Code XML

A CLI tool to import code files from an XML manifest with diff support, auto-skip identical files, and force-overwrite option. Perfect for importing generated code from AI assistants while preserving exact formatting.

Features

  • Smart diff detection: Automatically skips identical files
  • Visual diff display: Shows differences before overwriting
  • Interactive prompts: Choose to overwrite, skip, or view diff again
  • Force overwrite mode: Bypass prompts for batch operations
  • Format preservation: Maintains exact line breaks, tabs, and whitespace

Installation

Option 1: Install from local package

# Navigate to package directory
cd /path/to/import-code-xml

# Install globally
npm install -g .

Option 2: Install from npm (if published)

npm install -g import-code-xml

After installation, the import-code command will be available globally.

Usage

Basic usage with prompts:

import-code -f import_code.xml

Force overwrite all files:

import-code -f import_code.xml --force-overwrite
# or
import-code -f import_code.xml --fo

XML File Format

The XML file should follow this structure:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <item>
    <path>relative/or/absolute/path/to/file.extension</path>
    <content><![CDATA[
Your file content here
with exact formatting
including:
- Line breaks
- Tabs
- Indentation
- Special characters
]]></content>
  </item>
  
  <item>
    <path>another/file/path.js</path>
    <content><![CDATA[
function example() {
  return "Hello World";
}
]]></content>
  </item>
</root>

Important Notes:

  1. Use <![CDATA[ ... ]]> to preserve all formatting exactly
  2. Each file is defined in an <item> block
  3. <path> should be the destination file path
  4. <content> contains the exact file content

AI Assistant Prompt Template

When asking an AI chatbot (like Claude, ChatGPT, etc.) to generate code for import, use this prompt:

Please generate an XML file for code import with the following files. 
Use the exact format below with CDATA sections to preserve formatting:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <item>
    <path>[FILE_PATH_1]</path>
    <content><![CDATA[
[EXACT_FILE_CONTENT_1]
]]></content>
  </item>
  
  <item>
    <path>[FILE_PATH_2]</path>
    <content><![CDATA[
[EXACT_FILE_CONTENT_2]
]]></content>
  </item>
</root>

Replace the bracketed placeholders with:
- [FILE_PATH_X]: The path where the file should be saved
- [EXACT_FILE_CONTENT_X]: The exact code with all formatting preserved

Files to include:
1. [Describe first file and its purpose]
2. [Describe second file and its purpose]
[Add more as needed]

Example AI Prompt:

Please generate an XML file for code import with the following files. 
Use the exact format below with CDATA sections to preserve formatting:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <item>
    <path>utils/helpers.js</path>
    <content><![CDATA[
[EXACT_FILE_CONTENT_1]
]]></content>
  </item>
  
  <item>
    <path>config/settings.json</path>
    <content><![CDATA[
[EXACT_FILE_CONTENT_2]
]]></content>
  </item>
</root>

Files to include:
1. utils/helpers.js: A JavaScript utility module with helper functions
2. config/settings.json: Configuration file with default settings

Workflow Example

  1. Prepare XML: Ask AI to generate code in the XML format
  2. Save XML: Save the AI's response as import_code.xml
  3. Run import: import-code -f import_code.xml
  4. Review diffs: The tool will show differences and prompt for actions
  5. Manage conflicts: Choose to overwrite (o), skip (s), or view diff again (d)

Behavior

  • New files: Automatically created
  • Identical files: Automatically skipped with notification
  • Changed files: Shows diff and prompts for action
  • Force overwrite: All files overwritten without prompts
  • Missing directories: Automatically created

Dependencies

  • xml2js: XML parsing library

Troubleshooting

Permission denied: Ensure you have write permissions for target directories

XML parsing errors: Verify XML format and CDATA sections are properly closed

diff command not found: On Windows, install diffutils or use Git Bash/Cygwin

Global command not found: Try npm link in the package directory

License

MIT