@openwebf/webf 0.22.5 → 0.22.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/commands.js +25 -6
- package/package.json +1 -1
- package/src/commands.ts +29 -5
package/dist/commands.js
CHANGED
|
@@ -317,6 +317,8 @@ function generateCommand(distPath, options) {
|
|
|
317
317
|
const hasTsConfig = fs_1.default.existsSync(tsConfigPath);
|
|
318
318
|
// Determine if we need to create a new project
|
|
319
319
|
const needsProjectCreation = !hasPackageJson || !hasGlobalDts || !hasTsConfig;
|
|
320
|
+
// Track if this is an existing project (has all required files)
|
|
321
|
+
const isExistingProject = hasPackageJson && hasGlobalDts && hasTsConfig;
|
|
320
322
|
let framework = options.framework;
|
|
321
323
|
let packageName = options.packageName;
|
|
322
324
|
// Validate and sanitize package name if provided
|
|
@@ -526,7 +528,7 @@ function generateCommand(distPath, options) {
|
|
|
526
528
|
// Handle npm publishing if requested via command line option
|
|
527
529
|
if (options.publishToNpm && framework) {
|
|
528
530
|
try {
|
|
529
|
-
yield buildAndPublishPackage(resolvedDistPath, options.npmRegistry);
|
|
531
|
+
yield buildAndPublishPackage(resolvedDistPath, options.npmRegistry, isExistingProject);
|
|
530
532
|
}
|
|
531
533
|
catch (error) {
|
|
532
534
|
console.error('\nError during npm publish:', error);
|
|
@@ -561,7 +563,7 @@ function generateCommand(distPath, options) {
|
|
|
561
563
|
}
|
|
562
564
|
}]);
|
|
563
565
|
try {
|
|
564
|
-
yield buildAndPublishPackage(resolvedDistPath, registryAnswer.registry || undefined);
|
|
566
|
+
yield buildAndPublishPackage(resolvedDistPath, registryAnswer.registry || undefined, isExistingProject);
|
|
565
567
|
}
|
|
566
568
|
catch (error) {
|
|
567
569
|
console.error('\nError during npm publish:', error);
|
|
@@ -652,17 +654,34 @@ function buildPackage(packagePath) {
|
|
|
652
654
|
}
|
|
653
655
|
});
|
|
654
656
|
}
|
|
655
|
-
function buildAndPublishPackage(
|
|
656
|
-
return __awaiter(this,
|
|
657
|
+
function buildAndPublishPackage(packagePath_1, registry_1) {
|
|
658
|
+
return __awaiter(this, arguments, void 0, function* (packagePath, registry, isExistingProject = false) {
|
|
657
659
|
const packageJsonPath = path_1.default.join(packagePath, 'package.json');
|
|
658
660
|
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
659
661
|
throw new Error(`No package.json found in ${packagePath}`);
|
|
660
662
|
}
|
|
661
|
-
|
|
663
|
+
let packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
|
|
662
664
|
const packageName = packageJson.name;
|
|
663
|
-
|
|
665
|
+
let packageVersion = packageJson.version;
|
|
664
666
|
// First, ensure dependencies are installed and build the package
|
|
665
667
|
yield buildPackage(packagePath);
|
|
668
|
+
// If this is an existing project, increment the patch version before publishing
|
|
669
|
+
if (isExistingProject) {
|
|
670
|
+
console.log(`\nIncrementing version for existing project...`);
|
|
671
|
+
const versionResult = (0, child_process_1.spawnSync)(NPM, ['version', 'patch', '--no-git-tag-version'], {
|
|
672
|
+
cwd: packagePath,
|
|
673
|
+
encoding: 'utf-8',
|
|
674
|
+
stdio: 'pipe'
|
|
675
|
+
});
|
|
676
|
+
if (versionResult.status !== 0) {
|
|
677
|
+
console.error('Failed to increment version:', versionResult.stderr);
|
|
678
|
+
throw new Error('Failed to increment version');
|
|
679
|
+
}
|
|
680
|
+
// Re-read package.json to get the new version
|
|
681
|
+
packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'));
|
|
682
|
+
packageVersion = packageJson.version;
|
|
683
|
+
console.log(`Version updated to ${packageVersion}`);
|
|
684
|
+
}
|
|
666
685
|
// Set registry if provided
|
|
667
686
|
if (registry) {
|
|
668
687
|
console.log(`\nUsing npm registry: ${registry}`);
|
package/package.json
CHANGED
package/src/commands.ts
CHANGED
|
@@ -395,6 +395,9 @@ async function generateCommand(distPath: string, options: GenerateOptions): Prom
|
|
|
395
395
|
// Determine if we need to create a new project
|
|
396
396
|
const needsProjectCreation = !hasPackageJson || !hasGlobalDts || !hasTsConfig;
|
|
397
397
|
|
|
398
|
+
// Track if this is an existing project (has all required files)
|
|
399
|
+
const isExistingProject = hasPackageJson && hasGlobalDts && hasTsConfig;
|
|
400
|
+
|
|
398
401
|
let framework = options.framework;
|
|
399
402
|
let packageName = options.packageName;
|
|
400
403
|
|
|
@@ -620,7 +623,7 @@ async function generateCommand(distPath: string, options: GenerateOptions): Prom
|
|
|
620
623
|
// Handle npm publishing if requested via command line option
|
|
621
624
|
if (options.publishToNpm && framework) {
|
|
622
625
|
try {
|
|
623
|
-
await buildAndPublishPackage(resolvedDistPath, options.npmRegistry);
|
|
626
|
+
await buildAndPublishPackage(resolvedDistPath, options.npmRegistry, isExistingProject);
|
|
624
627
|
} catch (error) {
|
|
625
628
|
console.error('\nError during npm publish:', error);
|
|
626
629
|
process.exit(1);
|
|
@@ -655,7 +658,8 @@ async function generateCommand(distPath: string, options: GenerateOptions): Prom
|
|
|
655
658
|
try {
|
|
656
659
|
await buildAndPublishPackage(
|
|
657
660
|
resolvedDistPath,
|
|
658
|
-
registryAnswer.registry || undefined
|
|
661
|
+
registryAnswer.registry || undefined,
|
|
662
|
+
isExistingProject
|
|
659
663
|
);
|
|
660
664
|
} catch (error) {
|
|
661
665
|
console.error('\nError during npm publish:', error);
|
|
@@ -760,20 +764,40 @@ async function buildPackage(packagePath: string): Promise<void> {
|
|
|
760
764
|
}
|
|
761
765
|
}
|
|
762
766
|
|
|
763
|
-
async function buildAndPublishPackage(packagePath: string, registry?: string): Promise<void> {
|
|
767
|
+
async function buildAndPublishPackage(packagePath: string, registry?: string, isExistingProject: boolean = false): Promise<void> {
|
|
764
768
|
const packageJsonPath = path.join(packagePath, 'package.json');
|
|
765
769
|
|
|
766
770
|
if (!fs.existsSync(packageJsonPath)) {
|
|
767
771
|
throw new Error(`No package.json found in ${packagePath}`);
|
|
768
772
|
}
|
|
769
773
|
|
|
770
|
-
|
|
774
|
+
let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
771
775
|
const packageName = packageJson.name;
|
|
772
|
-
|
|
776
|
+
let packageVersion = packageJson.version;
|
|
773
777
|
|
|
774
778
|
// First, ensure dependencies are installed and build the package
|
|
775
779
|
await buildPackage(packagePath);
|
|
776
780
|
|
|
781
|
+
// If this is an existing project, increment the patch version before publishing
|
|
782
|
+
if (isExistingProject) {
|
|
783
|
+
console.log(`\nIncrementing version for existing project...`);
|
|
784
|
+
const versionResult = spawnSync(NPM, ['version', 'patch', '--no-git-tag-version'], {
|
|
785
|
+
cwd: packagePath,
|
|
786
|
+
encoding: 'utf-8',
|
|
787
|
+
stdio: 'pipe'
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
if (versionResult.status !== 0) {
|
|
791
|
+
console.error('Failed to increment version:', versionResult.stderr);
|
|
792
|
+
throw new Error('Failed to increment version');
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// Re-read package.json to get the new version
|
|
796
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
797
|
+
packageVersion = packageJson.version;
|
|
798
|
+
console.log(`Version updated to ${packageVersion}`);
|
|
799
|
+
}
|
|
800
|
+
|
|
777
801
|
// Set registry if provided
|
|
778
802
|
if (registry) {
|
|
779
803
|
console.log(`\nUsing npm registry: ${registry}`);
|