Giter Club home page Giter Club logo

ctix's Introduction

ctix - Next generation Create TypeScript barrel

ts Download Status Github Star Github Issues NPM version License ci codecov code style: prettier

entrypoint barrel file automatically generated cli tool

Why ctix?

Have you ever developed a library project in the TypeScript language? Unlike API servers or desktop applications, library projects do not have executable scripts or functions. Therefore, it is common to organize a number of functions and variables to be included in the library in an barrel file. However, it is inconvenient to rewrite the barrel file every time you add a function or variable, and it is easy to make a mistake and miss a function or variable you intended. ctix uses the TypeScript compiler API to automatically generate the barrel file by searching your TypeScript project for functions and variables with the export keyword added.

To summarize,

  1. automatically extracts statement with the export keyword applied
  2. generate a single barrel file or directory-specific barrel files
  3. automatically generate configuration files via interactive prompts
  4. automatically add type keyword to interface, type aliases to indicate they are pure types
    • eg. export { type IAmSuperHero } from './marvel';
  5. can be set to exception files via comments in source code files (eslint style)
  6. always generates a compilable barrel file because it uses the TypeScript compiler API

In addition, ctix will auto-generate barrel files so that a single index.d.ts file can be generated correctly when using the rollup-plugin-dts plugin. Now you can develop your TypeScript library projects more easily!

Table of Contents

Getting Starts

npm install ctix --save-dev
npx ctix init
npx ctix build

ctix provides interactive prompts to help you create the configuration file. Execute the ctix init command to create a configuration file.

How it works?

The graph below outlines the behavioral flow of ctix.

flowchart LR
    START(start) --> |execute cli|ctix
    ctix --> |TypeScript Compiler API| INP01[Source Code files]
    ctix --> |TypeScript Compiler API| INP02["tsconfig.json"]
    ctix --> |json, json5, yaml| INP03[".ctirc"]
    INP01 --> TF[/Summray target source files/]
    INP02 --> TF
    INP03 --> TF
    TF --> TS[/Summray target export statements/]
    TS --> IW["index.ts file generation"]
    IW --> END(end)
Loading

Because ctix uses the TypeScript Compiler API to summary target files and extract export statements, developers don't need to write source code in a special format or make any changes to existing code to make it work.

Barrel file

A barrel is a way to rollup exports from several modules into a single convenient module. The barrel itself is a module file that re-exports selected exports of other modules.

Installation

npm install ctix --save-dev

Usage

# bundle mode
ctix build --mode bundle -p ./tsconfig.json -o ./src

# create mode
ctix build --mode create -p ./tsconfig.json --start-from ./src

# module mode
ctix build --mode module -p ./tsconfig.json -o ./src/components

The mode in which the barrel file is to be generated. There is a create mode that generates an barrel file per directory, a bundle mode that generates a single barrel file, and a module mode that generates an barrel file by filename for vue, sevelte, etc.

bundle mode create mode module mode
bundle mode create mode module mode

Check out the .ctirc in examples/type10 to see how to utilize the module mode.

Saving Configuration

You can save frequently used configurations. ctix supports saving settings in package.json, tsconfig.json, or a .ctirc file. You can easily create a basic configuration using the ctix init command.

# generate base configuration
ctix init

include & exclude file

ctix needs a list of files to generate the index.ts file. You can provide this list using the --include option, which supports glob patterns. If you don't use the --include option, ctix will use the include setting from the .ctirc file. If neither the --include option nor the .ctirc file is provided, ctix will fall back to the include field in the tsconfig.json file.

How can I include wanted files?

ctix gets a glob pattern to generate the index.ts file. The glob pattern is obtained from various configuration files such as:

  1. Glob pattern from cli argument --include
  2. Glob patterns from the include field in the .ctirc configuration file
  3. Glob patterns from the include field in the tsconfig.json configuration file

If your index.ts file is empty or a warning is displayed, please check the above configuration.

How can I exclude unwanted files?

There are two ways to do this. The first is to create a .ctirc file and set the include or exclude value, which works similarly to the include and exclude values in the tsconfig.json file. The second is to comment out @ctix-exclude at the top of the files you want to exclude, such as eslint.

.ctirc

{
  "options": {
    "mode": "bundle",
    "exclude": ["**/*.storybook.tsx"]
  }
}

If you want to use a .ctirc file, I recommend creating one with the npx ctix init command.

eslint style inline comment

You can add configurations using eslint-style inline comments.

@ctix-exclude

If you want to include an entire directory but exclude certain files, instead of writing a complex glob pattern, you can simply use inline comments to exclude the specific files.

/** @ctix-exclude */

const Button = () => {
  return <button>Sample</button>;
};

@ctix-exclude-next

When exporting multiple classes and functions, you can exclude one or two of them if needed.

const Button = () => {};

const GroupButton = () => {};

// @ctix-exclude-next
const UnwantedButton = () => {};

const Checkbox = () => {};

@ctix-generation-style

/** @ctix-generation-style default-alias-named-destructive */
const Button = () => {};

const GroupButton = () => {};

// @ctix-exclude-next
const UnwantedButton = () => {};

const Checkbox = () => {};

The export syntax in the index.ts file is determined by the chosen generation style. For more details, refer to the More about Generation Style documentation.

@ctix-declaration

When ctix generates the index.ts file, it uses prettier and prettier-plugin-organize-imports to check if the files to be exported are used. During this process, files that only contain declare module are excluded. This can cause issues if you intend to bundle type files. However, if you add @ctix-declaration to the file, it will be included in the index.ts file. Keep in mind that @ctix-declaration is applied after the exclude option, so make sure the file is not included in the exclude option.

/** @ctix-declaration */

declare module '*.vue' {
  import Vue from 'vue';
  export default Vue;
}

Programming interface

When using task runners like Gulp and Just, as well as bundlers like webpack and rollup, you need a programming interface to add ctix.

function option descryption
building TCommandBuildOptions Execute the build command
initializing TCommandInitOptions Execute the init command
removing TCommandRemoveOptions, TCommandBuildOptions Execute the remove command

Check out the example code.

Requirement

  • Node.js 18
  • TypeScript

Important

ctix does not work in JavaScript code because it uses TypeScript API, please use it before Babel translation or TypeScript compilation.

Generation Style

The handling of the default export is an important issue, but many bundlers and type bundlers handle the default export differently, so ctix provides many ways to create a default export.

You can change the generation style of the entire project by setting the generation-style option, or you can change the generation style of only certain files by adding the @ctix-generation-style inline comment at the top of the file.

More information

Examples

In the examples directory, you can find cases where ctix has been applied to various projects. For detailed explanations, please refer to the Examples README.md file.

Directory Name Purpose
type03 When there are duplicate names in the entire project
type05 For React projects
type06 When using TypeScript enums
type07 When using destructive operations on variables for named exports
type09 When using TTF fonts by declaring them as modules and using them in TypeScript
type10 For Vue.js projects
type11 When using Component Props in React projects

What is difference Re-Map paths?

It is not recommended to use index.ts file to re-map paths or shorten the paths. If you want to shorten the paths use Re-Map paths feature in TypeScript compilerOptions. ctix is recommended for webpack and rollup.js, typedoc entrypoint and TypeScript declaration file bundling.

Option

License

This software is licensed under the MIT.

References

ctix's People

Contributors

cliarena avatar dankeboy36 avatar imjuni avatar insidewhy avatar stringke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ctix's Issues

Support import file

Now only the export statement will be generated, but the project may have many polyfills files. At this time, you may need to generate a polyfills.ts as the entry file, with the following content:

import "@base/boost/js/polyfills/at.js";
import "@base/boost/js/polyfills/cause.js";
import "@base/boost/js/polyfills/disposable.js";
import "@base/boost/js/polyfills/has-own.js";
import "@base/boost/js/polyfills/metadata.js";
import "@base/boost/js/polyfills/queue-microtask.js";
import "@base/boost/js/polyfills/text-encoder-decoder.js";
import "@base/boost/js/polyfills/with-resolvers.js";
import "@base/macro/polyfills.js";

Currently, this kind of bucket file can only be maintained manually.

It would be great if you could add a comment at the top of a file, such as /** @ctix-import */, which would also add an import statement to the file.

// @base/boost/js/polyfills/at.js
/** @ctix-import */

......

And I hope to add a switch in the configuration to be more flexible when there are multiple configuration files in the same project.

Great work!

Re-exporting a type should consider about 'isolatedModules' flag

Current Behaviour

Current version of ctix will re-export a default exported type using this schema:

//in T.ts
type T = string;
export default T;
//in index.ts generated by ctix
export { default as T} from './T';

which will encounter following compile error when '--isolatedModules' flag is set:

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

Motivation

Since '--isolatedModules' flag is required by powerful typescript compilers (esbuild for example), it will be great to consider about 'isolatedModules'.

Reference

Typescript Handbook

"No parser and no filepath given"

.ctirc:

{
  "project": "./tsconfig.json",
  "exportFilename": "index.ts",
  "useSemicolon": false,
  "useTimestamp": false,
  "useComment": false,
  "quote": "'",
  "overwrite": true,
  "keepFileExt": false,
  "skipEmptyDir": true,
  "output": "./",
  "useRootDir": false,
  "includeBackup": false
}

Command:
npx ctix create

Output:
No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.

ctix not creating root index.ts

I have a project with different folders under "src"
ctix create successfully creates the index.ts file for all folders
except for the index.ts of the root "src" folder that should export all of the other files.
running ctix single seems to work fine and it creates the index.ts file

on another project i had to put a dummy file with export {} in the "src" folder which then caused ctix to create the index file correctly, but for this project it doesnt help

Incorrect warning about name collisions

In my StackNetwork.ts, I have this code:

interface Options {
    stackName: string;
    config: NetworkConfig;
}
export { Options as StackNetworkOptions };

In my StackService.ts, I have this code:

interface Options {
    stackName: string;
    config: ServiceConfig;
}

export { Options as StackServiceOptions };

But I still get these warnings:

   WARN     StackNetwork.ts:6:1
   > P:/modular/infrastructure-services/src/constructs/docker-stack/StackNetwork.ts:6:1
   > detect same name of export statement: "Options"

   WARN     StackService.ts:7:1
   > P:/modular/infrastructure-services/src/constructs/docker-stack/StackService.ts:7:1
   > detect same name of export statement: "Options"

Error with destructured exports

When I have the following export:

export const {
  setCodeGenerationModalIsOpen,
  updateCodeRules,
  disableDecimalPointReplacementInKeys,
  enableDecimalPointReplacementInKeys,
  setSelectedPresetName,
  resetPresetSelection,
} = codeGenerationSlice.actions;

I get the following error:

 ERROR  Cannot support type: (203) setCodeGenerationModalIsOpen                                                                                          17:18:06

  at getExportedName (node_modules/ctix/dist/ctix.js:527:11)
  at node_modules/ctix/dist/ctix.js:397:60
  at Array.map (<anonymous>)
  at getExportInfo (node_modules/ctix/dist/ctix.js:394:10)
  at node_modules/ctix/dist/ctix.js:444:103
  at Array.map (<anonymous>)
  at getExportInfos (node_modules/ctix/dist/ctix.js:444:55)
  at createWritor (node_modules/ctix/dist/ctix.js:1094:69)
  at Object.handler (node_modules/ctix/dist/ctix.js:3160:13)

The error goes away if I replace the destructured exports, eg;
export const setCodeGenerationModalIsOpen = codeGenerationSlice.actions.setCodeGenerationModalIsOpen

This also did not work

const {setCodeGenerationModalIsOpen} =  codeGenerationSlice.actions;
export setCodeGenerationModalIsOpen;

Ignoring exports based on glob pattern

Overview

Big fan of this library, it's made it so much easier to generate type definitions for my package! Just having some teething issues...

I am trying to limit which exports can come out of a file based on export name glob matching, but all the exports are still being generated.

I don't want to write each entry out because my end goal is to ignore any exports down the file structure matching the pattern, as they're generated files with a similar structure.

Example

With this configuration
.ctignore

{
  "src/protobufs/*": [
    "*ToJSON",
    "*FromJSON"
  ]
}

.ctirc

{
  // common configuration
  // tsconfig.json path: must be specified a path qualifier, such as "./tsconfig.json".
  // Relative to `package.json` directory of the package being built.
  "project": "./tsconfig.json",
  // Export filename: if blank uses "index.ts" or "index.d.ts"
  "exportFilename": "index.ts",
  // [create, single] command configuration
  // Whether to end lines with semicolons
  "useSemicolon": true,
  // Whether to append a timestamp to the right of the ctix comment
  // Only works if the 'useComment' option is set to 'true'
  "useTimestamp": false,
  // Whether to add a comment at first line of created index.ts file informing that it's generated by ctix
  "useComment": false,
  // Symbol to use for quoting strings (quotation mark " or ')
  "quote": "'",
  // Whether to overwrite the exported file (creates a backup)
  "overwrite": true,
  // Whether to remove the backup generated when 'overwrite' is enabled
  "noBackup": true,
  // Whether to retain the file extension specified in the export path
  "keepFileExt": false,
  // [create] command configuration
  // Whether to skip generating index files for empty directories
  "skipEmptyDir": true,
  // [single] command configuration
  // Directory to output the generated index file into
  "output": "./src/",
  // Whether to respect the rootDir or rootDirs configuration in tsconfig.json.
  "useRootDir": false,
  // [remove] command configuration
  // Whether to remove any backup file(s) alongside the generated index file(s)
  "includeBackup": false
}

Using the command

ctix single -c .ctirc

Given the following file, I would presume that the *Model would still be exported, but the *ToJSON and *FromJSON would not be.

src/protobufs/thing/thing_model.ts

export enum ThingModel {
  THING_0 = 0,
  THING_1 = 1
}

export function thingModelFromJSON(object: any): ThingModel {
  // <simplified for brevity>
  return 0;
}

export function thingModelToJSON(object: ThingModel): string {
  // <simplified for brevity>
  return "";
}

However, the resultant type still contains everything.

export { thingModelFromJSON, thingModelToJSON, ThingModel } from './protobufs/thing/thing_model';

If I don't use glob pattern matching, it works, but I have a number of *ToJSON etc exports which I want to exclude down the file structure

Why is this important?

  1. There is * pattern matching already, but there doesn't seem to be support for partial glob patterns *Thing etc which is a logical expectation.
  2. Users of the library may have huge codebases which it would be impractical to maintain the list of ignored files for, without this change.

ctix-exclude-next is not working.

in file ./base/boost/cloneable/interface.ts:

/** @ctix-exclude-next */
export interface Cloneable<T = unknown> {
    /**
     * 克隆一个新对象并返回
     */
    [clone](host?: ICloneHost): T;
}

export interface ICloneHost {
    /**
     * 传入原始对象,返回克隆后的对象
     */
    getCache<T extends object>(original: T): T | undefined;

    /**
     * 缓存传入的克隆对象
     */
    setCache<T extends object>(original: T, cloned: T): T;
}

output:

export * from "./base/boost/cloneable/interface.js";

expect:

export { ICloneHost } from "./base/boost/cloneable/interface.js";

demo:
js-core_poly_.zip

version:
v2.4.0

Duplicate enum export not detected

Hi, I've got a project where two files define and export the same enum:

export enum MyEnum {
        Zero = 0,
	Half = 0.5,
	One = 1,
}

This case does not seem to be handled and we end up exporting twice from the generated index.ts:

export * from './mydir/enumhere';
export * from './mydir/andenumhere';

And we end up with:

Module '/mydir/enumhere' has already exported a member named 'MyEnum'. Consider explicitly re-exporting to resolve the ambiguity.ts(2308)

Support ts 5.5 tsconfig.json with ${configDir}

Hello! Recently, ts 5.5 was announced in beta with new feature https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#the-configdir-template-variable-for-configuration-files
This lets us share tsconfig across packages, and I wanted to use it for my monorepo, but ctix cannot find the files properly, my guess is that it's still using an older version of typescript, I'm not sure if it's this package? or from the ts-morph package where it wraps the ts compiler API, I can think of perhaps 2 ways to solve it here:

Have a "next" branch that ups the deps to the beta version as well and simply just publish it as an alpha/beta
Have the typescript dep as a peerDep? and have userland install the required version? I'm not sure if that actually works, just a thought
For reference I used with typescript ver: "5.5.0-dev.20240518",
and shared configuration package I'm trying to create: https://github.com/Esposter/Esposter/tree/shared-configuration/packages/configuration
usage: https://github.com/Esposter/Esposter/blob/shared-configuration/packages/shared/package.json

NextJS use client directive feature & duplicate FirstLineComment fix

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

In order to circumvent this issue with NextJS vercel/next.js#41940 I had to include the 'use client' directive into multiple index files, so I've leveraged your project to do that via CLI.

Along the way I've also fixed the duplicated output of comment/timestamp in the indexFileWrite function. The firstLine is included in prettierApplied so there is no need to redo that when prettierApplied gets used.

I did not check against other configurations and consider this a quick working draft that helps me moving forward to other more pressing issues 🙂 I might be able to improve this solution at another time.

Here is the diff that solved my problem:

diff --git a/node_modules/ctix/dist/cli.js b/node_modules/ctix/dist/cli.js
index 85f381f..7c255e2 100755
--- a/node_modules/ctix/dist/cli.js
+++ b/node_modules/ctix/dist/cli.js
@@ -152,6 +152,12 @@ function createSingleBuilder(args) {
         describe: 'add ctix comment at first line of creted index.ts file, that remark created from ctix',
         type: 'boolean',
         default: false,
+    })
+        .option('useNextJsClientDirective', {
+        alias: 'd',
+        describe: 'add \'use client\' directive as first line into created index.ts files',
+        type: 'boolean',
+        default: false,
     })
         .option('quote', {
         alias: 'q',
@@ -219,6 +225,11 @@ function initBuilder(args) {
         describe: 'add ctix comment at first line of creted index.ts file, that remark created from ctix',
         type: 'boolean',
         default: false,
+    })
+        .option('useNextJsClientDirective', {
+        describe: 'add \'use client\' directive as first line into created index.ts files',
+        type: 'boolean',
+        default: false,
     })
         .option('quote', {
         describe: 'change quote character at export syntax',
@@ -1091,6 +1102,9 @@ const initialConfigLiteral = `{
   // add ctix comment at first line of creted index.ts file, that remark created from ctix
   "useComment": false,
 
+  // add 'use client' directive as first line into created index.ts files
+  "useNextJsClientDirective": false,
+
   // quote mark " or '
   "quote": "'",
   // overwrite index.ts file also index.ts file already exist that create backup file
@@ -1958,14 +1972,15 @@ async function prettierApply(project, contents) {
 
 function getFirstLineComment(option) {
     const today = dayjs__default["default"]();
+    const useClient = option.useNextJsClientDirective ? `'use client';\n\r` : '';
     if (option.useComment && option.useTimestamp) {
-        return `// created from ctix ${today.format('YYYY-MM-DD HH:mm:ss')}${option.eol}${option.eol}`;
+        return `${useClient}// created from ctix ${today.format('YYYY-MM-DD HH:mm:ss')}${option.eol}${option.eol}`;
     }
     if (option.useComment) {
-        return `// created from ctix${option.eol}${option.eol}`;
+        return `${useClient}// created from ctix${option.eol}${option.eol}`;
     }
     if (option.useTimestamp) {
-        return `// ${today.format('YYYY-MM-DD HH:mm:ss')}${option.eol}${option.eol}`;
+        return `${useClient}// ${today.format('YYYY-MM-DD HH:mm:ss')}${option.eol}${option.eol}`;
     }
     return '';
 }
@@ -1979,11 +1994,11 @@ async function indexFileWrite(indexInfos, option) {
             if ((await myNodeFp.exists(indexFilePath)) && option.noBackup === false) {
                 await fs__default["default"].promises.writeFile(`${indexFilePath}.bak`, await fs__default["default"].promises.readFile(indexFilePath));
             }
-            await fs__default["default"].promises.writeFile(indexFilePath, `${`${firstLine}${prettierApplied.contents}`.trim()}${option.eol}`);
+            await fs__default["default"].promises.writeFile(indexFilePath, `${`${prettierApplied.contents}`.trim()}${option.eol}`);
             return undefined;
         }
         if ((await myNodeFp.exists(indexFilePath)) === false) {
-            await fs__default["default"].promises.writeFile(indexFilePath, `${`${firstLine}${prettierApplied.contents}`.trim()}${option.eol}`);
+            await fs__default["default"].promises.writeFile(indexFilePath, `${`${prettierApplied.contents}`.trim()}${option.eol}`);
             return undefined;
         }
         const reason = {
@@ -2160,6 +2175,9 @@ async function createInitFile(option, isMessageDisplay) {
         if (option.useComment != null) {
             modifiedInitialConfig = jsoncParser.applyEdits(modifiedInitialConfig, jsoncParser.modify(modifiedInitialConfig, ['useComment'], option.useComment, options));
         }
+        if (option.useNextJsClientDirective != null) {
+          modifiedInitialConfig = jsoncParser.applyEdits(modifiedInitialConfig, jsoncParser.modify(modifiedInitialConfig, ['useNextJsClientDirective'], option.useNextJsClientDirective, options));
+        }
         if (option.quote != null) {
             modifiedInitialConfig = jsoncParser.applyEdits(modifiedInitialConfig, jsoncParser.modify(modifiedInitialConfig, ['quote'], option.quote, options));
         }

This issue body was partially generated by patch-package.

Inline ignore for files

Our use-case is a large lerna mono-repo with a number of packages each generating nested index files. Although ctix already provides .ctixignore, it would be extremely handy if we could indicate at the top of a file to ignore exporting it in the generated index:

/* ctix ignore */

There may be a use-case for being able to embed this at the export level (if you have files with multiple exports and some should be in the index and others shouldn't), but I think a simple one-off directive at the top of a file is probably "good enough". Curious what the feasibility of a feature like this is, and if the use-case seems broad enough to support it.

@ctix-declaration is too strict.

singleton-check.ts

/** @ctix-declaration */
/* eslint-disable no-var -- global neeed this. */
import { VERSION } from "internal/constants";
import { internal } from "./internal.js";

if (globalThis["XENON_INSTANCE_VERSION"] !== undefined) {
    internal.log.warn(
        "ATTENTION!!!",
        "There may currently be multiple versions of the module.",
        "Version A:",
        VERSION,
        "Version B:",
        globalThis["XENON_INSTANCE_VERSION"],
    );
} else {
    globalThis["XENON_INSTANCE_VERSION"] = VERSION;
}

declare global {
    var XENON_INSTANCE_VERSION: string | undefined;
}

I used the above file to check for multiple module instances, which requires an import statement in 'index.ts', but that would be excluded.

It is expected that files with '@ctix-declaration' will simply generate an 'import' statement in all cases.

ctix single should output to `rootDir` when it exists rather than root of project

When my tsconfig.json has rootDir: "src", then ctix single -p tsconfig.json should output the index.ts as src/index.ts (with imports relative to src) rather than next to tsconfig.json. Using yarn ctix single -p tsconfig.json -f src/index.ts doesn't help because the imports in src/index.ts are still relative to the root directory rather than src.

Does startFrom have to be an absolute path?

I need to automatically create index.ts under the root of monorepo for the libs I create

repo: https://github.com/StringKe/ctix-monorepo-repo

{
  "spinnerStream": "stdout",
  "progressStream": "stdout",
  "reasonerStream": "stderr",
  "options": [
    {
      "mode": "create",
      "project": "./libs/canvas/tsconfig.json",
      "exportFilename": "index.ts",
      "useSemicolon": true,
      "useBanner": true,
      "useTimestamp": true,
      "quote": "'",
      "directive": "",
      "fileExt": "none",
      "overwrite": true,
      "backup": false,
      "generationStyle": "auto",
      "include": [
        "src/**/*.ts"
      ],
      "exclude": [
        "../../node_modules",
        "../../tmp"
      ],
      "skipEmptyDir": true,
      "startFrom": "./libs/canvas",
      "output": "./libs/canvas/src",
      "removeBackup": true,
      "forceYes": true
    }
  ]
}

--ignoreFile option not working

I'm using the following command because I need to generate two indexes, one for browsers and one for node:

gen-commonjs-index": "ctix single -w -p tsconfig.json -o . --ignoreFile .ctiignore-commonjs -f commonjs-index.ts

But it's still using .ctiignore as the ignore file.

Parameters are overwritten

I use cli command:
npx ctix create --project="./tsconfig.json" --useBackupFile=false --quote='"'

And params always don't take effect.Then i find getMergedConfig() parentOptions be overwrite.Here are logs

optionObject
{"dir":"D:\Ts\libs","exists":false,"depth":1}

parentOptions
{"addNewline":true,"useSemicolon":true,"useTimestamp":false,"useComment":true,"exportFilename":"index.ts","quote":""","verbose":false,"useBackupFile":false,"output":"D:\Ts\tsconfig.json","useRoot
Dir":false,"excludePath":false,"useUpperFirst":true,"project":"./tsconfig.json"}

newOptionObject
{"dir":"D:\Ts\libs","exists":false,"depth":1,"option":{"addNewline":true,"useSemicolon":true,"useTimestamp":false,"useComment":true,"exportFilename":"index.ts","quote":"'","verbose":false,"useBack
upFile":true,"output":"./tsconfig.json","useRootDir":false,"excludePath":false,"useUpperFirst":true,"project":"./tsconfig.json"}}

toLocaleString breaks code

When I have a function named:

export const toLocaleString = (date: Date | number) => new Date(date).toLocaleString()

I receive the following output:

> ctix create -p ./tsconfig.json

  start validation
[23-10-04 16:22:07] error: (next[exportedName.identifier] ?? []) is not iterable
[23-10-04 16:22:07] error: TypeError: (next[exportedName.identifier] ?? []) is not iterable

Folders with '.' in names are not being resolved correctly

When running ctix create and a folder named foo.bar is encountered, the corresponding index.ts file is trying to import the module with import * from "foo" .

A very barebones reproduction repository:
https://github.com/Vulthil/RepoForCtix

I've included the generated index.ts files in the source tree.
The index.ts file in the src folder is trying to import a module from "./foo" even though the module is called foo.bar.

`getIsIsolatedModules` calculation depends on the order of the exported declarations

Thank you for the great lib!

I noticed that the isIsolatedModules evaluation depends on the order of the export declarations. I am using partial ignores.

Setup:

./src/Foo.ts:

export const Foo = { foo: 'foo' } as const;
export type Foo = typeof Foo;

export interface Ignore {}

./src/Bar.ts:

export type Bar = typeof Bar;
export const Bar = { bar: 'bar' } as const;

export interface Ignore {}

.ctiignore:

{
    "**/*.ts": [
        "Ignore"
    ]
}

Generated ./src/index.ts:

export { type Bar } from './bar';
export { Foo } from './foo';

Expected output ./src/index.ts:

export { Bar } from './bar';
export { Foo } from './foo';

I see that the following ExportedDeclarations is evaluated as TypeAliasDeclaration, so it's considered an isolated module and gets the type export.

'export type Bar = typeof Bar;'

if (isNotEmpty(exportedDeclarationNode.asKind(tsm.SyntaxKind.TypeAliasDeclaration))) {
return true;
}

The following ExportedDeclarations is a VariableDeclaration. Hence it evaluates to false and type is not generated for the export.

' Foo = { foo: 'foo' } as const'

if (isNotEmpty(exportedDeclarationNode.asKind(tsm.SyntaxKind.VariableDeclaration))) {
return false;
}

It would be great if the export could be deterministic and consider the same names in the scope. I am generating the code and have no control over the order.

I am happy to create a repo if needed. Thank you!

Output streams are misused

There are 2 separate issues:

  1. ora is used to output progress info text to the console but writes to stderr by default. This should be configured to write to stdout instead.
  2. Validation functions (e.g. validateExportDuplication.ts) write to stdout and don't propagate errors to the top-level process. As a result, CI builds won't properly terminate due to validation errors. The validation should be configured to write to stderr instead.

ctix fails when source file contains two exports to the same wildcard module declaration

Take this code which is typical for a project built with webpack:

/// <reference path="./DeclareTtfModule.d.ts" />
import RobotoBold from "./fonts/Roboto-Bold.ttf";
import Roboto from "./fonts/Roboto-Regular.ttf";

export { RobotoBold, Roboto };

and where DeclareTtfModule.d.ts looks like:

declare module "*.ttf";

Trying to compile a project like this exits with a non-zero status code and with the same error reported identically four times against the final line:

> detect same name of export statement: ""*.ttf""

Changing the final line so it only exports a single symbol works fine:

/// <reference path="./DeclareTtfModule.d.ts" />
import RobotoBold from "./fonts/Roboto-Bold.ttf";
import Roboto from "./fonts/Roboto-Regular.ttf";

export { RobotoBold }

Fixed this issue in #64

[Feature] Option to change default exports aliasing

I needed my default exported modules to be exported with their original file name, instead an alias with the full file path.

// instead original ctix:
export { default as srcPathToMyModule } from './src/path/to/MyModule';

// changes to:
export { default as MyModule } from './src/path/to/MyModule';

I made a quick fork and adapted it for me in ggondim/ctix.

Please consider adding an option to export defaults as their original file name or some alias formatting option.

Support specifying file extension

Hi,

First of all, thank you for the library. I'm in the process of migrating a project to ESM which requires a .js extension (see here) even in typescript. Is there a way to specify that the file extension should be compiled from .ts to .tsx and from .tsx to .jsx.

I see that there is a fileExt option in config but it is pretty limited in what it allows.

Thank you.

Index creation not working for vue-files

I am trying to create an index file for a project of a mix of ts-files and vue-files.
I created a vue.d.ts file with the following declaration

declare module "*.vue" {
    import * as Vue from 'vue';
    export default Vue;
}

Sadly the vue components aren't included in the resulting index.ts file.

This is my ts-config:

{
  "compilerOptions": {
//    "sourceRoot": ".",
    /* Visit https://aka.ms/tsconfig to read more about this file */

    /* Projects */
    // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
    // "composite": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */
    // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */
    // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */
    // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */
    // "disableReferencedProjectLoad": true,             /* Reduce the number of projects loaded automatically by TypeScript. */

    /* Language and Environment */
    "target": "es2016",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
    "lib": ["dom", "es2021"],                                      /* Specify a set of bundled library declaration files that describe the target runtime environment. */
    // "jsx": "preserve",                                /* Specify what JSX code is generated. */
    // "experimentalDecorators": true,                   /* Enable experimental support for TC39 stage 2 draft decorators. */
    // "emitDecoratorMetadata": true,                    /* Emit design-type metadata for decorated declarations in source files. */
    // "jsxFactory": "",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
    // "jsxFragmentFactory": "",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
    // "jsxImportSource": "",                            /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
    // "reactNamespace": "",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
    // "noLib": true,                                    /* Disable including any library files, including the default lib.d.ts. */
    // "useDefineForClassFields": true,                  /* Emit ECMAScript-standard-compliant class fields. */
    // "moduleDetection": "auto",                        /* Control what method is used to detect module-format JS files. */

    /* Modules */
    "module": "commonjs",                                /* Specify what module code is generated. */
    // "rootDir": "./",                                  /* Specify the root folder within your source files. */
    // "moduleResolution": "node",                       /* Specify how TypeScript looks up a file from a given module specifier. */
    // "baseUrl": "./",                                  /* Specify the base directory to resolve non-relative module names. */
    // "paths": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */
    // "rootDirs": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */
    // "typeRoots": [],                                  /* Specify multiple folders that act like './node_modules/@types'. */
    // "types": [],                                      /* Specify type package names to be included without being referenced in a source file. */
    // "allowUmdGlobalAccess": true,                     /* Allow accessing UMD globals from modules. */
    // "moduleSuffixes": [],                             /* List of file name suffixes to search when resolving a module. */
    // "resolveJsonModule": true,                        /* Enable importing .json files. */
    // "noResolve": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

    /* JavaScript Support */
    // "allowJs": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
    // "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */
    // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

    /* Emit */
    // "declaration": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
    // "declarationMap": true,                           /* Create sourcemaps for d.ts files. */
    // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */
    // "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */
    // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
    // "outDir": "./",                                   /* Specify an output folder for all emitted files. */
    // "removeComments": true,                           /* Disable emitting comments. */
    // "noEmit": true,                                   /* Disable emitting files from a compilation. */
    // "importHelpers": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
    // "importsNotUsedAsValues": "remove",               /* Specify emit/checking behavior for imports that are only used for types. */
    // "downlevelIteration": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
    // "sourceRoot": "",                                 /* Specify the root path for debuggers to find the reference source code. */
    // "mapRoot": "",                                    /* Specify the location where debugger should locate map files instead of generated locations. */
    // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */
    // "inlineSources": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */
    // "emitBOM": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
    // "newLine": "crlf",                                /* Set the newline character for emitting files. */
    // "stripInternal": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
    // "noEmitHelpers": true,                            /* Disable generating custom helper functions like '__extends' in compiled output. */
    // "noEmitOnError": true,                            /* Disable emitting files if any type checking errors are reported. */
    // "preserveConstEnums": true,                       /* Disable erasing 'const enum' declarations in generated code. */
    // "declarationDir": "./",                           /* Specify the output directory for generated declaration files. */
    // "preserveValueImports": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

    /* Interop Constraints */
    // "isolatedModules": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */
    // "allowSyntheticDefaultImports": true,             /* Allow 'import x from y' when a module doesn't have a default export. */
    "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
    // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
    "forceConsistentCasingInFileNames": true,            /* Ensure that casing is correct in imports. */

    /* Type Checking */
    "strict": true,                                      /* Enable all strict type-checking options. */
    // "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
    // "strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
    // "strictFunctionTypes": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
    // "strictBindCallApply": true,                      /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
    // "strictPropertyInitialization": true,             /* Check for class properties that are declared but not set in the constructor. */
    // "noImplicitThis": true,                           /* Enable error reporting when 'this' is given the type 'any'. */
    // "useUnknownInCatchVariables": true,               /* Default catch clause variables as 'unknown' instead of 'any'. */
    // "alwaysStrict": true,                             /* Ensure 'use strict' is always emitted. */
    // "noUnusedLocals": true,                           /* Enable error reporting when local variables aren't read. */
    // "noUnusedParameters": true,                       /* Raise an error when a function parameter isn't read. */
    // "exactOptionalPropertyTypes": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */
    // "noImplicitReturns": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */
    // "noFallthroughCasesInSwitch": true,               /* Enable error reporting for fallthrough cases in switch statements. */
    // "noUncheckedIndexedAccess": true,                 /* Add 'undefined' to a type when accessed using an index. */
    // "noImplicitOverride": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */
    // "noPropertyAccessFromIndexSignature": true,       /* Enforces using indexed accessors for keys declared using an indexed type. */
    // "allowUnusedLabels": true,                        /* Disable error reporting for unused labels. */
    // "allowUnreachableCode": true,                     /* Disable error reporting for unreachable code. */

    /* Completeness */
    // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
    "skipLibCheck": false                                 /* Skip type checking all .d.ts files. */
  },
  "include": [
    "**/*.ts",
    "**/*.vue"
  ]
}

My command is ctix single --noBackup -p ./tsconfig.json -o index.ts --noBackup -w -s

Support for default imports?

Hi!

Is it possible to auto generate code for default imports with CTIX?

Like this:

// src/components/index.ts

export { default as Badge } from './Badge';
export type { TBadge } from './TBadge';

When I'm running it now I only get

// created from ctix 2024-01-09 22:08:10

export * from './Badge';
export * from './TBadge';

and my Vite conf doesn't seem to like that because it keeps on generating empty chunks. For reference, here:s my vite config and output!

/* eslint-disable unicorn/prefer-module */
import { resolve } from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import { rollupEntryPoints } from '@diageo/buildsystem'

const entry = rollupEntryPoints(resolve(__dirname, 'src/**/index.ts'))

export default defineConfig({
	plugins: [react(), dts({ include: ['src'] }), libInjectCss()],
	mode: 'production',
	publicDir: false,
	build: {
		minify: false,
		lib: {
			entry,
			formats: ['es'],
		},
		rollupOptions: {
			output: {
				entryFileNames: '[name].js',
				assetFileNames: 'assets/[name][extname]',
			},
			external: ['react', 'react/jsx-runtime'],
		},
	},
})

My Output

Entrypoints for 
/Users/simpel/Code/platform/packages/designsystem/src/**/index.ts

 {
  index: '/Users/simpel/Code/platform/packages/designsystem/src/index.ts',
  'utils/types/index': '/Users/simpel/Code/platform/packages/designsystem/src/utils/types/index.ts',
  'utils/toCSSVariable/index': '/Users/simpel/Code/platform/packages/designsystem/src/utils/toCSSVariable/index.ts',
  'utils/createCSSVariables/index': '/Users/simpel/Code/platform/packages/designsystem/src/utils/createCSSVariables/index.ts',
  'utils/convertCSSValue/index': '/Users/simpel/Code/platform/packages/designsystem/src/utils/convertCSSValue/index.ts',
  'theme/index': '/Users/simpel/Code/platform/packages/designsystem/src/theme/index.ts',
  'hooks/useTheme/index': '/Users/simpel/Code/platform/packages/designsystem/src/hooks/useTheme/index.ts',
  'helpers/index': '/Users/simpel/Code/platform/packages/designsystem/src/helpers/index.ts',
  'contexts/DiageoDesignSystemProvider/index': '/Users/simpel/Code/platform/packages/designsystem/src/contexts/DiageoDesignSystemProvider/index.ts',
  'contexts/DiageoDesignSystemContext/index': '/Users/simpel/Code/platform/packages/designsystem/src/contexts/DiageoDesignSystemContext/index.ts',
  'components/Tabs/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Tabs/index.ts',
  'components/States/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/States/index.ts',
  'components/StateInfo/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/StateInfo/index.ts',
  'components/Stat/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Stat/index.ts',
  'components/Spacer/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Spacer/index.ts',
  'components/Poi/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Poi/index.ts',
  'components/NorthAmericaMap/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/NorthAmericaMap/index.ts',
  'components/LogoBlock/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/LogoBlock/index.ts',
  'components/IconBalance/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/IconBalance/index.ts',
  'components/IconArrow/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/IconArrow/index.ts',
  'components/Headline/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Headline/index.ts',
  'components/GraphicCard/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/GraphicCard/index.ts',
  'components/Container/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Container/index.ts',
  'components/CarouselCard/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/CarouselCard/index.ts',
  'components/Carousel/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Carousel/index.ts',
  'components/Badge/index': '/Users/simpel/Code/platform/packages/designsystem/src/components/Badge/index.ts'
} 
--------------

vite v5.0.8 building for production...
✓ 217 modules transformed.
Generated an empty chunk: "components/Badge/index".
Generated an empty chunk: "components/Carousel/index".
Generated an empty chunk: "components/CarouselCard/index".
Generated an empty chunk: "components/Container/index".
Generated an empty chunk: "components/GraphicCard/index".
Generated an empty chunk: "components/Headline/index".
Generated an empty chunk: "components/IconArrow/index".
Generated an empty chunk: "components/IconBalance/index".
Generated an empty chunk: "components/LogoBlock/index".
Generated an empty chunk: "components/NorthAmericaMap/index".
Generated an empty chunk: "components/Poi/index".
Generated an empty chunk: "components/Spacer/index".
Generated an empty chunk: "components/Stat/index".
Generated an empty chunk: "components/StateInfo/index".
Generated an empty chunk: "components/Tabs/index".
Generated an empty chunk: "contexts/DiageoDesignSystemContext/index".
Generated an empty chunk: "contexts/DiageoDesignSystemProvider/index".
Generated an empty chunk: "theme/index".
Generated an empty chunk: "utils/types/index".

[vite:dts] Start generate declaration files...
dist/components/Badge/index.js                       0.00 kB │ gzip:  0.02 kB
dist/components/Carousel/index.js                    0.00 kB │ gzip:  0.02 kB
dist/components/CarouselCard/index.js                0.00 kB │ gzip:  0.02 kB
dist/components/Container/index.js                   0.00 kB │ gzip:  0.02 kB
dist/components/GraphicCard/index.js                 0.00 kB │ gzip:  0.02 kB
dist/components/Headline/index.js                    0.00 kB │ gzip:  0.02 kB
dist/components/IconArrow/index.js                   0.00 kB │ gzip:  0.02 kB
dist/components/IconBalance/index.js                 0.00 kB │ gzip:  0.02 kB
dist/components/LogoBlock/index.js                   0.00 kB │ gzip:  0.02 kB
dist/components/NorthAmericaMap/index.js             0.00 kB │ gzip:  0.02 kB
dist/components/Poi/index.js                         0.00 kB │ gzip:  0.02 kB
dist/components/Spacer/index.js                      0.00 kB │ gzip:  0.02 kB
dist/components/Stat/index.js                        0.00 kB │ gzip:  0.02 kB
dist/components/StateInfo/index.js                   0.00 kB │ gzip:  0.02 kB
dist/components/Tabs/index.js                        0.00 kB │ gzip:  0.02 kB
dist/contexts/DiageoDesignSystemContext/index.js     0.00 kB │ gzip:  0.02 kB
dist/contexts/DiageoDesignSystemProvider/index.js    0.00 kB │ gzip:  0.02 kB
dist/theme/index.js                                  0.00 kB │ gzip:  0.02 kB
dist/utils/types/index.js                            0.00 kB │ gzip:  0.02 kB
dist/hooks/useTheme/index.js                         0.08 kB │ gzip:  0.08 kB
dist/index-YBDA8n6_.js                               0.32 kB │ gzip:  0.25 kB
dist/utils/toCSSVariable/index.js                    0.42 kB │ gzip:  0.25 kB
dist/utils/convertCSSValue/index.js                  0.52 kB │ gzip:  0.20 kB
dist/index.js                                        0.57 kB │ gzip:  0.23 kB
dist/utils/createCSSVariables/index.js               0.77 kB │ gzip:  0.38 kB
dist/helpers/index.js                                1.03 kB │ gzip:  0.39 kB
dist/useTheme-Ne8twTx6.js                            1.58 kB │ gzip:  0.61 kB
dist/components/States/index.js                    104.40 kB │ gzip: 43.42 kB
[vite:dts] Declaration files built in 1346ms.

✓ built in 2.10s

Configurations with different exportFilename always export index.ts

    {
      "mode": "bundle",
      "project": "tsconfig.json",
      "exportFilename": "index.ts",
      "useSemicolon": true,
      "useBanner": true,
      "useTimestamp": false,
      "quote": "\"",
      // Use to add a literal like `"use strict"` to the top. It will be added before the banner.
      //
      // @mode create, bundle
      "directive": "",
      "fileExt": "to-js",
      "overwrite": true,
      "backup": false,
      "generationStyle": "default-alias-named-star",
      // A list of files to use when generating the index.ts file. If no value is set,
      // the value of the include setting set in the tsconfig.json file will be used
      //
      // @mode create, bundle
      "include": [
        "src/**/*"
      ],
      // A list of files to exclude when generating the index.ts file. If no value is set,
      // the value of the exclude setting set in the tsconfig.json file is used
      //
      // @mode create, bundle
      "exclude": [
        "**/*polyfills*.ts",
        "**/*evils*.ts"
      ],
      "skipEmptyDir": true,
      "startFrom": "src",
      "output": "src",
      // remove with backup file
      // @mode remove
      // @default false
      "removeBackup": false,
      // answer `yes` to all questions
      // @mode remove
      // @default false
      "forceYes": false
    }
    {
      "mode": "bundle",
      "project": "tsconfig.json",
      "exportFilename": "polyfills.ts",
      "useSemicolon": true,
      "useBanner": true,
      "useTimestamp": false,
      "quote": "\"",
      // Use to add a literal like `"use strict"` to the top. It will be added before the banner.
      //
      // @mode create, bundle
      "directive": "",
      "fileExt": "to-js",
      "overwrite": true,
      "backup": false,
      "generationStyle": "default-alias-named-star",
      // A list of files to use when generating the index.ts file. If no value is set,
      // the value of the include setting set in the tsconfig.json file will be used
      //
      // @mode create, bundle
      "include": [
        "src/**/*polyfills*.ts"
      ],
      // A list of files to exclude when generating the index.ts file. If no value is set,
      // the value of the exclude setting set in the tsconfig.json file is used
      //
      // @mode create, bundle
      "exclude": [
      ],
      "skipEmptyDir": true,
      "startFrom": "src",
      "output": "src",
      // remove with backup file
      // @mode remove
      // @default false
      "removeBackup": false,
      // answer `yes` to all questions
      // @mode remove
      // @default false
      "forceYes": false
    }

Configurations with different exportFilename always export index.ts.

How to exclude __tests__ folders?

Hello,

I am able to successfully generate an index.ts file but this also contains entries like this;

export * from "./__tests__/some/path";

How do I exclude test folders from being added to the index?

Thanks in advance :-)

useRootDir unexpected behavior

Hi,

I was trying to create a single index.ts by the command npx ctix single -p ./tsconfig.json --useRootDir,
the index.ts is created, however, all export statements have the rootDir prefix path.

截圖 2022-01-20 下午12 06 09

module.exports fails

Example:

a = {}
a.b = {}
a.b.c = {}
a.b.c.X = function () {}

module.exports = a.b.c;

results with ERROR Cannot support type: (206) a.b.c.X.

An export like the above is produced by protoc-gen-grpc-web.

[question]: Cannot configure `.ctiignore` file: ignore file loading complete error: detailIgnoreds.at is not a function

I tried to filter exports, but I could not configure the .ctiignore file. The fix must be simple, but I could not figure out how partial ignore works.

My setup:

src/foo.ts:

export interface Foo {}
export interface Bar {}

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  },
  "include": [
    "./src"
  ]
}

.ctiignore:

{
    "**/*.ts": ["Bar"]
}

I did:

npx ctix single -p ./tsconfig.json -o ./src/index.ts

I got:

  ignore file loading complete
[22-09-14 12:04:41] error: detailIgnoreds.at is not a function
[22-09-14 12:04:41] error: TypeError: detailIgnoreds.at is not a function
    at getCtiIgnorePattern (/Users/path/to/my/project/node_modules/ctix/dist/cli.js:946:31)
    at getExportInfo (/Users/path/to/my/project/node_modules/ctix/dist/cli.js:984:26)
    at async Promise.all (index 0)
    at getExportInfos (/Users/path/to/my/project/node_modules/ctix/dist/cli.js:1067:26)
    at singleWritor (/Users/path/to/my/project/node_modules/ctix/dist/cli.js:2047:34)
    at Object.handler (/Users/path/to/my/project/node_modules/ctix/dist/cli.js:2213:13)

I also tried the following ignore files, but none of them worked:

{
    "src/foo.ts": ["Bar"]
}
{
    "./src/foo.ts": ["Bar"]
}
{
    "*": ["Bar"]
}
{
    "**/*": ["Bar"]
}

I am using [email protected]. Thank you!

export default HoC's are not supported

As title states, exporting a HoC directly as unnamed default fails to compile with error:
[22-10-25 23:17:38] error: Cannot support type: (208) withTheme()(TestComponent)
[22-10-25 23:17:38] error: Error: Cannot support type: (208) withTheme()(TestComponent)

Is it a configuration thing, or does something need to be fixed on the back-end in order to support this
Basic minified example repo:
https://github.com/L03TJ3/Sample_ExportHOC

Thanks!

index.ts is not created

Hi @imjuni,

I try to get this tool running in my project.
Great idea btw! I like it very much! 👍

Unfortunately I have problems generating any index.ts file at all.
Both modes, create and single aren't generating any index file.

The following setup won't work (current version 0.3.3):
image

I also checked out locally ctix-reproducable-master at https://github.com/raphaelsoul/ctix-reproducable
Updated ctix to 0.3.3:
Here I can generate index.ts files, even with copied tsconfig.json from my project.

Is there a bug, or do I miss some configuration? Maybe you got some hints.

Thanks and best regards!
iDschepe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.